Skip to content

Commit

Permalink
feat: (#124) path, router 설정 및 잘못된 URL 경로 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
Gilpop8663 committed Jul 25, 2023
1 parent ba0b6ba commit 33f196c
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export default function CategoryToggle({
onClick={() => handleFavoriteClick(id)}
$isFavorite={isFavorite}
/>
<S.CategoryName to={`/posts?categoryId=${id}`}>{name}</S.CategoryName>
<S.CategoryName to={`/posts/category/${id}`}>{name}</S.CategoryName>
</S.CategoryItem>
))}
</S.CategoryList>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ export default function UserProfile({ userInfo }: UserProfileProps) {
<S.TextCardTitle>포인트</S.TextCardTitle>
<S.TextCardContent>{userPoint}</S.TextCardContent>
</S.TextCardContainer>
<S.TextCardLink to={`/${BASE_PATH.USER}/posts`}>
<S.TextCardLink to={`${BASE_PATH.USER}/posts`}>
<S.TextCardTitle>작성글</S.TextCardTitle>
<S.TextCardContent>{postCount}</S.TextCardContent>
</S.TextCardLink>
<S.TextCardLink to={`/${BASE_PATH.USER}/votes`}>
<S.TextCardLink to={`${BASE_PATH.USER}/votes`}>
<S.TextCardTitle>투표수</S.TextCardTitle>
<S.TextCardContent>{voteCount}</S.TextCardContent>
</S.TextCardLink>
Expand Down
12 changes: 5 additions & 7 deletions frontend/src/constants/path.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
export const BASE_PATH = {
HOME: '/',

LANDING: '/landing',
LOGIN: '/login',

POST: '/posts',

USER: '/users',

ADMIN: '/admin',
SEARCH: '/search',
};

export const PATH = {
...BASE_PATH,

POST_WRITE: `${BASE_PATH.POST}/write`,
POST_WRITE_EDIT: `${BASE_PATH.POST}/write/:postId`,
POST_DETAIL: `${BASE_PATH.POST}/:postId`,
POST_VOTE_RESULT: `${BASE_PATH.POST}/:postId/results`,

POST_VOTE_RESULT: `${BASE_PATH.POST}/result/:postId`,
POST_CATEGORY: `${BASE_PATH.POST}/category/:categoryId`,
USER_POST: `${BASE_PATH.USER}/posts`,
USER_VOTE: `${BASE_PATH.USER}/votes`,
USER_INFO: `${BASE_PATH.USER}/myPage`,
};
36 changes: 25 additions & 11 deletions frontend/src/routes/router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,42 @@ import EditPost from '@pages/post/EditPost';
import PostDetailPage from '@pages/post/PostDetail';
import VoteStatisticsPage from '@pages/VoteStatistics';

import { PATH } from '@constants/path';

const router = createBrowserRouter([
{
path: '/',
path: PATH.HOME,
element: <Home />,
children: [
{ path: '', element: <Home /> },
{ path: 'search', element: <Home /> },
{ path: 'login', element: <Home /> },
],
},
{
path: PATH.POST,
children: [
{ path: 'write', element: <CreatePost /> },
{
path: 'posts/write',
element: <CreatePost />,
path: 'write/:postId',
element: <EditPost />,
},
{
path: 'posts/:postId',
path: ':postId',
element: <PostDetailPage />,
},
{
path: 'posts/write/:postId',
element: <EditPost />,
},
{
path: 'posts/result/:postId',
path: 'result/:postId',
element: <VoteStatisticsPage />,
},
{ path: 'posts/category/:categoryId', element: <Home /> },
{ path: 'category/:categoryId', element: <Home /> },
],
},
{
path: PATH.USER,
children: [
{ path: 'posts', element: <Home /> },
{ path: 'votes', element: <Home /> },
{ path: 'myPage', element: <Home /> },
],
},
]);
Expand Down

0 comments on commit 33f196c

Please sign in to comment.