Skip to content

Commit 63793f7

Browse files
authored
기능개발 v1.2
2 parents 6879823 + 295a01d commit 63793f7

74 files changed

Lines changed: 1045 additions & 808 deletions

File tree

Some content is hidden

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

public/styles/casual.jpg

142 KB
Loading

public/styles/classic.jpg

1.04 MB
Loading

public/styles/feminine.jpg

584 KB
Loading

public/styles/formal.jpg

16.4 KB
Loading

public/styles/hip.jpg

142 KB
Loading

public/styles/luxury.jpg

826 KB
Loading

public/styles/minimal.jpg

430 KB
Loading

public/styles/outdoor.jpg

246 KB
Loading

public/styles/street.jpg

1.5 MB
Loading

src/App.tsx

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react';
1+
import React, { useEffect, useState } from 'react';
22
import { BrowserRouter, Route, Routes, Navigate } from 'react-router-dom';
33

44
import Home from '@pages/Home';
@@ -7,6 +7,7 @@ import LoginComplete from '@pages/Login/LoginComplete';
77

88
import SignUp from '@pages/SignUp';
99
import TermsAgreement from '@pages/SignUp/TermsAgreement';
10+
import PickMyStyle from '@pages/SignUp/PickMyStyle';
1011

1112
import Profile from '@pages/Profile';
1213
import ProfileEdit from '@pages/Profile/ProfileEdit';
@@ -24,11 +25,29 @@ import PostInstaFeedSelect from '@pages/Post/PostInstaFeedSelect';
2425

2526
import Chats from '@pages/Chats';
2627
import ChatRoom from '@pages/Chats/ChatRoom';
28+
import MatchingRoom from '@pages/Chats/MatchingRoom';
2729

2830
import NotFound from '@pages/NotFound';
31+
import { getUserInfoApi } from '@apis/user';
32+
import { getCurrentUserId } from '@utils/getCurrentUserId';
33+
import Loading from '@components/Loading';
2934

3035
const ProtectedRoute = ({ children }: { children: JSX.Element }) => {
31-
const isAuthenticated = Boolean(localStorage.getItem('new_jwt_token'));
36+
const [isAuthenticated, setIsAuthenticated] = useState<boolean | null>(null);
37+
38+
useEffect(() => {
39+
const checkAuth = async () => {
40+
const currentUserId = getCurrentUserId();
41+
const response = await getUserInfoApi(currentUserId);
42+
setIsAuthenticated(response.isSuccess);
43+
};
44+
checkAuth();
45+
}, []);
46+
47+
if (isAuthenticated === null) {
48+
return <Loading />;
49+
}
50+
3251
return isAuthenticated ? children : <Navigate to="/login" />;
3352
};
3453

@@ -55,6 +74,7 @@ const protectedRoutes = [
5574
// 메시지/채팅
5675
{ path: '/chats', element: <Chats /> },
5776
{ path: '/chats/:chatRoomId', element: <ChatRoom /> },
77+
{ path: '/matching', element: <MatchingRoom /> },
5878
];
5979

6080
// 인증이 필요 없는 페이지 배열
@@ -64,6 +84,7 @@ const publicRoutes = [
6484

6585
{ path: '/signup', element: <SignUp /> },
6686
{ path: '/signup/terms-agreement', element: <TermsAgreement /> },
87+
{ path: '/signup/pick-my-style', element: <PickMyStyle /> },
6788
];
6889

6990
const App: React.FC = () => {

0 commit comments

Comments
 (0)