Skip to content

Commit

Permalink
Merge pull request #205 from kde98892/bug/mypage
Browse files Browse the repository at this point in the history
🐛Bug: 자잘한 오류 해결
  • Loading branch information
kde98892 authored Mar 22, 2024
2 parents 1c9ca7b + b9a938f commit f7b8a44
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 11 deletions.
17 changes: 13 additions & 4 deletions app/(route)/mypage/_components/SettingList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,14 @@ const EditUserInfo = {

const ButtonStyle = "w-full cursor-pointer border-b border-gray-50 px-24 py-20 pc:px-20 pc:py-16 hover:pc:bg-main-pink-50";

const SettingList = ({ isOpener }: { isOpener: boolean }) => {
interface Props {
closeBottomSheet?: () => void;
isOpener: boolean;
openModal: (modal: string) => void;
}

const SettingList = ({ isOpener, closeBottomSheet, openModal }: Props) => {
const router = useRouter();
const { modal, openModal, closeModal } = useModal();

const handleLogout = async () => {
const res = await instance.delete("/auth");
Expand All @@ -32,6 +37,11 @@ const SettingList = ({ isOpener }: { isOpener: boolean }) => {
}
};

const handleWithdraw = () => {
openModal("withdraw");
closeBottomSheet?.();
};

return (
<>
<ul className="flex h-fit w-full flex-col items-start text-16 text-gray-900 pc:text-14 pc:font-500" onClick={(event) => event.stopPropagation()}>
Expand All @@ -46,12 +56,11 @@ const SettingList = ({ isOpener }: { isOpener: boolean }) => {
<li onClick={handleLogout} className={ButtonStyle}>
{EditUserInfo.logOut}
</li>
<li onClick={() => openModal("withdraw")} className={`rounded-b-lg ${ButtonStyle}`}>
<li onClick={handleWithdraw} className={`rounded-b-lg ${ButtonStyle}`}>
{EditUserInfo.withdrawal}
</li>
<li className={`pc:hidden ${ButtonStyle}`} />
</ul>
{modal === "withdraw" && <WithdrawModal closeModal={closeModal} />}
</>
);
};
Expand Down
8 changes: 6 additions & 2 deletions app/(route)/mypage/_components/UserProfile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@

import dynamic from "next/dynamic";
import Image from "next/image";
import WithdrawModal from "@/components/modal/WithdrawModal";
import { useAuth } from "@/hooks/useAuth";
import useBottomSheet from "@/hooks/useBottomSheet";
import { useModal } from "@/hooks/useModal";
import SettingList from "./SettingList";

const MyPageBottomSheet = dynamic(() => import("@/components/bottom-sheet/MyPageBottomSheet"), { ssr: false });

const UserProfile = () => {
const { bottomSheet, openBottomSheet, closeBottomSheet, refs } = useBottomSheet();
const { modal, openModal, closeModal } = useModal();
const { session } = useAuth();

return (
Expand All @@ -31,12 +34,13 @@ const UserProfile = () => {
</div>
</div>
<section className="mx-20 hidden w-full rounded-lg border border-gray-50 pc:block">
<SettingList isOpener={session?.user.signupMethod === "opener"} />
<SettingList isOpener={session?.user.signupMethod === "opener"} openModal={openModal} />
</section>
<button onClick={() => openBottomSheet("mypage")} className="pc:hidden">
<Image src="/icon/kebab-black.svg" width={24} height={25} alt="계정 정보 수정하기" />
</button>
{bottomSheet === "mypage" && <MyPageBottomSheet closeBottomSheet={closeBottomSheet} refs={refs} isOpener={session?.user.signupMethod === "opener"} />}
{bottomSheet === "mypage" && <MyPageBottomSheet closeBottomSheet={closeBottomSheet} refs={refs} isOpener={session?.user.signupMethod === "opener"} openModal={openModal} />}
{modal === "withdraw" && <WithdrawModal closeModal={closeModal} />}
</div>
);
};
Expand Down
1 change: 0 additions & 1 deletion app/(route)/signup/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ const SignUp = () => {
<div className="flex h-[calc(100%-13.8rem)] grow flex-col px-20 tablet:px-40 pc:px-0">
<GenericFormProvider<SignUpFormType> formOptions={{ mode: "onBlur", defaultValues: { ...DEFAULT_VALUES, email: emailFromSignin ?? "" } }}>
<ProfileSetup steps={STEPS} handleNextClick={handleNextClick} handlePrevClick={handlePrevClick} Funnel={Funnel} Step={Step} />
<ProfileSetup steps={STEPS} handleNextClick={handleNextClick} handlePrevClick={handlePrevClick} Funnel={Funnel} Step={Step} />
</GenericFormProvider>
</div>
</DottedLayout>
Expand Down
7 changes: 5 additions & 2 deletions app/_api/api.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { usePathname } from "next/navigation";
import { getSession } from "@/store/session/cookies";
import { Req_Delete_Type } from "@/types/deleteBodyType";
import { Req_Post_Type } from "@/types/postBodyType";
Expand Down Expand Up @@ -145,8 +146,10 @@ export class Api {
const refetchResult = await this.refetch(newEndPoint, config);
return refetchResult;
}
const result = await res.json();
this.makeError(result);
if (endPoint !== "/auth") {
const result = await res.json();
this.makeError(result);
}
return res;
}
}
Expand Down
5 changes: 3 additions & 2 deletions app/_components/bottom-sheet/MyPageBottomSheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ interface Props {
content: (node: HTMLElement | null) => void;
};
isOpener: boolean;
openModal: (modal: string) => void;
}

const MyPageBottomSheet = ({ closeBottomSheet, refs, isOpener }: Props) => {
const MyPageBottomSheet = ({ closeBottomSheet, refs, isOpener, openModal }: Props) => {
return (
<>
<BottomSheet.Frame closeBottomSheet={closeBottomSheet} ref={refs.sheet}>
<SettingList isOpener={isOpener} />
<SettingList isOpener={isOpener} closeBottomSheet={closeBottomSheet} openModal={openModal} />
</BottomSheet.Frame>
</>
);
Expand Down

0 comments on commit f7b8a44

Please sign in to comment.