Skip to content

Commit 15a133c

Browse files
authored
Merge branch 'main' into 81-feat/루핏톡-페이지-제작
2 parents 04855dc + 7251ba7 commit 15a133c

96 files changed

Lines changed: 941 additions & 114 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/app/layout/MainLayout.tsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,24 @@
1+
import { useLogoutMutation } from '@shared/apis/auth';
2+
import { useAuth } from '@shared/apis/user';
13
import { Header } from '@shared/ui/Header';
24
import { Outlet } from 'react-router';
35

46
const MainLayout = () => {
7+
const { user, isLoggedIn, isLoading } = useAuth();
8+
const { mutate: logout } = useLogoutMutation();
9+
10+
const handleLogout = () => {
11+
logout();
12+
};
13+
514
return (
615
<div className="min-h-screen bg-white">
7-
<Header />
16+
<Header
17+
isLoading={isLoading}
18+
isLoggedIn={isLoggedIn}
19+
user={user ? { profileImage: user.profileImage, nickname: user.nickname } : undefined}
20+
onLogoutClick={handleLogout}
21+
/>
822
<div className="mt-header-total">
923
<Outlet />
1024
</div>

src/app/layout/ProtectedLayout.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { useAuthStore } from '@shared/stores';
2+
import { Navigate, Outlet } from 'react-router';
3+
4+
const ProtectedLayout = () => {
5+
const accessToken = useAuthStore((state) => state.accessToken);
6+
7+
if (!accessToken) {
8+
return <Navigate to="/login" replace />;
9+
}
10+
11+
return <Outlet />;
12+
};
13+
14+
export default ProtectedLayout;

src/app/layout/PublicLayout.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { useAuthStore } from '@shared/stores';
2+
import { Navigate, Outlet } from 'react-router';
3+
4+
const PublicLayout = () => {
5+
const accessToken = useAuthStore((state) => state.accessToken);
6+
7+
if (accessToken) {
8+
return <Navigate to="/" replace />;
9+
}
10+
11+
return <Outlet />;
12+
};
13+
14+
export default PublicLayout;

src/app/layout/index.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
2+
import { useState, type ReactNode } from 'react';
3+
4+
type QueryProviderProps = {
5+
children: ReactNode;
6+
};
7+
8+
export const QueryProvider = ({ children }: QueryProviderProps) => {
9+
const [queryClient] = useState(
10+
() =>
11+
new QueryClient({
12+
defaultOptions: {
13+
queries: {
14+
staleTime: 60 * 1000,
15+
retry: 1,
16+
},
17+
},
18+
})
19+
);
20+
21+
return <QueryClientProvider client={queryClient}>{children}</QueryClientProvider>;
22+
};

src/app/providers/index.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { QueryProvider } from './QueryProvider';
12
import { ToastProvider } from './ToastProvider';
23
import type { ReactNode } from 'react';
34

@@ -6,5 +7,9 @@ type AppProvidersProps = {
67
};
78

89
export const AppProviders = ({ children }: AppProvidersProps) => {
9-
return <ToastProvider>{children}</ToastProvider>;
10+
return (
11+
<QueryProvider>
12+
<ToastProvider>{children}</ToastProvider>
13+
</QueryProvider>
14+
);
1015
};

src/app/routes.ts

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,46 @@
11
import { index, layout, route, type RouteConfig } from '@react-router/dev/routes';
22

33
export default [
4-
// (auth) - 레이아웃 없는 인증 페이지
5-
route('login', 'routes/(auth)/login.tsx'),
6-
route('signup', 'routes/(auth)/signup.tsx'),
4+
// (auth) - 비로그인만 접근 가능 (로그인 시 / 로 리다이렉트)
5+
layout('layout/PublicLayout.tsx', [
6+
route('login', 'routes/(auth)/login.tsx'),
7+
route('signup', 'routes/(auth)/signup.tsx'),
8+
]),
9+
10+
// 카카오 콜백 (인증 체크 불필요)
11+
route('login/kakao', 'routes/(auth)/login.kakao.tsx'),
712

813
// (main) - MainLayout 적용 페이지
914
layout('layout/MainLayout.tsx', [
15+
// 공개 페이지 (누구나 접근 가능)
1016
index('routes/(main)/_index.tsx'),
1117

1218
// buy
1319
route('buy', 'routes/(main)/buy/index.tsx'),
1420
route('buy/:id', 'routes/(main)/buy/detail.tsx'),
1521

16-
// sell
17-
route('sell', 'routes/(main)/sell/index.tsx'),
18-
route('sell/confirm', 'routes/(main)/sell/confirm.tsx'),
19-
2022
// repair
2123
route('repair', 'routes/(main)/repair/index.tsx'),
2224

23-
// mypage
24-
route('mypage', 'routes/(main)/mypage/index.tsx'),
25-
route('mypage/settings', 'routes/(main)/mypage/settings.tsx'),
26-
route('mypage/profile', 'routes/(main)/mypage/profile.tsx'),
27-
2825
// seller
2926
route('seller/:userId', 'routes/(main)/seller/index.tsx'),
3027

31-
// chat
32-
route('chat', 'routes/(main)/chat/index.tsx'),
28+
// 로그인 필요 페이지 (미로그인 시 /login 으로 리다이렉트)
29+
layout('layout/ProtectedLayout.tsx', [
30+
// sell
31+
route('sell', 'routes/(main)/sell/index.tsx'),
32+
route('sell/confirm', 'routes/(main)/sell/confirm.tsx'),
33+
34+
// mypage
35+
route('mypage', 'routes/(main)/mypage/index.tsx'),
36+
route('mypage/settings', 'routes/(main)/mypage/settings.tsx'),
37+
route('mypage/profile', 'routes/(main)/mypage/profile.tsx'),
38+
39+
// chat
40+
route('chat', 'routes/(main)/chat/index.tsx'),
3341

34-
// chatbot
35-
route('chatbot', 'routes/(main)/chatbot/index.tsx'),
42+
// chatbot
43+
route('chatbot', 'routes/(main)/chatbot/index.tsx'),
44+
]),
3645
]),
37-
] satisfies RouteConfig;
46+
] satisfies RouteConfig;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { KakaoLogin } from '@pages/login';
2+
3+
export default function KakaoLoginRoute() {
4+
return <KakaoLogin />;
5+
}

src/app/styles/index.css

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,5 +223,20 @@
223223
transform: translateY(4px);
224224
}
225225
}
226+
227+
.animate-dropdown {
228+
animation: dropdown 0.2s ease-out forwards;
229+
}
230+
231+
@keyframes dropdown {
232+
from {
233+
opacity: 0;
234+
transform: translateY(-8px);
235+
}
236+
to {
237+
opacity: 1;
238+
transform: translateY(0);
239+
}
240+
}
226241
}
227242
}

src/pages/login/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export { LoginPage } from './ui';
1+
export { LoginPage, KakaoLogin } from './ui';

0 commit comments

Comments
 (0)