-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Feature/#140
- Loading branch information
Showing
10 changed files
with
137 additions
and
4 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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 @@ | ||
import Header from '@components/common/Header'; | ||
|
||
interface TermsLayoutProps { | ||
children: React.ReactNode; | ||
} | ||
|
||
export default function layout({ children }: TermsLayoutProps) { | ||
return ( | ||
<div> | ||
<Header> | ||
<p className="body-16-bold">설정</p> | ||
</Header> | ||
{children} | ||
</div> | ||
); | ||
} |
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,41 @@ | ||
'use client'; | ||
|
||
import { useRouter } from 'next/navigation'; | ||
|
||
import { SETTINGS, Setting } from '@constants/settings'; | ||
import RightArrowIcon from 'public/assets/icon24/right_arrow_24.svg'; | ||
import ArrowSquareIcon from 'public/assets/icon16/arrow_square_16.svg'; | ||
import { useLogout } from '@hooks/api/useLogout'; | ||
|
||
export default function Page() { | ||
const { push } = useRouter(); | ||
const { mutate: logout } = useLogout(); | ||
|
||
const handleClickSettingItem = (setting: Setting) => () => { | ||
if (setting.url) { | ||
push(setting.url); | ||
} | ||
|
||
if (setting.title === '로그아웃') { | ||
logout(); | ||
} | ||
}; | ||
|
||
return ( | ||
<ul className="pt-[56px]"> | ||
{SETTINGS.map((setting, index) => ( | ||
<li | ||
key={index} | ||
className="flex justify-between items-center py-[8px] pl-[24px] pr-[16px] h-[56px] cursor-pointer border-b-[1px] border-gray-100" | ||
onClick={handleClickSettingItem(setting)} | ||
> | ||
<div className="flex gap-[4px] items-center"> | ||
<p className="body-16-bold">{setting.title}</p> | ||
{setting.url && <ArrowSquareIcon />} | ||
</div> | ||
{setting.url && <RightArrowIcon />} | ||
</li> | ||
))} | ||
</ul> | ||
); | ||
} |
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 +1,2 @@ | ||
export const TOKEN_REFRESH_URL = '/api/v1/auth/token/reissue'; | ||
export const LOGOUT_URL = '/api/v1/auth/logout'; |
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,25 @@ | ||
export interface Setting { | ||
url?: string; | ||
title: string; | ||
} | ||
|
||
export const SETTINGS: Setting[] = [ | ||
{ | ||
url: '/service-terms', | ||
title: '이용약관', | ||
}, | ||
{ | ||
url: '/privacy-policy', | ||
title: '개인정보처리방침', | ||
}, | ||
{ | ||
url: '/location-terms', | ||
title: '위치기반 서비스 이용약관', | ||
}, | ||
{ | ||
title: '로그아웃', | ||
}, | ||
{ | ||
title: '회원탈퇴', | ||
}, | ||
]; |
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,19 @@ | ||
import { useMutation, UseMutationResult } from '@tanstack/react-query'; | ||
import { AxiosError } from 'axios'; | ||
import Cookies from 'js-cookie'; | ||
import { useRouter } from 'next/navigation'; | ||
|
||
import { logout } from '@utils/auth'; | ||
|
||
export const useLogout = (): UseMutationResult<void, AxiosError, void> => { | ||
const { push } = useRouter(); | ||
return useMutation({ | ||
mutationKey: ['logout'], | ||
mutationFn: logout, | ||
onSuccess: () => { | ||
Cookies.remove('accessToken'); | ||
Cookies.remove('refreshToken'); | ||
push('/login'); | ||
}, | ||
}); | ||
}; |
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
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