Skip to content

Commit a3ef49b

Browse files
committed
[chore]포매팅
1 parent d025835 commit a3ef49b

File tree

8 files changed

+42
-51
lines changed

8 files changed

+42
-51
lines changed

src/app/layout.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import KaKaoScript from './api/kakao/KaKaoScript';
88
import IdleHandler from '@/domains/login/components/IdleHandler';
99
import Provider from '@/shared/api/Provider';
1010

11-
1211
export const metadata: Metadata = {
1312
title: { default: 'SSOUL', template: 'SSOUL | %s' },
1413
metadataBase: new URL('http://www.ssoul.life'),

src/app/mypage/layout.tsx

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,13 @@ import { Suspense } from 'react';
55

66
function Layout({ children }: { children: React.ReactNode }) {
77
return (
8-
9-
<Suspense fallback={<SkeletonLayout />}>
10-
<div className="max-w-1024 page-layout py-12">
11-
<MyProfile />
12-
<MyNav />
13-
<div className="mt-5">{children}</div>
14-
</div>
15-
</Suspense>
8+
<Suspense fallback={<SkeletonLayout />}>
9+
<div className="max-w-1024 page-layout py-12">
10+
<MyProfile />
11+
<MyNav />
12+
<div className="mt-5">{children}</div>
13+
</div>
14+
</Suspense>
1615
);
1716
}
1817
export default Layout;

src/domains/mypage/api/fetchProfile.ts

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,16 @@ import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
44
import { Profile } from '../types/type';
55

66
function useFetchProfile() {
7-
8-
const queryClient = useQueryClient()
7+
const queryClient = useQueryClient();
98

109
const fetchProfile = async () => {
1110
const res = await fetch(`${getApi}/me/profile`, {
1211
method: 'GET',
1312
credentials: 'include',
1413
});
1514
const json = await res.json();
16-
17-
return json.data
15+
16+
return json.data;
1817
};
1918

2019
const patchNickName = useMutation({
@@ -23,25 +22,25 @@ function useFetchProfile() {
2322
method: 'PATCH',
2423
credentials: 'include',
2524
headers: { 'Content-Type': 'application/json' },
26-
body: JSON.stringify({nickname})
27-
})
28-
if (!res.ok) throw new Error('닉네임 수정 실패')
29-
const json = await res.json()
30-
return json.data
25+
body: JSON.stringify({ nickname }),
26+
});
27+
if (!res.ok) throw new Error('닉네임 수정 실패');
28+
const json = await res.json();
29+
return json.data;
3130
},
3231

3332
onMutate: async (nickname) => {
3433
// 같은 키로 요청중인 fetch 중단
35-
await queryClient.cancelQueries({ queryKey: ['myProfile'] })
34+
await queryClient.cancelQueries({ queryKey: ['myProfile'] });
3635
// 캐시에 저장된 데이터를 즉시 가져오는 역할 실패시 prev로 롤백
37-
const prev = queryClient.getQueryData(['myProfile'])
36+
const prev = queryClient.getQueryData(['myProfile']);
3837
// 캐시 내용을 수정
39-
queryClient.setQueryData(['myProfile'], (old:Profile) => ({ ...old, nickname }))
40-
return {prev}
41-
}
42-
})
43-
const profile = useQuery({queryKey:['myProfile'], queryFn:fetchProfile})
38+
queryClient.setQueryData(['myProfile'], (old: Profile) => ({ ...old, nickname }));
39+
return { prev };
40+
},
41+
});
42+
const profile = useQuery({ queryKey: ['myProfile'], queryFn: fetchProfile });
4443

45-
return{fetchProfile , profile, patchNickName}
44+
return { fetchProfile, profile, patchNickName };
4645
}
4746
export default useFetchProfile;

src/domains/mypage/components/EditNickName.tsx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,26 +28,26 @@ function EditNickName({
2828
}: Props) {
2929
const [defaultNickname, setDefaultNickname] = useState(nickname);
3030
const { toastSuccess, toastError } = useToast();
31-
const { patchNickName } = useFetchProfile()
32-
31+
const { patchNickName } = useFetchProfile();
32+
3333
useEffect(() => {
3434
setEditNickName(nickname);
3535
setDefaultNickname(nickname);
3636
}, [nickname, setEditNickName]);
3737

3838
const handlesave = async () => {
39-
if (editNickName.length <= 1 || editNickName.length >= 8) {
40-
toastError('닉네임은 2글자 이상 8글자 이내로 입력해야합니다');
41-
return;
42-
}
39+
if (editNickName.length <= 1 || editNickName.length >= 8) {
40+
toastError('닉네임은 2글자 이상 8글자 이내로 입력해야합니다');
41+
return;
42+
}
4343

44-
await setNickName(editNickName);
45-
// CRUD중 CUD를 관리하는 메서드
46-
await patchNickName.mutateAsync(editNickName)
44+
await setNickName(editNickName);
45+
// CRUD중 CUD를 관리하는 메서드
46+
await patchNickName.mutateAsync(editNickName);
4747

48-
await setIsOpen(false);
49-
toastSuccess('닉네임이 저장되었습니다.');
50-
}
48+
await setIsOpen(false);
49+
toastSuccess('닉네임이 저장되었습니다.');
50+
};
5151

5252
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
5353
setEditNickName(e.target.value);

src/domains/mypage/main/MyProfile.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { useQuery } from '@tanstack/react-query';
88

99
function MyProfile() {
1010
const { fetchProfile } = useFetchProfile();
11-
const {data} = useQuery({ queryKey: ['myProfile'], queryFn: fetchProfile });
11+
const { data } = useQuery({ queryKey: ['myProfile'], queryFn: fetchProfile });
1212

1313
if (!data) return;
1414
const {
@@ -19,7 +19,7 @@ function MyProfile() {
1919
myCommentCount,
2020
myKeepCount,
2121
abvDegree,
22-
} = data
22+
} = data;
2323

2424
return (
2525
<section className="h-auto p-6 bg-white rounded-2xl">

src/domains/mypage/main/MySetting.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@ import { useEffect, useState } from 'react';
77
import useFetchProfile from '../api/fetchProfile';
88
import { useQuery } from '@tanstack/react-query';
99

10-
1110
function MySetting() {
1211
const { fetchProfile } = useFetchProfile();
13-
const { data:profile } = useQuery({ queryKey: ['myProfile'], queryFn: fetchProfile });
12+
const { data: profile } = useQuery({ queryKey: ['myProfile'], queryFn: fetchProfile });
1413
const [isOpen, setIsOpen] = useState(false);
1514
const [isQuit, setIsQuit] = useState(false);
1615
const [nickname, setNickName] = useState(profile?.nickname);

src/domains/mypage/types/type.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ export interface Profile {
44
abvLevel: number;
55
email: string | null;
66
id: number;
7-
myCommentCount: number
8-
myKeepCount: number
7+
myCommentCount: number;
8+
myKeepCount: number;
99
myLikedPostCount: number;
1010
myPostCount: number;
1111
nickname: string;
12-
}
12+
}

src/shared/api/Provider.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
1-
21
'use client';
32
import { useState } from 'react';
43
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
54

65
export default function Providers({ children }: { children: React.ReactNode }) {
76
const [client] = useState(() => new QueryClient());
8-
return (
9-
<QueryClientProvider client={client}>
10-
{children}
11-
</QueryClientProvider>
12-
);
7+
return <QueryClientProvider client={client}>{children}</QueryClientProvider>;
138
}

0 commit comments

Comments
 (0)