Skip to content

Commit c6fdb34

Browse files
committed
feat: 이메일 필드 추가 및 프로필 페이지에 이메일 표시
1 parent f1c20a4 commit c6fdb34

6 files changed

Lines changed: 32 additions & 0 deletions

File tree

src/controllers/auth/api.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,14 @@ export const fetchOAuth2Login = async (_code: string, _state: string, provider:
3434

3535
export const fetchAuthRegister = async (
3636
imageBase64: string,
37+
email: string,
3738
nickname: string,
3839
birth_date: string,
3940
marketingAgreement: boolean,
4041
provider: string,
4142
) => {
4243
const formData = new FormData();
44+
if (email) formData.append('email', email);
4345
formData.append('nickname', nickname);
4446
formData.append('birth_date', birth_date);
4547
formData.append('marketingAgreement', String(marketingAgreement));

src/hooks/useAuthInfo.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { webPath } from '@router/index';
33
import useLocalStorageState from './useLocalStorageState';
44

55
interface UserInfo {
6+
email?: string;
67
nickname: string;
78
profileImage?: string;
89
provider: string;

src/hooks/useSocialAuth.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,15 @@ export const useSocialAuth = () => {
9696
navigate(webPath.register, {
9797
state: {
9898
provider,
99+
email: res.email,
99100
},
100101
});
101102
return;
102103
}
103104

104105
// 로그인 성공 - WebView와 브라우저 모두 동일하게 처리
105106
setAuthInfo(res.access_token, res.refresh_token, {
107+
email: res.email,
106108
nickname: res.nickname,
107109
profileImage: res.profileImageUrl,
108110
provider: res.provider,

src/pages/MyPage/Profile/Profile.Style.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ const ProfileContents = styled.div({
3131
},
3232
},
3333

34+
['>span']: {
35+
...theme.font.body16Medium,
36+
color: theme.colors.sub_blue1,
37+
},
38+
3439
['>button']: {
3540
display: 'flex',
3641
gap: '6px',

src/pages/MyPage/Profile/Profile.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const MyPageProfile = () => {
1111
const { isLogin, userInfo, handleNavigateLogin, setUserInfo } = useAuthInfo();
1212

1313
const username = userInfo?.nickname ?? '아직 정보가 없어요!';
14+
const useremail = userInfo?.email ?? '로그인을 진행해주세요';
1415

1516
const handleClickProfile = () => {
1617
if (!isLogin) {
@@ -62,6 +63,7 @@ const MyPageProfile = () => {
6263
/>
6364
<ProfileContents>
6465
<p>{username}<RightArrowThickSVG /></p>
66+
<span>{useremail}</span>
6567
</ProfileContents>
6668
</ProfileContainer>
6769
);

src/pages/Register/Register.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ const Register = () => {
5252
const { navToRegisterDone, navToTerm } = useRouter();
5353
const location = useLocation();
5454

55+
const email = location.state?.email || '';
56+
5557
const [values, setValues] = useState({
5658
name: '',
5759
birth: '',
@@ -189,6 +191,23 @@ const Register = () => {
189191
},
190192
],
191193
},
194+
...(email
195+
? [
196+
{
197+
name: 'email',
198+
title: '이메일',
199+
inputs: [
200+
{
201+
key: 'email',
202+
value: email,
203+
placeholder: 'email@email.com',
204+
disabled: true,
205+
handleChange: handleChangeValue,
206+
},
207+
],
208+
} as MyPageInputProps,
209+
]
210+
: []),
192211
{
193212
name: 'birth',
194213
title: '생년월일(선택)',
@@ -218,6 +237,7 @@ const Register = () => {
218237

219238
const res = await fetchAuthRegister(
220239
profileImage as string,
240+
email,
221241
values.name,
222242
values.birth,
223243
true,

0 commit comments

Comments
 (0)