Skip to content

Commit dcf2356

Browse files
authored
Merge pull request #75 from GotchaAI/feature/auth
branch: 프로필에 로그아웃 기능 추가
2 parents 1d1520b + 26dee26 commit dcf2356

5 files changed

Lines changed: 55 additions & 14 deletions

File tree

src/assets/commons/carrot.png

8.94 KB
Loading

src/components/home/Profile.jsx

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,21 @@
1-
import rabbit from "assets/rabbit-sample.png";
2-
import useUserInformationStore from "store/userInformation";
3-
import "styles/components/home/Profile.scss";
1+
import carrot from 'assets/commons/carrot.png';
2+
import { signOutAPI } from 'services/auth/auth';
3+
import useUserInformationStore from 'store/userInformation';
4+
import 'styles/components/home/Profile.scss';
45

56
const Profile = () => {
67
const profile = useUserInformationStore((state) => state.profile);
78
const experience = useUserInformationStore((state) => state.experience);
9+
10+
const signOutHandler = async () => {
11+
try {
12+
await signOutAPI();
13+
window.location.reload();
14+
} catch (e) {
15+
console.error(e);
16+
}
17+
};
18+
819
return (
920
<div className="profile-container">
1021
<div className="exp-container">
@@ -20,7 +31,7 @@ const Profile = () => {
2031
</div>
2132
<div className="profile-user-info-container">
2233
<div className="profile-img-container">
23-
<img src={rabbit} alt="프로필 사진" />
34+
<img src={carrot} alt="프로필 사진" />
2435
</div>
2536
<div className="profile-detail-container">
2637
<div className="profile-detail">
@@ -32,6 +43,10 @@ const Profile = () => {
3243
</div>
3344
</div>
3445
</div>
46+
47+
<button className="sign-out-btn" type="button" onClick={signOutHandler}>
48+
로그아웃
49+
</button>
3550
</div>
3651
);
3752
};

src/constants/api.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export const GUEST_SIGN_IN_API = process.env.REACT_APP_GUEST_SIGN_IN_API;
99
export const GUEST_SIGN_UP_API = process.env.REACT_APP_GUEST_SIGN_UP_API;
1010
export const TOKEN_REISSUE_API = process.env.REACT_APP_TOKEN_REISSUE_API;
1111
export const CSRF_TOKEN_API = process.env.REACT_APP_CSRF_TOKEN_API;
12+
export const SIGN_OUT_API = process.env.REACT_APP_SIGN_OUT_API;
1213

1314
export const EMAIL_SEND_API = process.env.REACT_APP_EMAIL_SEND_API;
1415
export const EMAIL_VERIFY_API = process.env.REACT_APP_EMAIL_VERIFY_API;
@@ -78,4 +79,4 @@ export const SERVICE_QNA_API = process.env.REACT_APP_SERVICE_QNA;
7879
export const RANKING_API = process.env.REACT_APP_RANKING_API;
7980
export const RANkING_MY_API = process.env.REACT_APP_MY_RANKING_API;
8081

81-
export const AI_SERVER_IP = process.env.REACT_APP_AI_SERVER_IP;
82+
export const AI_SERVER_IP = process.env.REACT_APP_AI_SERVER_IP;

src/services/auth/auth.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
EMAIL_VERIFY_API,
55
GUEST_SIGN_IN_API,
66
SIGN_IN_API,
7+
SIGN_OUT_API,
78
SIGN_UP_API,
89
TOKEN_REISSUE_API,
910
} from 'constants/api';
@@ -17,6 +18,10 @@ export const signInAPI = async (authForm) => {
1718
return await apiInterface('post', SIGN_IN_API, authForm, {}, false);
1819
};
1920

21+
export const signOutAPI = async () => {
22+
return await apiInterface('get', SIGN_OUT_API, {}, {}, true);
23+
};
24+
2025
export const guestSignInAPI = async () => {
2126
return await apiInterface('post', GUEST_SIGN_IN_API, {}, {}, false);
2227
};

src/styles/components/home/Profile.scss

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.profile-container {
2+
position: relative;
23
width: 255px;
34
height: 122px;
45

@@ -46,7 +47,7 @@
4647
left: 50%;
4748
top: 50%;
4849
transform: translate(-50%, -50%);
49-
font-family: "SUIT-Regular";
50+
font-family: 'SUIT-Regular';
5051
font-size: 13px;
5152
}
5253
}
@@ -58,15 +59,20 @@
5859

5960
.profile-img-container {
6061
position: relative;
62+
display: flex;
63+
align-items: center;
64+
justify-content: center;
6165
width: 67px;
6266
height: 67px;
63-
border: solid 1px;
64-
background-color: #d9d9d9;
67+
//border: solid 1px;
68+
border-radius: 8px;
69+
70+
background-color: #f28110;
6571

6672
overflow: hidden;
6773
img {
68-
width: 67px;
69-
height: 67px;
74+
width: 30.67px;
75+
height: 35.21px;
7076
}
7177
}
7278

@@ -76,14 +82,14 @@
7682
align-items: center;
7783
justify-content: center;
7884

79-
width: 149px;
85+
width: 129px;
8086

81-
font-family: "YoonChild";
87+
font-family: 'YoonChild';
8288

8389
.profile-detail {
8490
display: flex;
8591
flex-direction: column;
86-
align-items: center;
92+
align-items: start;
8793
justify-content: center;
8894

8995
width: 92px;
@@ -103,7 +109,7 @@
103109
align-items: center;
104110
font-size: 15px;
105111
font-weight: 600;
106-
font-family: "YoonChild";
112+
font-family: 'YoonChild';
107113
}
108114

109115
.left-strip {
@@ -117,4 +123,18 @@
117123
}
118124
}
119125
}
126+
127+
.sign-out-btn {
128+
position: absolute;
129+
bottom: 5px;
130+
right: 10px;
131+
background: none;
132+
border: none;
133+
134+
font-size: 10.5px;
135+
136+
&:hover {
137+
color: red;
138+
}
139+
}
120140
}

0 commit comments

Comments
 (0)