Skip to content

Commit 0ebb139

Browse files
committed
Merge branch 'develop' into Feat/159/CrewReview
2 parents 6513988 + 6dea7f6 commit 0ebb139

File tree

5 files changed

+28
-28
lines changed

5 files changed

+28
-28
lines changed

.storybook/preview.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,9 @@ export const decorators = [
2424
(renderStory: any) => <ColorSchemeWrapper>{renderStory()}</ColorSchemeWrapper>,
2525
(renderStory: any) => <MantineProvider>{renderStory()}</MantineProvider>,
2626
];
27+
28+
export const parameters = {
29+
nextjs: {
30+
appDirectory: true,
31+
},
32+
};

src/_queries/auth/reissue-queries.ts

Lines changed: 0 additions & 15 deletions
This file was deleted.

src/_queries/auth/user-queries.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { useQuery } from '@tanstack/react-query';
22
import { getUser } from '@/src/_apis/auth/user-apis';
3-
import { authStore } from '@/src/store/use-auth-store';
3+
import { useAuthStore } from '@/src/store/use-auth-store';
44

55
export function useUser() {
6-
const { token } = authStore.getState();
6+
const token = useAuthStore((state) => state.token);
77
return useQuery({
88
queryKey: ['user'],
99
queryFn: getUser,

src/components/client-provider.tsx

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
'use client';
22

33
import { ReactNode, useState } from 'react';
4+
import { usePathname, useRouter } from 'next/navigation';
45
import { QueryCache, QueryClient, QueryClientProvider } from '@tanstack/react-query';
56
import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
67
import { ReactQueryStreamedHydration } from '@tanstack/react-query-next-experimental';
78
import { reissue } from '../_apis/auth/reissue-apis';
89
import { useAuthStore } from '../store/use-auth-store';
10+
import { ApiError } from '../utils/api';
911

1012
export default function ClientProvider({ children }: { children: ReactNode }) {
1113
const setToken = useAuthStore((state) => state.setToken);
14+
const redirect = usePathname();
15+
const router = useRouter();
1216

1317
const [queryClient] = useState(
1418
() =>
@@ -25,16 +29,22 @@ export default function ClientProvider({ children }: { children: ReactNode }) {
2529
},
2630
},
2731
},
28-
// accessToken 에러 -> reissue() -> refetch()
2932
queryCache: new QueryCache({
3033
onError: async (error, query) => {
31-
if (error.message === '토큰이 올바르지 않습니다.') {
32-
const { token } = await reissue();
33-
if (token) setToken(token.replace(/^Bearer\s/, ''));
34-
await Promise.all([
35-
queryClient.refetchQueries({ queryKey: query.queryKey }),
36-
queryClient.refetchQueries({ queryKey: ['user'] }),
37-
]);
34+
const apiError = error as ApiError;
35+
if (apiError.status === 401) {
36+
try {
37+
const { token } = await reissue();
38+
if (token) {
39+
setToken(token.replace(/^Bearer\s/, ''));
40+
await Promise.all([
41+
queryClient.refetchQueries({ queryKey: query.queryKey }),
42+
queryClient.refetchQueries({ queryKey: ['user'] }),
43+
]);
44+
}
45+
} catch {
46+
router.push(`/login?redirect=${redirect}`);
47+
}
3848
}
3949
},
4050
}),

src/components/common/gathering-card/scheduled-gathering-card/presenter.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,13 @@ export default function ScheduledGatheringCardPresenter({
2828
tabIndex={0}
2929
className="h-80 cursor-pointer items-center rounded-xl bg-white shadow-xs md:flex md:h-44"
3030
>
31-
{/* Image Section */}
32-
<div className="relative h-28 w-28 flex-shrink-0 overflow-hidden rounded-lg md:h-32 md:w-32 lg:h-32 lg:w-32">
31+
<div className="relative h-1/2 w-full flex-shrink-0 overflow-hidden rounded-t-lg md:h-full md:w-1/3 md:rounded-l-lg md:rounded-r-none">
3332
<Image
3433
src={imageUrl}
3534
alt={title}
3635
fill
3736
sizes="(max-width: 744px) 100vw, (max-width: 1200px) 50vw, 33vw"
38-
className="h-full w-full object-cover"
37+
className="object-cover"
3938
/>
4039
</div>
4140
<div className="flex h-1/2 w-full min-w-0 flex-grow flex-col justify-between p-4 md:h-full">

0 commit comments

Comments
 (0)