Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 50 additions & 34 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,55 +1,71 @@
import { Routes, Route, useLocation, useSearchParams } from 'react-router-dom';
import Navbar from './components/layout/Navbar';
import Login from './pages/account/Login';
import Signup from './pages/account/Signup';
import Store from './pages/store/Store';
import StoreEdit from './pages/store/StoreEdit';
import StoreForm from './pages/store/StoreForm';
import StorePost from './pages/store/StorePost';
import Profile from './pages/profile/Profile';
import ProfileForm from './pages/profile/ProfileForm';
import NoticeList from './pages/notice/NoticeList';
import Notice from './pages/notice/Notice';
import { Suspense, lazy } from 'react';
import { Routes, Route, useLocation } from 'react-router-dom';
import Navbar from '@/components/layout/Navbar';

// νŽ˜μ΄μ§€ μ»΄ν¬λ„ŒνŠΈ lazy import
const NoticeList = lazy(() => import('@/pages/notice/NoticeList'));
const Notice = lazy(() => import('@/pages/notice/Notice'));
const Login = lazy(() => import('@/pages/account/Login'));
const Signup = lazy(() => import('@/pages/account/Signup'));
const NotFound = lazy(() => import('@/pages/error/NotFound'));

const Store = lazy(() => import('@/pages/store/Store'));
const StoreEdit = lazy(() => import('@/pages/store/StoreEdit'));
const StoreForm = lazy(() => import('@/pages/store/StoreForm'));
const StorePost = lazy(() => import('@/pages/store/StorePost'));

const Profile = lazy(() => import('@/pages/profile/Profile'));
const ProfileForm = lazy(() => import('@/pages/profile/ProfileForm'));

import { useSearchParams } from 'react-router-dom';

// 검색 쿼리용 νŽ˜μ΄μ§€
function SearchPage() {
const [params] = useSearchParams();
const query = params.get('query') || '';
return <NoticeList search={query} />;
}

// λ‘œλ”© μŠ€ν”Όλ„ˆ
function LoadingSpinner() {
return (
<div className="flex min-h-[calc(100vh-102px)] items-center justify-center md:min-h-[calc(100vh-70px)]">
<div className="size-100 animate-spin rounded-full border-8 border-gray-200 border-t-primary" />
</div>
);
}

export default function App() {
const { pathname } = useLocation();

return (
<>
<Suspense fallback={<LoadingSpinner />}>
{pathname !== '/login' && pathname !== '/signup' && <Navbar />}
<Routes>
{/* 곡톡 νŽ˜μ΄μ§€ */}
<Route path="/" element={<NoticeList />} />
<Route path="/search" element={<SearchPage />} />
<Route path=":shopId/:noticeId" element={<Notice />} />
<Route path="login" element={<Login />} />
<Route path="signup" element={<Signup />} />
<Route path="/:shopId/:noticeId" element={<Notice />} />
<Route path="/login" element={<Login />} />
<Route path="/signup" element={<Signup />} />

{/* 사μž₯λ‹˜ νŽ˜μ΄μ§€ */}
<Route path="owner">
<Route path="store">
<Route index element={<Store />} />
<Route path="edit" element={<StoreEdit />} />
</Route>
<Route path="post">
<Route index element={<StoreForm />} />
<Route path=":shopId/:noticeId" element={<StorePost />} />
<Route path=":shopId/:noticeId/edit" element={<StoreForm />} />
</Route>
</Route>

{/* μ•Œλ°”λ‹˜ ν”„λ‘œν•„ νŽ˜μ΄μ§€ */}
<Route path="profile">
<Route index element={<Profile />} />
<Route path="edit" element={<ProfileForm />} />
</Route>
<Route path="/owner/store" element={<Store />} />
<Route path="/owner/store/edit" element={<StoreEdit />} />
<Route path="/owner/post" element={<StoreForm />} />
<Route path="/owner/post/:shopId/:noticeId" element={<StorePost />} />
<Route
path="/owner/post/:shopId/:noticeId/edit"
element={<StoreForm />}
/>

{/* μ•Œλ°”λ‹˜ ν”„λ‘œν•„ */}
<Route path="/profile" element={<Profile />} />
<Route path="/profile/edit" element={<ProfileForm />} />

{/* 404 Not Found */}
<Route path="*" element={<NotFound />} />
</Routes>
</>
</Suspense>
);
}
13 changes: 13 additions & 0 deletions src/pages/error/NotFound.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Link } from 'react-router-dom';

export default function NotFound() {
return (
<div className="flex h-screen flex-col items-center justify-center text-center">
<h1 className="mb-20 text-8xl font-bold text-primary">404</h1>
<p className="mb-40 text-4xl text-primary">νŽ˜μ΄μ§€λ₯Ό 찾을 수 μ—†μŠ΅λ‹ˆλ‹€.</p>
<Link to="/" className="text-xl text-[#5534DA] underline">
ν™ˆμœΌλ‘œ λŒμ•„κ°€κΈ°
</Link>
</div>
);
}