Skip to content

Commit 8ac1dd4

Browse files
committed
fix: 에러 수정
1 parent 3e10a43 commit 8ac1dd4

File tree

6 files changed

+22
-15
lines changed

6 files changed

+22
-15
lines changed

src/components/organisms/FridgeInfoBox.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const FridgeInfoBox: React.FC<{
1313
}> = ({ currentFridgeInfo, fridgeName, userName = '', toggleIsOpenFridgeListModal, isOkIngredientAdd }) => {
1414
const router = useRouter();
1515

16+
console.log(currentFridgeInfo);
1617
return (
1718
<div className="flex justify-between items-end mb-[28px]">
1819
<div className="flex flex-col gap-[12px]">

src/hooks/queries/login/usePostUser.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { useBaseMutation } from '../useBaseMutation';
33
import { useRouter } from 'next/router';
44

55
interface PostUserBodyType {
6-
nickName: string;
6+
nickname: string;
77
kakaoId: number;
88
kakaoEmail: string;
99
googleEmail: string | null;
@@ -18,8 +18,6 @@ const usePostUser = () => {
1818
data: {
1919
accessToken: string;
2020
refreshToken: string;
21-
email: string;
22-
nickName: string;
2321
};
2422
}) => {
2523
localStorage.setItem('accessToken', data.accessToken);

src/hooks/queries/useBaseMutation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export const useBaseMutation = <T>(
2222
mutationFn: async (body: T) => {
2323
const response = await fetchData<T>(url, body, method);
2424

25-
if (onSuccess) onSuccess(response.data);
25+
if (onSuccess) onSuccess(response);
2626
},
2727
});
2828
};

src/hooks/queries/useBaseQuery.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export const fetchData = async <T>(url: string, isNotCatch: boolean) => {
1010
if (error.response && error.response.status === 404) {
1111
return await Promise.resolve({ data: null });
1212
} else {
13-
throw error;
13+
console.error(error);
1414
}
1515
}
1616
}

src/pages/fridge/index.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@ import withLogin from '@/components/templates/withLogin';
88
import useGetMyFridgeList from '@/hooks/queries/fridge/useGetFridgeList';
99
import type { CurrentFridgeInfoType } from '@/types/fridge';
1010
import { useRouter } from 'next/router';
11+
import { EmptyBox } from '@/components/molecules';
1112

1213
const FridgePage: NextPage = () => {
1314
const router = useRouter();
1415
const [currentFridgeInfo, setCurrentFridgeInfo] = useState<CurrentFridgeInfoType>({
1516
username: null,
1617
fridgeId: 0,
17-
fridgeName: '',
18+
fridgeName: '냉장고정보없음',
1819
});
1920
const {
2021
isOpen: isOpenFridgeListModal,
@@ -28,7 +29,8 @@ const FridgePage: NextPage = () => {
2829
const { fridgeid, name } = router.query;
2930

3031
useEffect(() => {
31-
if (!fridgeList || fridgeList.length < 0) {
32+
if (!fridgeList || fridgeList.length === 0 || !currentFridgeInfo) {
33+
onOpenFridgeListModal();
3234
return;
3335
}
3436
if (fridgeid) {
@@ -76,7 +78,13 @@ const FridgePage: NextPage = () => {
7678
toggleIsOpenFridgeListModal={onOpenFridgeListModal}
7779
isOkIngredientAdd={true}
7880
/>
79-
<FridgeBoard currentFridgeInfo={currentFridgeInfo} />
81+
{!fridgeList || fridgeList.length === 0 ? (
82+
<div>
83+
<EmptyBox text={`냉장칸에 추가된 식자재가 없어요!`} />
84+
</div>
85+
) : (
86+
<FridgeBoard currentFridgeInfo={currentFridgeInfo} />
87+
)}
8088
</section>
8189
</div>
8290
</>

src/pages/mypage/profile/index.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ const ProfilePage: NextPage = () => {
3535
const router = useRouter();
3636
const { kakaoId, kakaoEmail, googleEmail } = router.query;
3737

38-
const MyInfo = useGetMe();
38+
const MyInfo = kakaoId ? null : useGetMe();
3939

40-
const [selectedProfile, setSelectedProfile] = useState<ProfileEnum>('BLUE');
40+
const [selectedProfile, setSelectedProfile] = useState<ProfileEnum>('GREEN');
4141
const [nickname, setNickname] = useState(MyInfo?.nickname ?? '');
4242
const [isNicknameAvailable, setIsNicknameAvailable] = useState<null | boolean>(null);
4343
const [isNicknameChecked, setIsNicknameChecked] = useState<null | boolean>(null);
@@ -84,10 +84,10 @@ const ProfilePage: NextPage = () => {
8484

8585
if ((kakaoEmail && kakaoId) ?? googleEmail) {
8686
postUser.mutate({
87-
nickName: nickname,
88-
kakaoId: Number(kakaoId ?? MyInfo.kakaoId),
89-
kakaoEmail: (kakaoEmail as string) ?? MyInfo.kakaoEmail,
90-
googleEmail: (googleEmail as string) ?? MyInfo.googleEmail,
87+
nickname,
88+
kakaoId: Number(kakaoId ?? MyInfo?.kakaoId),
89+
kakaoEmail: (kakaoEmail as string) ?? MyInfo?.kakaoEmail,
90+
googleEmail: (googleEmail as string) ?? MyInfo?.googleEmail ?? null,
9191
profileImage: selectedProfile,
9292
});
9393
} else {
@@ -141,7 +141,7 @@ const ProfilePage: NextPage = () => {
141141
</div>
142142
<button
143143
type="submit"
144-
className={`p-18 gap-12 rounded-12 heading4-semibold ${(MyInfo?.nickname !== nickname && MyInfo.profileImage === selectedProfile) || (MyInfo?.nickname === nickname && MyInfo.profileImage !== selectedProfile) || (isNicknameAvailable && selectedProfile) ? 'bg-primary2' : 'bg-gray3'} mt-[205px] text-white`}
144+
className={`p-18 gap-12 rounded-12 heading4-semibold ${(MyInfo?.nickname !== nickname && MyInfo?.profileImage === selectedProfile) || (MyInfo?.nickname === nickname && MyInfo.profileImage !== selectedProfile) || (isNicknameAvailable && selectedProfile) ? 'bg-primary2' : 'bg-gray3'} mt-[205px] text-white`}
145145
>
146146
편집완료
147147
</button>

0 commit comments

Comments
 (0)