diff --git a/src/components/GiftAdd/GiftAddPageLayout/GiftAddPageLayout.tsx b/src/components/GiftAdd/GiftAddPageLayout/GiftAddPageLayout.tsx index 50a5b2d3..6b69d956 100644 --- a/src/components/GiftAdd/GiftAddPageLayout/GiftAddPageLayout.tsx +++ b/src/components/GiftAdd/GiftAddPageLayout/GiftAddPageLayout.tsx @@ -66,6 +66,7 @@ const GiftAddPageLayout = ({ setIsModalOpen={setIsModalOpen} onClickDelete={handleClickConfirmDeleteBtn} clickedItem={clickedItem} + okButtonText='네, 삭제할게요' > 정말 상품을 삭제하시겠어요? diff --git a/src/components/common/Button/Logout/BtnLogout.tsx b/src/components/common/Button/Logout/BtnLogout.tsx index 853b929e..d90b978e 100644 --- a/src/components/common/Button/Logout/BtnLogout.tsx +++ b/src/components/common/Button/Logout/BtnLogout.tsx @@ -1,26 +1,16 @@ import { ButtonHTMLAttributes } from 'react'; import * as S from './BtnLogout.style'; -import { logOutInstance } from '../../../../apis/client'; -import { useNavigate } from 'react-router'; type BtnLogoutProps = ButtonHTMLAttributes & { disabled?: boolean; children: React.ReactNode; customStyle?: React.CSSProperties; + handleButtonClick: VoidFunction; }; -const BtnLogout = ({ disabled, children, customStyle }: BtnLogoutProps) => { - const navigate = useNavigate(); - const fetchAuth = async () => logOutInstance.post(`/oauth/logout`); - const handleClick = () => { - fetchAuth().then((response: any) => { - console.log(response); - }); - localStorage.clear(); - navigate('/'); - }; +const BtnLogout = ({ disabled, children, customStyle, handleButtonClick }: BtnLogoutProps) => { return ( - + {children} ); diff --git a/src/components/common/Modal/DeleteModal.tsx b/src/components/common/Modal/DeleteModal.tsx index 5f73dc50..8555547e 100644 --- a/src/components/common/Modal/DeleteModal.tsx +++ b/src/components/common/Modal/DeleteModal.tsx @@ -9,6 +9,7 @@ interface DeleteModalProps { onClickDelete: (giftId?: number) => void; setIsModalOpen: React.Dispatch>; clickedItem?: number | undefined; + okButtonText: string; } const DeleteModal = ({ @@ -16,6 +17,7 @@ const DeleteModal = ({ onClickDelete, setIsModalOpen, clickedItem, + okButtonText, }: DeleteModalProps) => { const onClickCancel = () => { setIsModalOpen(false); @@ -39,9 +41,9 @@ const DeleteModal = ({ backgroundColor: 'white', color: 'black', }} - onClick={() => (clickedItem ? onClickDelete(clickedItem) : onClickCancel())} + onClick={() => (clickedItem ? onClickDelete(clickedItem) : onClickDelete())} > - 네, 삭제할게요 + {okButtonText} 아니오 diff --git a/src/pages/MyPage/MyPage.tsx b/src/pages/MyPage/MyPage.tsx index 505c1ed5..bf763178 100644 --- a/src/pages/MyPage/MyPage.tsx +++ b/src/pages/MyPage/MyPage.tsx @@ -7,6 +7,9 @@ import useGetMyPage from '../../hooks/queries/member/useGetMypage'; import { MyPageType } from '../../types/member'; import * as S from './MyPage.style'; import { useNavigate } from 'react-router'; +import { useState } from 'react'; +import DeleteModal from '../../components/common/Modal/DeleteModal'; +import { logOutInstance } from '../../apis/client'; interface MyPage { memberData: MyPageType; } @@ -15,6 +18,8 @@ const MAX_USERNAME_LENGTH = 5; const MyPage = () => { const navigate = useNavigate(); + const [isModalOpen, setIsModalOpen] = useState(false); + const fetchAuth = async () => logOutInstance.post(`/oauth/logout`); const memberData = useGetMyPage(); @@ -35,6 +40,17 @@ const MyPage = () => { ); }; + const isLogout = () => { + fetchAuth().then((response: any) => { + console.log(response); + }); + localStorage.clear(); + navigate('/'); + }; + const handleButtonClick = () => { + setIsModalOpen(true); + }; + const renderUserName = () => { const userName = memberData?.data?.memberInfo.nickname; const translatedUserName = @@ -49,22 +65,33 @@ const MyPage = () => { }; return ( - - - - - - - {renderUserName()} - - 로그아웃 - - - 새로운 선물 준비하기 - - - {renderGiftRoom()} - + <> + {isModalOpen && ( + + 정말 로그아웃하시겠어요? + + )} + + + + + + + {renderUserName()} + + 로그아웃 + + + 새로운 선물 준비하기 + + + {renderGiftRoom()} + + ); };