File tree 5 files changed +52
-15
lines changed
5 files changed +52
-15
lines changed Original file line number Diff line number Diff line change @@ -5,12 +5,14 @@ import { Link } from 'react-router-dom';
5
5
import colors from 'styles/color' ;
6
6
import Menus from 'common/components/layout/menus' ;
7
7
import { Search , Logo } from 'common/components/icons' ;
8
+ import useAuth from 'common/hooks/useAuth' ;
8
9
9
10
interface Props extends HTMLAttributes < HTMLDivElement > {
10
11
children : ReactNode ;
11
12
}
12
13
13
14
const Layout = ( { children } : Props ) => {
15
+ const { logout } = useAuth ( [ ] ) ;
14
16
return (
15
17
< div css = { _container } >
16
18
< aside css = { _sideMenu } >
@@ -22,6 +24,9 @@ const Layout = ({ children }: Props) => {
22
24
< nav aria-label = "Sidebar navigation" css = { _menuContainer } >
23
25
< Menus />
24
26
</ nav >
27
+ < button onClick = { logout } css = { _signout } >
28
+ Sign out
29
+ </ button >
25
30
</ aside >
26
31
< div css = { _wrapper } >
27
32
< header css = { _header } >
@@ -58,6 +63,10 @@ const _sideMenu = css`
58
63
width : 345px ;
59
64
background-color : rgba (255 , 255 , 255 , 1 );
60
65
filter : drop-shadow (18px 4px 30px # 00000002 );
66
+ height : 100% ;
67
+ display : flex;
68
+ flex-direction : column;
69
+ padding-bottom : 24px ;
61
70
` ;
62
71
63
72
const _wrapper = css `
@@ -145,3 +154,12 @@ const _main = css`
145
154
146
155
padding : 32px ; // 메인 컴포넌트 기본 패딩
147
156
` ;
157
+
158
+ const _signout = css `
159
+ margin-top : auto;
160
+ cursor : pointer;
161
+ transition : opacity 0.7s ;
162
+ : hover {
163
+ opacity : 0.5 ;
164
+ }
165
+ ` ;
Original file line number Diff line number Diff line change 1
1
export const authMockData = {
2
2
login : {
3
- " response" : {
4
- " accessToken" : " JWT 토큰 문자열" ,
5
- " refreshToken" : " JWT 토큰 문자열"
3
+ response : {
4
+ accessToken : ' JWT 토큰 문자열' ,
5
+ refreshToken : ' JWT 토큰 문자열' ,
6
6
} ,
7
- "code" : "200" ,
8
- "message" : "성공"
7
+ code : '200' ,
8
+ message : '성공' ,
9
+ } ,
10
+ logout : {
11
+ code : '200' ,
12
+ message : '성공' ,
9
13
} ,
10
14
refresh : {
11
- " response" : {
12
- " accessToken" : " JWT 토큰 문자열" ,
13
- " refreshToken" : " JWT 토큰 문자열"
15
+ response : {
16
+ accessToken : ' JWT 토큰 문자열' ,
17
+ refreshToken : ' JWT 토큰 문자열' ,
14
18
} ,
15
- " code" : " 200" ,
16
- " message" : "성공"
17
- }
18
- }
19
+ code : ' 200' ,
20
+ message : '성공' ,
21
+ } ,
22
+ } ;
Original file line number Diff line number Diff line change @@ -18,6 +18,9 @@ export const authHandlers = [
18
18
http . post ( `${ BASE_URL } /auth/refresh` , async ( ) => {
19
19
return HttpResponse . json ( authMockData . refresh ) ;
20
20
} ) ,
21
+ http . post ( `${ BASE_URL } /auth/logout` , async ( ) => {
22
+ return HttpResponse . json ( authMockData . logout ) ;
23
+ } ) ,
21
24
] ;
22
25
23
26
// 계정 관련 API 요청 핸들러 정의
Original file line number Diff line number Diff line change @@ -24,11 +24,23 @@ const SignIn = () => {
24
24
resolver : zodResolver ( loginSchema ) ,
25
25
} ) ;
26
26
27
- const { login : loginFn } = useAuth ( [ 'admin' , 'guest' , 'owner' ] ) ;
27
+ const { login } = useAuth ( [ 'admin' , 'guest' , 'owner' ] ) ;
28
+
29
+ const loginTestData = {
30
+ accountId : 'test@naver.com' ,
31
+ password : '123!@#' ,
32
+ } ;
28
33
29
34
const onSubmit : SubmitHandler < SignInFormType > = async ( data ) => {
30
35
try {
31
- await loginFn ( data ) ;
36
+ if (
37
+ data . accountId === loginTestData . accountId &&
38
+ data . password === loginTestData . password
39
+ ) {
40
+ await login ( data ) ;
41
+ } else {
42
+ alert ( '로그인 실패' ) ;
43
+ }
32
44
reset ( ) ;
33
45
} catch {
34
46
alert ( '로그인 실패' ) ;
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ import type { UpdateStorePayload } from 'api/modules/stores/types';
24
24
import useAuth from 'common/hooks/useAuth' ;
25
25
26
26
const Store = ( { ...rest } ) => {
27
- const { AuthGuard } = useAuth ( [ 'admin' ] ) ;
27
+ const { AuthGuard } = useAuth ( [ 'admin' , 'owner' ] ) ;
28
28
const { data } = useGetStoresQueryTest ( 1 ) ;
29
29
const { mutate : updateStoreQuery } = useUpdateStoresQuery ( ) ;
30
30
You can’t perform that action at this time.
0 commit comments