This repository has been archived by the owner on Jul 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
45f17a8
commit cfd9735
Showing
3 changed files
with
31 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
export const PATH = { | ||
app: '', | ||
introducePage: '', | ||
oauthPage: 'oauth/login/*', | ||
kakao: 'kakao', | ||
space: 'space', | ||
writingPage: 'writings/:categoryId/:writingId', | ||
writingTablePage: 'writings/:categoryId', | ||
} as const; | ||
|
||
export const NAVIGATE_PATH = { | ||
homePage: `/${PATH.space}`, | ||
getWritingTablePage: (categoryId: number) => `/${PATH.space}/writings/${categoryId}`, | ||
getWritingPage: (categoryId: number, writingId: number) => | ||
`/${PATH.space}/writings/${categoryId}/${writingId}`, | ||
} as const; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,16 @@ | ||
import { NAVIGATE_PATH } from 'constants/path'; | ||
import { useNavigate } from 'react-router-dom'; | ||
|
||
export const usePageNavigate = () => { | ||
const navigate = useNavigate(); | ||
|
||
const goHomePage = () => navigate('/space'); | ||
const goHomePage = () => navigate(NAVIGATE_PATH.homePage); | ||
|
||
const goWritingPage = ({ categoryId, writingId }: { categoryId: number; writingId: number }) => | ||
navigate(`/space/writings/${categoryId}/${writingId}`); | ||
const goWritingTablePage = (categoryId: number) => | ||
navigate(NAVIGATE_PATH.getWritingTablePage(categoryId)); | ||
|
||
const goWritingTablePage = (categoryId: number) => navigate(`/space/writings/${categoryId}`); | ||
const goWritingPage = ({ categoryId, writingId }: { categoryId: number; writingId: number }) => | ||
navigate(NAVIGATE_PATH.getWritingPage(categoryId, writingId)); | ||
|
||
return { goHomePage, goWritingPage, goWritingTablePage }; | ||
return { goHomePage, goWritingTablePage, goWritingPage }; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters