Skip to content

Commit

Permalink
chore : 예시 페이지 생성 및 로그인 상태 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
judahhh committed Oct 20, 2023
1 parent c81e2bf commit 86cb97b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ dist
dist-ssr
*.local
.env
src/pages/example

# Editor directories and files
.vscode/*
Expand Down
3 changes: 3 additions & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import AdminPage from '@/pages/admin'
import AdminLoginPage from '@/pages/admin/AdminLogin'
import ChatListPage from '@/pages/chatList'
import ChattingPage from '@/pages/chatting'
import ExamplePage from '@/pages/example'

Check failure on line 7 in src/App.tsx

View workflow job for this annotation

GitHub Actions / build

Cannot find module '@/pages/example' or its corresponding type declarations.
import HomePage from '@/pages/home'
import LandingPage from '@/pages/landing'
import LoginPage from '@/pages/login'
Expand All @@ -21,6 +22,7 @@ const App = () => {
<Route path={'/profile/*'} element={<ProfilePage />} />
<Route path={'/chatting'} element={<ChattingPage />} />
<Route path={'/chat-list'} element={<ChatListPage />} />
<Route path={'/example'} element={<ExamplePage />}></Route>
<Route path={'*'} element={<NotFoundPage />}></Route>
</Route>

Expand All @@ -29,6 +31,7 @@ const App = () => {
<Route path={'/login'} element={<LoginPage />} />
<Route path={'/register/*'} element={<RegisterPage />} />
<Route path={'/admin-login'} element={<AdminLoginPage />} />
<Route path={'/example'} element={<ExamplePage />}></Route>
<Route path={'*'} element={<NotFoundPage />}></Route>
</Route>

Expand Down
8 changes: 5 additions & 3 deletions src/pages/redirect/PrivateRoute.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ type PrivateRouteProps = {
superAuth?: boolean
}

type LoginStatus = 'true' | 'false'

const PrivateRoute = ({ auth }: PrivateRouteProps) => {
const isLogin = localStorage.getItem('isLogin')
const isLogin: LoginStatus = 'true'

if (auth) {
return isLogin === null || isLogin == 'false' ? <Navigate to={'/login'} /> : <Outlet />
return isLogin !== 'true' ? <Navigate to={'/login'} /> : <Outlet />
} else {
return isLogin === null || isLogin == 'false' ? <Outlet /> : <Navigate to={'/'} />
return isLogin !== 'true' ? <Outlet /> : <Navigate to={'/'} />
}
}

Expand Down

0 comments on commit 86cb97b

Please sign in to comment.