Skip to content

Commit

Permalink
Merge pull request #149 from kakao-tech-campus-2nd-step3/Feature/Orde…
Browse files Browse the repository at this point in the history
…rRefactor-#139

Feature/order refactor #139
  • Loading branch information
rudtj authored Nov 19, 2024
2 parents 7278bba + ba3f938 commit 2e7defa
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 10 deletions.
38 changes: 35 additions & 3 deletions src/api/emailApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,21 @@ type LoginData = {
password: string;
};

type FarmerData = {
type FarmerRegisterData = {
name: string;
address: string;
phone: string;
};

type FarmerData = {
name: string;
email: string;
password: string;
phoneNumber: string;
storeName: string;
storeAddress: string;
};

type AddressData = {
defaultAddress: string;
addressDetail: string;
Expand All @@ -39,7 +49,7 @@ const useLoginEmail = () => {
};

const useCreateFarmer = () => {
const fetcher = (farmerData: FarmerData) =>
const fetcher = (farmerData: FarmerRegisterData) =>
needAuthDefaultApi.put(`/api/members/to-farmer`, farmerData).then(({ data }) => data);
return useMutation({ mutationFn: fetcher });
};
Expand All @@ -58,6 +68,20 @@ const useUpdateEmail = () => {
});
};

const useUpdateFarmer = () => {
const queryClient = useQueryClient();
const fetcher = (updateData: FarmerData) =>
needAuthDefaultApi.put(`/api/members/update/farmer`, updateData).then(({ data }) => data);

return useMutation({
mutationFn: fetcher,
onSuccess: () =>
queryClient.invalidateQueries({
queryKey: ["farmer"],
}),
});
};

const useUpdateAddress = () => {
const queryClient = useQueryClient();
const fetcher = (updateData: AddressData) =>
Expand All @@ -82,4 +106,12 @@ const useDeleteAccount = () => {
});
};

export { useCreateEmail, useLoginEmail, useUpdateEmail, useUpdateAddress, useCreateFarmer, useDeleteAccount };
export {
useCreateEmail,
useLoginEmail,
useUpdateEmail,
useUpdateAddress,
useCreateFarmer,
useUpdateFarmer,
useDeleteAccount,
};
8 changes: 4 additions & 4 deletions src/api/productApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type ProductData = {
};

const useGetProducts = () => {
const fetcher = () => defaultApi.get(`/products`).then(({ data }) => data);
const fetcher = () => defaultApi.get(`/api/products`).then(({ data }) => data);

return useQuery({
queryKey: ["products"],
Expand All @@ -29,7 +29,7 @@ const useGetProducts = () => {
};

const useGetProductDetail = (productId: number) => {
const fetcher = () => defaultApi.get(`/products/${productId}`).then(({ data }) => data);
const fetcher = () => defaultApi.get(`/api/products/${productId}`).then(({ data }) => data);
return useQuery({
queryKey: ["products", productId],
queryFn: fetcher,
Expand All @@ -38,7 +38,7 @@ const useGetProductDetail = (productId: number) => {
};

const useCreateProducts = () => {
const fetcher = (productData: ProductData) => defaultApi.post(`/products`, productData).then(({ data }) => data);
const fetcher = (productData: ProductData) => defaultApi.post(`/api/products`, productData).then(({ data }) => data);

return useMutation({ mutationFn: fetcher });
};
Expand All @@ -47,7 +47,7 @@ const useUpdateProducts = (productId: number) => {
const queryClient = useQueryClient();

const fetcher = (productData: ProductData) =>
defaultApi.put(`/products/${productId}`, productData).then(({ data }) => data);
defaultApi.put(`/api/products/${productId}`, productData).then(({ data }) => data);

return useMutation({
mutationFn: fetcher,
Expand Down
2 changes: 1 addition & 1 deletion src/components/features/MyPage/Category.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const Category = () => (
</Flex>
<ChakraLink
as={Link}
w="50px"
w="100px"
h="20px"
mt={3}
ml={5}
Expand Down
2 changes: 1 addition & 1 deletion src/components/features/StorePage/StoreBanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const StoreBanner = () => (
<Image h="full" src="/assets/image/vegetables.png" />
<Flex align="center" justify="center" direction="column" w="470px" h="full" color="white">
<Text fontSize="xl" fontWeight="bold">
믿고 먹는 건간한 먹거리,{" "}
믿고 먹는 건강한 먹거리,{" "}
<Text as="span" color="#48BB78">
품앗이
</Text>{" "}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/MyPage/ProductWishlistPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Card from "@components/common/Card";
import ProductWish from "@components/features/MyPage/Wishlist/ProductWish";

const ProductWishlistPage = () => (
<Card title="위시리스트-농산물" w="100%" h="fit-content" p="10">
<Card title="위시리스트" w="100%" h="fit-content" p="10">
<ProductWish />
</Card>
);
Expand Down

0 comments on commit 2e7defa

Please sign in to comment.