From 4d0f450deaa8d62663e3b0450ec1501b67cbb544 Mon Sep 17 00:00:00 2001 From: rudtj Date: Fri, 15 Nov 2024 17:49:53 +0900 Subject: [PATCH 01/46] fix: store api --- src/api/storeApi.ts | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/api/storeApi.ts diff --git a/src/api/storeApi.ts b/src/api/storeApi.ts new file mode 100644 index 0000000..c54041a --- /dev/null +++ b/src/api/storeApi.ts @@ -0,0 +1,30 @@ +import { useMutation, useQueryClient } from "@tanstack/react-query"; +import { defaultApi } from "@api/axiosInstance"; + +type StoreData = { + name: string; + address: string; + phone: number; +}; + +const useCreateStore = () => { + const fetcher = (storeData: StoreData) => defaultApi.post(`/api/stores`, storeData).then(({ data }) => data); + + return useMutation({ mutationFn: fetcher }); +}; + +const useUpdateStore = () => { + const queryClient = useQueryClient(); + + const fetcher = (storeData: StoreData) => defaultApi.put(`/api/stores`, storeData).then(({ data }) => data); + + return useMutation({ + mutationFn: fetcher, + onSuccess: () => + queryClient.invalidateQueries({ + queryKey: ["store"], + }), + }); +}; + +export { useCreateStore, useUpdateStore }; From 3dcaecf0ce4510b987867487d5d926178bd3c52d Mon Sep 17 00:00:00 2001 From: gimdogyun Date: Mon, 18 Nov 2024 18:36:25 +0900 Subject: [PATCH 02/46] refactor: change localstorage key - #140 --- src/api/axiosInstance.ts | 4 ++-- src/api/intercepters.ts | 4 ++-- src/atoms/userAtom.ts | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/api/axiosInstance.ts b/src/api/axiosInstance.ts index 254d0f5..f4bed3d 100644 --- a/src/api/axiosInstance.ts +++ b/src/api/axiosInstance.ts @@ -19,8 +19,8 @@ const needAuthDefaultApi = axios.create({ baseURL: process.env.REACT_APP_API_URL, headers: { "Content-Type": "application/json", - Authorization: JSON.parse(localStorage.getItem("poomasi_user") || "{}")?.token - ? `Bearer ${JSON.parse(localStorage.getItem("poomasi_user") || "{}").token}` + Authorization: JSON.parse(localStorage.getItem("poomasi-user") || "{}")?.token + ? `Bearer ${JSON.parse(localStorage.getItem("poomasi-user") || "{}").token}` : undefined, }, withCredentials: true, diff --git a/src/api/intercepters.ts b/src/api/intercepters.ts index 22e29df..e2032ea 100644 --- a/src/api/intercepters.ts +++ b/src/api/intercepters.ts @@ -13,10 +13,10 @@ const refrechIntercepter = async (response: AxiosResponse): Promise { @@ -16,7 +16,7 @@ const userAtomWithPersistence = atom( }, (_, set, data: UserAtomValue | null) => { set(userAtom, JSON.stringify(data)); - localStorage.setItem("poomasi_user", JSON.stringify(data)); + localStorage.setItem("poomasi-user", JSON.stringify(data)); }, ); From a75d6d682bb8ab6e89bb163305ff6c9704a766a5 Mon Sep 17 00:00:00 2001 From: gimdogyun Date: Mon, 18 Nov 2024 18:36:53 +0900 Subject: [PATCH 03/46] refactor: header - #140 --- src/components/layouts/Header.tsx | 150 +++++++++++++----------------- src/hooks/useLogin.ts | 2 +- 2 files changed, 67 insertions(+), 85 deletions(-) diff --git a/src/components/layouts/Header.tsx b/src/components/layouts/Header.tsx index 6f2960d..d07f259 100644 --- a/src/components/layouts/Header.tsx +++ b/src/components/layouts/Header.tsx @@ -1,109 +1,91 @@ -import { useState } from "react"; -import { Link } from "react-router-dom"; -import { HeartOutlined, ShoppingCartOutlined } from "@ant-design/icons"; -import { Box, Flex, Text, Icon } from "@chakra-ui/react"; +import { Link, useLocation } from "react-router-dom"; +import { HeartOutlined, ShoppingCartOutlined, LogoutOutlined } from "@ant-design/icons"; +import { Flex, Text, Icon } from "@chakra-ui/react"; import poomasi from "@assets/logo/logo.png"; +import Avatar from "@components/common/Avatar"; import Image from "@components/common/Image"; import useLogin from "@hooks/useLogin"; -const Header = () => { - const [activeMenu, setActiveMenu] = useState(""); +const menuLinks = [ + { + name: "소개", + link: "/introduction", + }, + { + name: "상점", + link: "/store", + }, + { + name: "농장", + link: "/schedule", + }, +]; - const { loginCheck, logout, sellerCheck } = useLogin(); +const Header = () => { + const location = useLocation(); - const handleMenuClick = (menu: string) => { - setActiveMenu(menu); - }; + const { user, loginCheck, logout, sellerCheck } = useLogin(); return ( - - {loginCheck() - ? [ - - 마이페이지 - , - - 로그아웃 - , - ] - : [ - - 회원가입 - , - - 로그인 - , - ]} - {sellerCheck() && ( - - 판매자 페이지 - - )} - - - - - poomasi - - - - - handleMenuClick("소개")} - > - 소개 - + + + + poomasi - + {sellerCheck() && ( handleMenuClick("상점")} + to="/seller" > - 상점 + farmer - - + )} + {menuLinks.map(menuLink => ( handleMenuClick("농장")} + to={menuLink.link} > - 농장 + {menuLink.name} - + ))} - {/* */} - - - - - - - - + + {loginCheck() ? ( + [ + + + , + + + , + + + + {user.name}님 + + , + logout()} />, + ] + ) : ( + + 로그인 + + )} diff --git a/src/hooks/useLogin.ts b/src/hooks/useLogin.ts index b46a42b..a8bb89b 100644 --- a/src/hooks/useLogin.ts +++ b/src/hooks/useLogin.ts @@ -30,7 +30,7 @@ const useLogin = () => { const sellerCheck = () => user?.role === "ROLE_FARMER"; - return { login, logout, loginCheck, sellerCheck }; + return { user, login, logout, loginCheck, sellerCheck }; }; export default useLogin; From e505c4d839936a0862ec034a39415f2523d84e98 Mon Sep 17 00:00:00 2001 From: gimdogyun Date: Mon, 18 Nov 2024 21:59:24 +0900 Subject: [PATCH 04/46] test: localtest - #140 --- src/components/common/KaKaoLoginButton.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/common/KaKaoLoginButton.tsx b/src/components/common/KaKaoLoginButton.tsx index 489d350..38a3ede 100644 --- a/src/components/common/KaKaoLoginButton.tsx +++ b/src/components/common/KaKaoLoginButton.tsx @@ -4,7 +4,7 @@ import Image from "@components/common/Image"; type KaKaoLoginButtonProps = ImageProps; const KaKaoLoginButton = ({ ...props }: KaKaoLoginButtonProps) => { - const link = "https://api.poomasi.shop/oauth2/authentication/kakao"; + const link = "http://172.22.42.12:8080/oauth2/authentication/kakao"; return ( From ec9e46a6ef8274b104d1cecb91c99ce8cdeba0df Mon Sep 17 00:00:00 2001 From: rudtj Date: Mon, 18 Nov 2024 23:06:00 +0900 Subject: [PATCH 05/46] =?UTF-8?q?refactor:=20farmlist=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../features/MyPage/Order/FarmList.tsx | 110 +++++++++++------- 1 file changed, 68 insertions(+), 42 deletions(-) diff --git a/src/components/features/MyPage/Order/FarmList.tsx b/src/components/features/MyPage/Order/FarmList.tsx index 25a161d..90ce464 100644 --- a/src/components/features/MyPage/Order/FarmList.tsx +++ b/src/components/features/MyPage/Order/FarmList.tsx @@ -1,56 +1,82 @@ +import { useState } from "react"; import { Flex, Button, Text } from "@chakra-ui/react"; import farm1 from "@assets/Image/Farm/Farm1.png"; import Image from "@components/common/Image"; +import ReviewModal from "./ReviewModal"; -const FarmList = () => ( - +const FarmList = () => { + const [isModalOpen, setModalOpen] = useState(false); + + const handleOpenModal = () => { + setModalOpen(true); + }; + + const handleCloseModal = () => { + setModalOpen(false); + }; + + return ( - + 2024.09.14 지민이네 복숭아 농장 - - Farm image - - 가끔 지민은 학교에서 심각하게 집에 가고싶을 때가 있어요. 그럴 때면 로만이나 자스민에서 산 달달한 복숭아 - 아이스티를 마시며 향수병을 달랩니다. - - - + + Farm image + + + + 주소 :  + + + 부산대학교 금정구 중앙대로 1616 + + - - - + + 한 줄 소개 + + + 가끔 지민은 학교에서 심각하게 집에 가고싶을 때마다 달달한 복숭아 아이스티를 마시며 향수병을 달랩니다. + + + + + + {isModalOpen && } + + - -); + ); +}; export default FarmList; From 123e01873fb5ca522ed67b8100ff0629e44fa385 Mon Sep 17 00:00:00 2001 From: rudtj Date: Mon, 18 Nov 2024 23:06:25 +0900 Subject: [PATCH 06/46] =?UTF-8?q?refactor:=20review=20modal=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../features/MyPage/Order/ReviewModal.tsx | 40 ++++++++++--------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/src/components/features/MyPage/Order/ReviewModal.tsx b/src/components/features/MyPage/Order/ReviewModal.tsx index 6f2f578..cf29efe 100644 --- a/src/components/features/MyPage/Order/ReviewModal.tsx +++ b/src/components/features/MyPage/Order/ReviewModal.tsx @@ -10,7 +10,7 @@ import { Divider, Icon, Input, - Box, + Textarea, } from "@chakra-ui/react"; import Image from "@components/common/Image"; import StarRating from "@components/common/StarRating"; @@ -39,7 +39,7 @@ const ReviewModal: React.FC = ({ isOpen, onClose, productId }) setRating(newRating); }; - const handleReviewTextChange = (event: React.ChangeEvent) => { + const handleReviewTextChange = (event: React.ChangeEvent) => { setReviewText(event.target.value); }; @@ -54,7 +54,7 @@ const ReviewModal: React.FC = ({ isOpen, onClose, productId }) }; return ( - + 후기 쓰기 @@ -80,32 +80,34 @@ const ReviewModal: React.FC = ({ isOpen, onClose, productId }) as={UploadOutlined} mx="5" mt={12} - ml={-200} + ml={-230} color="#000000" fontSize="30px" cursor="pointer" onClick={() => mainImageInputRef.current?.click()} /> - + main image - - - - +