Skip to content

Commit

Permalink
.env 파일 타입 선언 및 router 및 경로 설정 (#133)
Browse files Browse the repository at this point in the history
* feat: (#124) .env 파일에 타입을 적용하여 자동 완성 되도록 적용

* feat: (#124) path, router 설정 및 잘못된 URL 경로 수정

* chore: (#124) 스타일드 컴포넌트 이름 수정 및 상수 URL 사용
  • Loading branch information
Gilpop8663 authored and tjdtls690 committed Sep 12, 2023
1 parent 3663cf1 commit a9cd61b
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 24 deletions.
6 changes: 6 additions & 0 deletions frontend/env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
declare module NodeJS {
interface ProcessEnv {
VOTOGETHER_BASE_URL: string;
VOTOGETHER_MOCKING_URL: string;
}
}
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.CategoryNameLink to={`/posts/category/${id}`}>{name}</S.CategoryNameLink>
</S.CategoryItem>
))}
</S.CategoryList>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export const Caption = styled.span`
color: var(--dark-gray);
`;

export const CategoryName = styled(Link)`
export const CategoryNameLink = styled(Link)`
text-decoration: none;
color: inherit;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';

import { User } from '@type/user';

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

import * as PS from '../profileStyle';

Expand All @@ -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={PATH.USER_POST}>
<S.TextCardTitle>작성글</S.TextCardTitle>
<S.TextCardContent>{postCount}</S.TextCardContent>
</S.TextCardLink>
<S.TextCardLink to={`/${BASE_PATH.USER}/votes`}>
<S.TextCardLink to={PATH.USER_VOTE}>
<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
2 changes: 1 addition & 1 deletion frontend/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@
},
"outDir": "./dist"
},
"include": ["src", "src/custom.d.ts", "__test__", "styled-components.d.ts"],
"include": ["src", "src/custom.d.ts", "__test__", "styled-components.d.ts", "env.d.ts"],
"exclude": ["node_modules"]
}

0 comments on commit a9cd61b

Please sign in to comment.