From dcf2a843ddbc0a2b8f323cf9336e7f80a2fcdfd8 Mon Sep 17 00:00:00 2001 From: yunsung Date: Mon, 9 Dec 2024 16:11:44 +0900 Subject: [PATCH 01/12] =?UTF-8?q?fix:=20=EA=B2=B0=EC=A0=9C=20=EC=99=84?= =?UTF-8?q?=EB=A3=8C=20=ED=8E=98=EC=9D=B4=EC=A7=80=20=EB=B3=80=EC=88=98=20?= =?UTF-8?q?=EC=88=98=EC=A0=95(#14)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/pages/Payment/PaymentFailPage.tsx | 2 +- src/components/pages/Payment/PaymentSuccessPage.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/pages/Payment/PaymentFailPage.tsx b/src/components/pages/Payment/PaymentFailPage.tsx index dffe762..9891645 100644 --- a/src/components/pages/Payment/PaymentFailPage.tsx +++ b/src/components/pages/Payment/PaymentFailPage.tsx @@ -11,7 +11,7 @@ const PaymentFailPage = () => { const productId = Number(id); const queryString = window.location.search; const urlParams = new URLSearchParams(queryString); - const amount = urlParams.get('totalAmount'); + const amount = urlParams.get('price'); const { data: product, isLoading, isError } = useProductQuery(productId); if (!product) { diff --git a/src/components/pages/Payment/PaymentSuccessPage.tsx b/src/components/pages/Payment/PaymentSuccessPage.tsx index aa61298..db95635 100644 --- a/src/components/pages/Payment/PaymentSuccessPage.tsx +++ b/src/components/pages/Payment/PaymentSuccessPage.tsx @@ -12,7 +12,7 @@ const PaymentSuccessPage = () => { const queryString = window.location.search; const urlParams = new URLSearchParams(queryString); - const amount = urlParams.get('totalAmount'); + const amount = urlParams.get('price'); const { data: product, isLoading, isError } = useProductQuery(productId); From a607845d70e23c15bd72ed3e31cea9524b78d809 Mon Sep 17 00:00:00 2001 From: yunsung Date: Mon, 9 Dec 2024 17:20:37 +0900 Subject: [PATCH 02/12] =?UTF-8?q?fix:=20=EA=B0=81=EC=A2=85=20=EC=98=A4?= =?UTF-8?q?=EB=A5=98=20=EC=88=98=EC=A0=95(#1)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/common/Header.tsx | 8 +++----- src/components/pages/HomePage/HomePage.tsx | 1 + src/components/pages/Payment/PaymentFailPage.tsx | 4 ++-- src/components/pages/Payment/PaymentSuccessPage.tsx | 4 ++-- src/components/pages/ProductDetailPage/ProductDetail.tsx | 2 +- src/components/pages/ProductDetailPage/api/CommentApi.ts | 9 +++------ src/components/pages/ProductPage/ProductComponent.tsx | 2 +- src/components/pages/login/SignInPage.tsx | 1 + 8 files changed, 14 insertions(+), 17 deletions(-) diff --git a/src/components/common/Header.tsx b/src/components/common/Header.tsx index 24b0820..5b538f1 100644 --- a/src/components/common/Header.tsx +++ b/src/components/common/Header.tsx @@ -54,7 +54,7 @@ const Header = () => { {isLoggedIn && ( {isAdmin ? 'Admin Page' : 'My Page'} @@ -63,12 +63,10 @@ const Header = () => { {isAdmin && ( - - Post Management - + Post Management - + Chat Management diff --git a/src/components/pages/HomePage/HomePage.tsx b/src/components/pages/HomePage/HomePage.tsx index b75a667..b9f9dc7 100644 --- a/src/components/pages/HomePage/HomePage.tsx +++ b/src/components/pages/HomePage/HomePage.tsx @@ -11,6 +11,7 @@ import { categories } from './model/categories'; const HomePage: React.FC = () => { const { data: products, isLoading, isError } = useProductsQuery(); + console.log(products); const availableProduct = products?.filter( (p) => p.available === true && new Date(p.deadline) > new Date() ); diff --git a/src/components/pages/Payment/PaymentFailPage.tsx b/src/components/pages/Payment/PaymentFailPage.tsx index 9891645..16b2b76 100644 --- a/src/components/pages/Payment/PaymentFailPage.tsx +++ b/src/components/pages/Payment/PaymentFailPage.tsx @@ -11,7 +11,7 @@ const PaymentFailPage = () => { const productId = Number(id); const queryString = window.location.search; const urlParams = new URLSearchParams(queryString); - const amount = urlParams.get('price'); + const price = urlParams.get('price'); const { data: product, isLoading, isError } = useProductQuery(productId); if (!product) { @@ -33,7 +33,7 @@ const PaymentFailPage = () => { - {amount} 원 + {price} 원 diff --git a/src/components/pages/Payment/PaymentSuccessPage.tsx b/src/components/pages/Payment/PaymentSuccessPage.tsx index db95635..6c0927c 100644 --- a/src/components/pages/Payment/PaymentSuccessPage.tsx +++ b/src/components/pages/Payment/PaymentSuccessPage.tsx @@ -12,7 +12,7 @@ const PaymentSuccessPage = () => { const queryString = window.location.search; const urlParams = new URLSearchParams(queryString); - const amount = urlParams.get('price'); + const price = urlParams.get('price'); const { data: product, isLoading, isError } = useProductQuery(productId); @@ -34,7 +34,7 @@ const PaymentSuccessPage = () => { - {amount}원 + {price}원 diff --git a/src/components/pages/ProductDetailPage/ProductDetail.tsx b/src/components/pages/ProductDetailPage/ProductDetail.tsx index 16dad50..424aac6 100644 --- a/src/components/pages/ProductDetailPage/ProductDetail.tsx +++ b/src/components/pages/ProductDetailPage/ProductDetail.tsx @@ -24,7 +24,7 @@ const ProductDetail: React.FC = () => { const { quantity, setQuantity } = useQuantity(); const [remainingTime, setRemainingTime] = useState(''); const navigate = useNavigate(); - const isOutOfStock = product ? product.now >= product.currentStock : false; + const isOutOfStock = product ? product.currentStock <= 0 : false; const isDeadlinePassed = remainingTime === '마감되었습니다.'; const isButtonDisabled = isOutOfStock || isDeadlinePassed; useEffect(() => { diff --git a/src/components/pages/ProductDetailPage/api/CommentApi.ts b/src/components/pages/ProductDetailPage/api/CommentApi.ts index 4b1eebe..6f5f53f 100644 --- a/src/components/pages/ProductDetailPage/api/CommentApi.ts +++ b/src/components/pages/ProductDetailPage/api/CommentApi.ts @@ -6,18 +6,15 @@ export interface Review { export const addComment = async (productId: number, payload: Review) => { const URL = `/api/review/${productId}`; - const response = await axiosInstance.post(URL, payload); - return response; + await axiosInstance.post(URL, payload); }; export const editComment = async (reviewId: number, payload: Review) => { const URL = `/api/review/update/${reviewId}`; - const response = await axiosInstance.put(URL, payload); - return response; + await axiosInstance.put(URL, payload); }; export const deleteComment = async (reviewId: number) => { const URL = `/api/review/remove/${reviewId}`; - const response = await axiosInstance.put(URL); - return response; + await axiosInstance.put(URL); }; diff --git a/src/components/pages/ProductPage/ProductComponent.tsx b/src/components/pages/ProductPage/ProductComponent.tsx index 956292a..85ba5b6 100644 --- a/src/components/pages/ProductPage/ProductComponent.tsx +++ b/src/components/pages/ProductPage/ProductComponent.tsx @@ -27,7 +27,7 @@ const ProductComponent: React.FC = ({ const filteredProducts = selectedText === '마감 상품' ? products.filter( - (p) => p.available === false && new Date(p.deadline) < new Date() + (p) => p.available === false || new Date(p.deadline) < new Date() ) : products.filter( (p) => p.available === true && new Date(p.deadline) > new Date() diff --git a/src/components/pages/login/SignInPage.tsx b/src/components/pages/login/SignInPage.tsx index 92c8426..85aad60 100644 --- a/src/components/pages/login/SignInPage.tsx +++ b/src/components/pages/login/SignInPage.tsx @@ -48,6 +48,7 @@ const SignInPage = () => { password: pw, }); if (response.status === 200) { + localStorage.setItem('role', response.data.roles); login(); navigate('/'); } else { From 453fbb12aed2bd11711e848f62de1b562bb38b95 Mon Sep 17 00:00:00 2001 From: yunsung Date: Mon, 9 Dec 2024 17:49:12 +0900 Subject: [PATCH 03/12] =?UTF-8?q?style:=20css=EC=9D=BC=EB=B6=80=20?= =?UTF-8?q?=EC=88=98=EC=A0=95(#1)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pages/ProductDetailPage/ProductDetail.tsx | 4 ++-- .../pages/ProductDetailPage/api/CommentApi.ts | 15 +++++++++------ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/components/pages/ProductDetailPage/ProductDetail.tsx b/src/components/pages/ProductDetailPage/ProductDetail.tsx index 424aac6..d3060c0 100644 --- a/src/components/pages/ProductDetailPage/ProductDetail.tsx +++ b/src/components/pages/ProductDetailPage/ProductDetail.tsx @@ -24,7 +24,7 @@ const ProductDetail: React.FC = () => { const { quantity, setQuantity } = useQuantity(); const [remainingTime, setRemainingTime] = useState(''); const navigate = useNavigate(); - const isOutOfStock = product ? product.currentStock <= 0 : false; + const isOutOfStock = product ? product.currentStock < 0 : false; const isDeadlinePassed = remainingTime === '마감되었습니다.'; const isButtonDisabled = isOutOfStock || isDeadlinePassed; useEffect(() => { @@ -209,7 +209,7 @@ const Stars = styled.div` position: absolute; font-size: 20px; color: #ffaa00; - bottom: 80px; + bottom: 13%; right: 2%; @media (min-width: 768px) and (max-width: 1024px) { diff --git a/src/components/pages/ProductDetailPage/api/CommentApi.ts b/src/components/pages/ProductDetailPage/api/CommentApi.ts index 6f5f53f..20537e4 100644 --- a/src/components/pages/ProductDetailPage/api/CommentApi.ts +++ b/src/components/pages/ProductDetailPage/api/CommentApi.ts @@ -5,16 +5,19 @@ export interface Review { } export const addComment = async (productId: number, payload: Review) => { - const URL = `/api/review/${productId}`; - await axiosInstance.post(URL, payload); + const URL = `api/review/${productId}`; + const response = await axiosInstance.post(URL, payload); + return response; }; export const editComment = async (reviewId: number, payload: Review) => { - const URL = `/api/review/update/${reviewId}`; - await axiosInstance.put(URL, payload); + const URL = `api/review/update/${reviewId}`; + const response = await axiosInstance.put(URL, payload); + return response; }; export const deleteComment = async (reviewId: number) => { - const URL = `/api/review/remove/${reviewId}`; - await axiosInstance.put(URL); + const URL = `api/review/remove/${reviewId}`; + const response = await axiosInstance.put(URL); + return response; }; From 433dc4d5694ce4a92e13d0da0f57f9e98b08a38f Mon Sep 17 00:00:00 2001 From: yunsung Date: Mon, 9 Dec 2024 17:57:31 +0900 Subject: [PATCH 04/12] =?UTF-8?q?fix:=20admin=20page=20=EB=A7=81=ED=81=AC?= =?UTF-8?q?=EB=8F=99=EC=9E=91=20=EC=95=88=ED=95=98=EB=8F=84=EB=A1=9D=20?= =?UTF-8?q?=EC=88=98=EC=A0=95(#1)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/common/Header.tsx | 10 ++++++++-- src/components/pages/login/SignInPage.tsx | 1 - 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/components/common/Header.tsx b/src/components/common/Header.tsx index 5b538f1..ec8a395 100644 --- a/src/components/common/Header.tsx +++ b/src/components/common/Header.tsx @@ -54,8 +54,14 @@ const Header = () => { {isLoggedIn && ( { + if (isAdmin) { + e.preventDefault(); // Admin일 경우 링크 동작 차단 + } else { + toggleMobileMenu(); + } + }} > {isAdmin ? 'Admin Page' : 'My Page'} diff --git a/src/components/pages/login/SignInPage.tsx b/src/components/pages/login/SignInPage.tsx index 85aad60..92c8426 100644 --- a/src/components/pages/login/SignInPage.tsx +++ b/src/components/pages/login/SignInPage.tsx @@ -48,7 +48,6 @@ const SignInPage = () => { password: pw, }); if (response.status === 200) { - localStorage.setItem('role', response.data.roles); login(); navigate('/'); } else { From 20fca33cabf0a231cfd7aa7da707c4e61f04c9d7 Mon Sep 17 00:00:00 2001 From: yunsung Date: Mon, 9 Dec 2024 18:04:22 +0900 Subject: [PATCH 05/12] =?UTF-8?q?fix:=20api=EA=B2=BD=EB=A1=9C=20=EC=88=98?= =?UTF-8?q?=EC=A0=95=20(#1)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/pages/HomePage/HomePage.tsx | 1 - src/components/pages/ProductDetailPage/api/CommentApi.ts | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/components/pages/HomePage/HomePage.tsx b/src/components/pages/HomePage/HomePage.tsx index b9f9dc7..b75a667 100644 --- a/src/components/pages/HomePage/HomePage.tsx +++ b/src/components/pages/HomePage/HomePage.tsx @@ -11,7 +11,6 @@ import { categories } from './model/categories'; const HomePage: React.FC = () => { const { data: products, isLoading, isError } = useProductsQuery(); - console.log(products); const availableProduct = products?.filter( (p) => p.available === true && new Date(p.deadline) > new Date() ); diff --git a/src/components/pages/ProductDetailPage/api/CommentApi.ts b/src/components/pages/ProductDetailPage/api/CommentApi.ts index 20537e4..4b1eebe 100644 --- a/src/components/pages/ProductDetailPage/api/CommentApi.ts +++ b/src/components/pages/ProductDetailPage/api/CommentApi.ts @@ -5,19 +5,19 @@ export interface Review { } export const addComment = async (productId: number, payload: Review) => { - const URL = `api/review/${productId}`; + const URL = `/api/review/${productId}`; const response = await axiosInstance.post(URL, payload); return response; }; export const editComment = async (reviewId: number, payload: Review) => { - const URL = `api/review/update/${reviewId}`; + const URL = `/api/review/update/${reviewId}`; const response = await axiosInstance.put(URL, payload); return response; }; export const deleteComment = async (reviewId: number) => { - const URL = `api/review/remove/${reviewId}`; + const URL = `/api/review/remove/${reviewId}`; const response = await axiosInstance.put(URL); return response; }; From 7f9a9c5f4bfcc14b1e127e72bf0631e5bf10181e Mon Sep 17 00:00:00 2001 From: jiyoung Date: Mon, 9 Dec 2024 22:25:20 +0900 Subject: [PATCH 06/12] =?UTF-8?q?chore:=20=EC=9D=B4=EB=AF=B8=EC=A7=80=20?= =?UTF-8?q?=ED=81=AC=EA=B8=B0=20=EB=B3=80=EA=B2=BD=20(#7)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/pages/login/FindPasswordPage.tsx | 2 +- src/components/pages/login/LoginCompletePage.tsx | 2 +- src/components/pages/login/ResetPasswordPage.tsx | 2 +- src/components/pages/login/SetNicknamePage.tsx | 2 +- src/components/pages/login/SetProfilePage.tsx | 2 +- src/components/pages/login/SignInPage.tsx | 2 +- src/components/pages/login/SignUpPage.tsx | 2 +- src/components/pages/login/TermsPage.tsx | 2 +- .../pages/myPage/OrderListComponents/OrderHistory.tsx | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/components/pages/login/FindPasswordPage.tsx b/src/components/pages/login/FindPasswordPage.tsx index db21f40..9706098 100644 --- a/src/components/pages/login/FindPasswordPage.tsx +++ b/src/components/pages/login/FindPasswordPage.tsx @@ -18,7 +18,7 @@ const FindPasswordPage = () => { style={{ width: '100%', height: '100%', - objectFit: 'contain', + objectFit: 'cover', }} /> diff --git a/src/components/pages/login/LoginCompletePage.tsx b/src/components/pages/login/LoginCompletePage.tsx index cd784ba..e3a7960 100644 --- a/src/components/pages/login/LoginCompletePage.tsx +++ b/src/components/pages/login/LoginCompletePage.tsx @@ -14,7 +14,7 @@ const LoginCompletePage = () => { style={{ width: '100%', height: '100%', - objectFit: 'contain', + objectFit: 'cover', }} /> diff --git a/src/components/pages/login/ResetPasswordPage.tsx b/src/components/pages/login/ResetPasswordPage.tsx index b6b9ec5..8a0b99f 100644 --- a/src/components/pages/login/ResetPasswordPage.tsx +++ b/src/components/pages/login/ResetPasswordPage.tsx @@ -31,7 +31,7 @@ const ResetPasswordPage = () => { style={{ width: '100%', height: '100%', - objectFit: 'contain', + objectFit: 'cover', }} /> diff --git a/src/components/pages/login/SetNicknamePage.tsx b/src/components/pages/login/SetNicknamePage.tsx index 69cba2b..a865088 100644 --- a/src/components/pages/login/SetNicknamePage.tsx +++ b/src/components/pages/login/SetNicknamePage.tsx @@ -29,7 +29,7 @@ const SetNicknamePage = () => { style={{ width: '100%', height: '100%', - objectFit: 'contain', + objectFit: 'cover', }} /> diff --git a/src/components/pages/login/SetProfilePage.tsx b/src/components/pages/login/SetProfilePage.tsx index 76bedb9..ffb9e68 100644 --- a/src/components/pages/login/SetProfilePage.tsx +++ b/src/components/pages/login/SetProfilePage.tsx @@ -29,7 +29,7 @@ const SetProfilePage = () => { style={{ width: '100%', height: '100%', - objectFit: 'contain', + objectFit: 'cover', }} /> diff --git a/src/components/pages/login/SignInPage.tsx b/src/components/pages/login/SignInPage.tsx index 92c8426..c8e0182 100644 --- a/src/components/pages/login/SignInPage.tsx +++ b/src/components/pages/login/SignInPage.tsx @@ -18,7 +18,7 @@ const SignInPage = () => { style={{ width: '100%', height: '100%', - objectFit: 'contain', + objectFit: 'cover', }} /> diff --git a/src/components/pages/login/SignUpPage.tsx b/src/components/pages/login/SignUpPage.tsx index 001b500..627d1ba 100644 --- a/src/components/pages/login/SignUpPage.tsx +++ b/src/components/pages/login/SignUpPage.tsx @@ -20,7 +20,7 @@ function SignUpPage() { style={{ width: '100%', height: '100%', - objectFit: 'contain', + objectFit: 'cover', }} /> diff --git a/src/components/pages/login/TermsPage.tsx b/src/components/pages/login/TermsPage.tsx index 11429d4..89a7d86 100644 --- a/src/components/pages/login/TermsPage.tsx +++ b/src/components/pages/login/TermsPage.tsx @@ -73,7 +73,7 @@ const TermsPage = () => { style={{ width: '100%', height: '100%', - objectFit: 'contain', + objectFit: 'cover', }} /> diff --git a/src/components/pages/myPage/OrderListComponents/OrderHistory.tsx b/src/components/pages/myPage/OrderListComponents/OrderHistory.tsx index 119ab66..fbee6db 100644 --- a/src/components/pages/myPage/OrderListComponents/OrderHistory.tsx +++ b/src/components/pages/myPage/OrderListComponents/OrderHistory.tsx @@ -36,7 +36,7 @@ const OrderHistory = () => { return '결제 완료'; case 'FAILED': return '결제 실패'; - case 'CANCELD': + case 'CANCELED': return '결제 취소'; case 'PARTIAL_CANCELED': return '부분 취소'; From a91ab4f9f431d1c9487deef7b176c5cfca4745d2 Mon Sep 17 00:00:00 2001 From: jiyoung Date: Mon, 9 Dec 2024 22:53:23 +0900 Subject: [PATCH 07/12] =?UTF-8?q?feat:=20=EB=8B=89=EB=84=A4=EC=9E=84=20api?= =?UTF-8?q?=20=EC=A0=81=EC=9A=A9=20=EC=99=84=EB=A3=8C=20(#13)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/mypageApi.ts | 8 +++++++ src/components/pages/myPage/SettingPage.tsx | 24 ++++++++++++++++++--- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/src/api/mypageApi.ts b/src/api/mypageApi.ts index 745a51c..bf766b8 100644 --- a/src/api/mypageApi.ts +++ b/src/api/mypageApi.ts @@ -136,3 +136,11 @@ export const putEditProfile = async (file: File) => { return response.data; }; + +export const putChangeNickname = async (nickname: string) => { + const response = await axiosInstance.put( + `/api/mypage/change_nickname?nickName=${nickname}` + ); + + return response.data; +}; diff --git a/src/components/pages/myPage/SettingPage.tsx b/src/components/pages/myPage/SettingPage.tsx index 5acc8c1..b95a061 100644 --- a/src/components/pages/myPage/SettingPage.tsx +++ b/src/components/pages/myPage/SettingPage.tsx @@ -7,7 +7,11 @@ import PasswordModal from './Modal/PasswordModal'; import LogoutModal from './Modal/LogoutModal'; import WithdrawModal from './Modal/WithdrawModal'; import { useDaumPostcodePopup } from 'react-daum-postcode'; -import { getUser, putEditProfile } from '../../../api/mypageApi'; +import { + getUser, + putChangeNickname, + putEditProfile, +} from '../../../api/mypageApi'; const SettingPage = () => { const [addressList, setAddressList] = useState(SettingPageData.addressList); @@ -21,6 +25,7 @@ const SettingPage = () => { const [phoneLast, setPhoneLast] = useState(''); const [isAddingNewAddress, setIsAddingNewAddress] = useState(false); const [profileImage, setProfileImage] = useState(null); + const [nickname, setNickname] = useState(''); const postcodeScriptUrl = 'https://t1.daumcdn.net/mapjsapi/bundle/postcode/prod/postcode.v2.js'; @@ -127,8 +132,21 @@ const SettingPage = () => { 닉네임 변경 - - 변경하기 + ) => { + setNickname(e.target.value); + }} + placeholder="최소 2자 이상 ~ 15자 이내, 띄어쓰기 및 특수문자 사용 불가" + /> + { + await putChangeNickname(nickname); + setNickname(''); + }} + > + 변경하기 + 배송지 주소 변경 From 56e57d35fcb7f4c47269b11d8932d09a2af92e59 Mon Sep 17 00:00:00 2001 From: jiyoung Date: Mon, 9 Dec 2024 22:58:10 +0900 Subject: [PATCH 08/12] =?UTF-8?q?feat:=20=EC=A3=BC=EC=86=8C=20=ED=92=80?= =?UTF-8?q?=EB=84=A4=EC=9E=84=EC=9C=BC=EB=A1=9C=20=EB=B3=80=EA=B2=BD=20(#1?= =?UTF-8?q?3)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/pages/login/SetLocationPage.tsx | 6 ++++-- src/components/pages/myPage/LocationPage.tsx | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/components/pages/login/SetLocationPage.tsx b/src/components/pages/login/SetLocationPage.tsx index 2f1df7f..a485a37 100644 --- a/src/components/pages/login/SetLocationPage.tsx +++ b/src/components/pages/login/SetLocationPage.tsx @@ -29,8 +29,10 @@ function SetLocationPage() { // eslint-disable-next-line @typescript-eslint/no-explicit-any (result: any, status: any) => { if (status === window.kakao.maps.services.Status.OK) { - const primaryRegion = result[0]?.region_3depth_name || ''; - setRegion(primaryRegion); + const fullRegion = `${result[0]?.region_1depth_name || ''} ${ + result[0]?.region_2depth_name || '' + } ${result[0]?.region_3depth_name || ''}`; + setRegion(fullRegion); setCalled(true); } else { console.error('주소를 가져오지 못했습니다.'); diff --git a/src/components/pages/myPage/LocationPage.tsx b/src/components/pages/myPage/LocationPage.tsx index 822ad11..07eb974 100644 --- a/src/components/pages/myPage/LocationPage.tsx +++ b/src/components/pages/myPage/LocationPage.tsx @@ -29,8 +29,10 @@ function LocationPage() { // eslint-disable-next-line @typescript-eslint/no-explicit-any (result: any, status: any) => { if (status === window.kakao.maps.services.Status.OK) { - const primaryRegion = result[0]?.region_3depth_name || ''; - setRegion(primaryRegion); + const fullRegion = `${result[0]?.region_1depth_name || ''} ${ + result[0]?.region_2depth_name || '' + } ${result[0]?.region_3depth_name || ''}`; + setRegion(fullRegion); setCalled(true); } else { console.error('주소를 가져오지 못했습니다.'); From d99d2789573d8b665c9dd91f618fdea65c481980 Mon Sep 17 00:00:00 2001 From: jiyoung Date: Mon, 9 Dec 2024 23:02:07 +0900 Subject: [PATCH 09/12] =?UTF-8?q?feat:=20onClickhandler=20=ED=83=80?= =?UTF-8?q?=EC=9E=85=20=EC=B6=94=EA=B0=80=20+=20=EC=9E=A5=EB=B0=94?= =?UTF-8?q?=EA=B5=AC=EB=8B=88=20=EB=A7=81=ED=81=AC=20=EC=97=B0=EA=B2=B0=20?= =?UTF-8?q?(#7)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/common/Header.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/components/common/Header.tsx b/src/components/common/Header.tsx index bbbfd3e..5f3e3ca 100644 --- a/src/components/common/Header.tsx +++ b/src/components/common/Header.tsx @@ -55,7 +55,7 @@ const Header = () => { {isLoggedIn && ( { + onClick={(e: React.MouseEvent) => { if (isAdmin) { e.preventDefault(); // Admin일 경우 링크 동작 차단 } else { @@ -92,7 +92,10 @@ const Header = () => { - + 장바구니 아이콘 From a4ff59c2c8610b646a02864fd3bcf28edb180ac5 Mon Sep 17 00:00:00 2001 From: jiyoung Date: Mon, 9 Dec 2024 23:16:36 +0900 Subject: [PATCH 10/12] =?UTF-8?q?feat:=20=EC=86=8C=EC=85=9C=EB=A1=9C?= =?UTF-8?q?=EA=B7=B8=EC=9D=B8=20api=20=EC=97=B0=EB=8F=99=20=EC=99=84?= =?UTF-8?q?=EB=A3=8C(#7)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/pages/login/SignInPage.tsx | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/components/pages/login/SignInPage.tsx b/src/components/pages/login/SignInPage.tsx index c8e0182..c26d690 100644 --- a/src/components/pages/login/SignInPage.tsx +++ b/src/components/pages/login/SignInPage.tsx @@ -1,14 +1,25 @@ -import React, { useState } from 'react'; -import { useNavigate } from 'react-router-dom'; +import React, { useEffect, useState } from 'react'; +import { useLocation, useNavigate } from 'react-router-dom'; import { styled } from 'styled-components'; import { postSignIn } from '../../../api/loginApi'; import { useAuth } from '../../../context/AuthContext'; const SignInPage = () => { const navigate = useNavigate(); + const location = useLocation(); const [email, setEmail] = useState(''); const [pw, setPw] = useState(''); const { login } = useAuth(); + + useEffect(() => { + const searchParams = new URLSearchParams(location.search); + const accessToken = searchParams.get('accessToken'); + if (accessToken) { + localStorage.setItem('token', accessToken); + navigate('/'); + } + }, [location, navigate]); + return ( @@ -18,7 +29,7 @@ const SignInPage = () => { style={{ width: '100%', height: '100%', - objectFit: 'cover', + objectFit: 'contain', }} /> From 4708019928a48c9ae6e0accb8582c39ce49bc6c8 Mon Sep 17 00:00:00 2001 From: jiyoung Date: Mon, 9 Dec 2024 23:34:42 +0900 Subject: [PATCH 11/12] =?UTF-8?q?feat:=20=ED=99=98=EB=B6=88=20api=20?= =?UTF-8?q?=EB=A1=9C=EC=A7=81=20=EC=A0=81=EC=9A=A9=20=EC=99=84=EB=A3=8C=20?= =?UTF-8?q?(#13)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/mypageApi.ts | 9 ++++++ .../OrderListComponents/OrderHistory.tsx | 28 ++++++++++------- .../OrderListComponents/RefundHistory.tsx | 31 ++++++++++++------- 3 files changed, 46 insertions(+), 22 deletions(-) diff --git a/src/api/mypageApi.ts b/src/api/mypageApi.ts index bf766b8..614e4c6 100644 --- a/src/api/mypageApi.ts +++ b/src/api/mypageApi.ts @@ -1,5 +1,14 @@ import axiosInstance from './axiosInstance'; +export type RefundType = { + productName: string; + quantity: number; + price: number; + url: string; + paymentStatus: string; + postId: number; +}; + export type MyPostType = { availableNumber: number; category: string; diff --git a/src/components/pages/myPage/OrderListComponents/OrderHistory.tsx b/src/components/pages/myPage/OrderListComponents/OrderHistory.tsx index fbee6db..0b55586 100644 --- a/src/components/pages/myPage/OrderListComponents/OrderHistory.tsx +++ b/src/components/pages/myPage/OrderListComponents/OrderHistory.tsx @@ -78,18 +78,24 @@ const OrderHistory = () => { > 상품 페이지 이동 - { - handleCancelClick(); - if (order.payment_key) { - setPk(order.payment_key); - } - }} - > - 주문 취소/환불 - {order.paymentStatus === 'DONE' && ( - + { + handleCancelClick(); + if (order.payment_key) { + setPk(order.payment_key); + } + }} + > + 주문 취소/환불 + + )} + {order.paymentStatus === 'DONE' && ( + { + navigate(`/products/${order.postId}`); + }} + > 리뷰 작성하기 diff --git a/src/components/pages/myPage/OrderListComponents/RefundHistory.tsx b/src/components/pages/myPage/OrderListComponents/RefundHistory.tsx index 1f6de75..3273868 100644 --- a/src/components/pages/myPage/OrderListComponents/RefundHistory.tsx +++ b/src/components/pages/myPage/OrderListComponents/RefundHistory.tsx @@ -1,37 +1,46 @@ -import React, { useEffect } from 'react'; +import React, { useEffect, useState } from 'react'; +import { useNavigate } from 'react-router-dom'; import styled from 'styled-components'; -import { getRefundList } from '../../../../api/mypageApi'; -import { refundHistoryData } from '../mockData'; +import { getRefundList, RefundType } from '../../../../api/mypageApi'; const RefundHistory = () => { + const [refundList, setRefundList] = useState([]); + const navigate = useNavigate(); + useEffect(() => { const fetchOrderList = async () => { const response = await getRefundList(); - console.log(response); + setRefundList(response); }; fetchOrderList(); }, []); return ( - {refundHistoryData.map((refund) => ( - + {refundList.map((refund, idx) => ( + - {refund.name} + {refund.productName} Quantity: {refund.quantity} - - {refund.status} + + {refund.paymentStatus === 'CANCELED' ? '취소' : '대기 중'} - {refund.price} + {refund.price}원 - 상품 페이지 이동 + { + navigate(`/products/${refund.postId}`); + }} + > + 상품 페이지 이동 + ))} From fc330e8aaa60c3dbe6a90ddcee96498801fcdd84 Mon Sep 17 00:00:00 2001 From: jiyoung Date: Tue, 10 Dec 2024 00:48:59 +0900 Subject: [PATCH 12/12] =?UTF-8?q?feat:=20api=20=EC=8B=A4=ED=8C=A8=EC=8B=9C?= =?UTF-8?q?=20=EC=95=8C=EB=9E=8C=20=EC=B6=94=EA=B0=80=20(#7)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pages/login/SetNicknamePage.tsx | 26 ++++++++--- src/components/pages/login/SignUpPage.tsx | 44 ++++++++++++------- 2 files changed, 48 insertions(+), 22 deletions(-) diff --git a/src/components/pages/login/SetNicknamePage.tsx b/src/components/pages/login/SetNicknamePage.tsx index a865088..25f384f 100644 --- a/src/components/pages/login/SetNicknamePage.tsx +++ b/src/components/pages/login/SetNicknamePage.tsx @@ -1,3 +1,4 @@ +import axios from 'axios'; import React, { useState } from 'react'; import { useNavigate } from 'react-router-dom'; import { styled } from 'styled-components'; @@ -53,14 +54,27 @@ const SetNicknamePage = () => { { if (isValidLength && isValidFormat) { - const response = await postSignUpNickname({ nickname: nickname }); + try { + const response = await postSignUpNickname({ + nickname: nickname, + }); - if (response.message === '닉네임 중복 확인 완료') { - localStorage.setItem('nickname', nickname); + if (response.message === '닉네임 중복 확인 완료') { + localStorage.setItem('nickname', nickname); - navigate('/setprofile'); - } else { - alert('닉네임이 중복입니다.'); + navigate('/setprofile'); + } else { + alert('닉네임이 중복입니다.'); + } + } catch (err) { + if ( + axios.isAxiosError(err) && + err.response && + err.response.data && + err.response.data.error + ) { + alert(err.response.data.error); + } } } else { alert('닉네임 조건을 만족시켜 주세요.'); diff --git a/src/components/pages/login/SignUpPage.tsx b/src/components/pages/login/SignUpPage.tsx index 627d1ba..81d8a5e 100644 --- a/src/components/pages/login/SignUpPage.tsx +++ b/src/components/pages/login/SignUpPage.tsx @@ -1,3 +1,4 @@ +import axios from 'axios'; import React, { useState } from 'react'; import { useNavigate } from 'react-router-dom'; import { styled } from 'styled-components'; @@ -71,24 +72,35 @@ function SignUpPage() { if (pw !== cpw) { alert('비밀번호가 일치하지 않습니다.'); } else { - const response = await postSignUp({ - email: email, - password: pw, - password_confirm: cpw, - name: name, - phone: phone, - }); + try { + const response = await postSignUp({ + email: email, + password: pw, + password_confirm: cpw, + name: name, + phone: phone, + }); - if (response.message === '이메일, 전화번호 중복 확인 완료') { - localStorage.setItem('email', email); - localStorage.setItem('password', pw); - localStorage.setItem('password_confirm', cpw); - localStorage.setItem('name', name); - localStorage.setItem('phone', phone); + if (response.message === '이메일, 전화번호 중복 확인 완료') { + localStorage.setItem('email', email); + localStorage.setItem('password', pw); + localStorage.setItem('password_confirm', cpw); + localStorage.setItem('name', name); + localStorage.setItem('phone', phone); - navigate('/termsandservice'); - } else { - alert('이메일 또는 전화번호가 중복 되었습니다.'); + navigate('/termsandservice'); + } else { + alert('이메일 또는 전화번호가 중복 되었습니다.'); + } + } catch (err) { + if ( + axios.isAxiosError(err) && + err.response && + err.response.data && + err.response.data.error + ) { + alert(err.response.data.error); + } } } }}