Skip to content

Commit 144e75f

Browse files
committed
♻ refactor(#165): 마이페이지 이메일 아이콘 constant로 리팩토링
1 parent 5ea1606 commit 144e75f

2 files changed

Lines changed: 14 additions & 31 deletions

File tree

src/app/mypage/page.tsx

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
import { getLetterCount } from '@/api/letter/letter';
44
import { getUserInfo, logout } from '@/api/mypage/user';
5-
import Button from '@/components/common/Button';
65
import Loader, { LoaderContainer } from '@/components/common/Loader';
76
import NavigatorBar from '@/components/common/NavigatorBar';
7+
import { OAUTH } from '@/constants/oauth';
88
import { theme } from '@/styles/theme';
99
import { clearOnboarding, clearTokens, getRefreshToken } from '@/utils/storage';
1010
import { useRouter } from 'next/navigation';
@@ -65,7 +65,6 @@ const MyPage = () => {
6565
setName(response.data.name);
6666
setEmail(response.data.email);
6767
setPlatform(response.data.socialPlatform);
68-
// console.log('회원정보 조회 성공:', response.data);
6968
} catch (error) {
7069
console.error('회원정보 조회 실패:', error);
7170
}
@@ -81,18 +80,9 @@ const MyPage = () => {
8180
}
8281
};
8382

84-
const EmailType = (platform): string => {
85-
switch (platform) {
86-
case 'GOOGLE':
87-
return '/assets/icons/ic_google.svg';
88-
case 'KAKAO':
89-
return '/assets/icons/ic_kakao_profile.svg';
90-
case 'NAVER':
91-
return '/assets/icons/ic_naver.svg';
92-
default:
93-
return '';
94-
}
95-
};
83+
const profileSrc = OAUTH.find(
84+
(oauth) => oauth.key === platform.toLowerCase()
85+
)?.profile;
9686

9787
return (
9888
<Container>
@@ -112,11 +102,7 @@ const MyPage = () => {
112102
<ProfileInfo>
113103
<ProfileName>{name}님의 스페이스</ProfileName>
114104
<ProfileEmail>
115-
<StyledIcon
116-
src={EmailType(platform)}
117-
alt="emailIcon"
118-
platform={platform as keyof typeof iconSizes}
119-
/>
105+
<StyledIcon src={profileSrc} alt={platform} />
120106
<div>{email}</div>
121107
</ProfileEmail>
122108
<CountRaw>
@@ -258,15 +244,9 @@ const ProfileImage = styled.img`
258244
}
259245
`;
260246

261-
const iconSizes = {
262-
GOOGLE: 20,
263-
KAKAO: 20,
264-
NAVER: 20
265-
} as const;
266-
267-
const StyledIcon = styled.img<{ platform: keyof typeof iconSizes }>`
268-
width: ${({ platform }) => iconSizes[platform]}px;
269-
height: ${({ platform }) => iconSizes[platform]}px;
247+
const StyledIcon = styled.img`
248+
width: 20px;
249+
height: 20px;
270250
`;
271251

272252
const ProfileInfo = styled.div`

src/constants/oauth.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,21 @@ export const OAUTH = [
33
key: 'naver',
44
bgColor: '#03CF5D',
55
icon: '/assets/icons/ic_naver.svg',
6-
size: 26
6+
size: 26,
7+
profile: "/assets/icons/ic_naver.svg"
78
},
89
{
910
key: 'google',
1011
bgColor: '#FFFFFF',
1112
icon: '/assets/icons/ic_google.svg',
12-
size: 32
13+
size: 32,
14+
profile: "/assets/icons/ic_googler.svg"
1315
},
1416
{
1517
key: 'kakao',
1618
bgColor: '#FEE500',
1719
icon: '/assets/icons/ic_kakaotalk.svg',
18-
size: 38
20+
size: 38,
21+
profile: '/assets/icons/ic_kakao_profile.svg',
1922
}
2023
];

0 commit comments

Comments
 (0)