Skip to content

Commit ec0c8b5

Browse files
authored
Merge pull request #335 from JEOLLOGA/feat/#333/my
[FEAT] λ§ˆμ΄νŽ˜μ΄μ§€ μ—…λ°μ΄νŠΈ
2 parents e964851 + fccc234 commit ec0c8b5

File tree

6 files changed

+133
-18
lines changed

6 files changed

+133
-18
lines changed

β€Žsrc/apis/user/axios.tsβ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import instance from '@apis/instance';
22

3-
import { OnboardingDataV2, OnboardingResponseV2, UserNicknameResponse } from './type';
3+
import { OnboardingDataV2, OnboardingResponseV2 } from './type';
44

55
export const postOnboardingData = async (data: OnboardingDataV2): Promise<OnboardingResponseV2> => {
66
const response = await instance.post<OnboardingResponseV2>('/v2/user/onboarding', data);
77
return response.data;
88
};
99

1010
export const getMyPage = async () => {
11-
const res = await instance.get('/v2/user/mypage');
11+
const res = await instance.get('/v2/user/new-mypage');
1212
return res.data;
1313
};

β€Žsrc/apis/user/index.tsβ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { useMutation, useQuery } from '@tanstack/react-query';
22

33
import { ApiResponse } from './../response';
44
import { getMyPage, postOnboardingData } from './axios';
5-
import { MyPageType, OnboardingDataV2, OnboardingResponseV2 } from './type';
5+
import { MyPageResponse, OnboardingDataV2, OnboardingResponseV2 } from './type';
66

77
export const usePostOnboardingData = () => {
88
return useMutation<OnboardingResponseV2, Error, OnboardingDataV2>({
@@ -11,7 +11,7 @@ export const usePostOnboardingData = () => {
1111
};
1212

1313
export const useGetMyPage = () => {
14-
const { data, isLoading, isError } = useQuery<ApiResponse<MyPageType>>({
14+
const { data, isLoading, isError } = useQuery<ApiResponse<MyPageResponse>>({
1515
queryKey: ['myPage'],
1616
queryFn: () => getMyPage(),
1717
});

β€Žsrc/apis/user/type.tsβ€Ž

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,11 @@ export interface MyPageType {
2323
religion?: string;
2424
hasExperience?: boolean;
2525
}
26+
27+
export interface MyPageResponse {
28+
type: string | null;
29+
typeContent: string | null;
30+
nickname: string;
31+
email: string;
32+
hasType: boolean;
33+
}

β€Žsrc/app/myPage/myPage.css.tsβ€Ž

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,53 @@ export const modalOverlay = style({
2424
alignItems: 'center',
2525
marginTop: '-1.2rem',
2626
});
27+
28+
export const resultSection = style({
29+
marginTop: '3.7rem',
30+
marginBottom: '6rem',
31+
display: 'flex',
32+
flexDirection: 'column',
33+
alignItems: 'center',
34+
});
35+
36+
export const cardWrapper = style({
37+
display: 'flex',
38+
justifyContent: 'center',
39+
});
40+
41+
export const profileInfoBox = style({
42+
marginTop: '1.2rem',
43+
display: 'flex',
44+
flexDirection: 'column',
45+
alignItems: 'center',
46+
gap: '0.2rem',
47+
marginBottom: '2.4rem',
48+
});
49+
50+
export const nameRow = style({
51+
display: 'flex',
52+
alignItems: 'center',
53+
gap: '0.2rem',
54+
...theme.FONTS.h5Sb16,
55+
color: theme.COLORS.black,
56+
});
57+
58+
export const typeContent = style({
59+
color: theme.COLORS.primary600,
60+
});
61+
62+
export const nickname = style({
63+
color: theme.COLORS.black,
64+
});
65+
66+
export const email = style({
67+
...theme.FONTS.f3R10,
68+
color: theme.COLORS.gray7,
69+
});
70+
71+
export const buttonGroup = style({
72+
display: 'flex',
73+
gap: '0.9rem',
74+
justifyContent: 'center',
75+
width: '100%',
76+
});

β€Žsrc/app/myPage/page.tsxβ€Ž

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,65 @@
11
'use client';
22
import { usePostLogout, usePostWithdraw } from '@apis/auth';
33
import { useGetMyPage } from '@apis/user';
4+
import PopupBtn from '@components/common/button/popupBtn/PopupBtn';
45
import ModalContainer from '@components/common/modal/ModalContainer';
56
import PageName from '@components/common/pageName/PageName';
67
import ExceptLayout from '@components/except/exceptLayout/ExceptLayout';
78
import Footer from '@components/footer/Footer';
9+
import ResultCard from '@components/test/resultCard/ResultCard';
810
import UserInfo from '@components/userInfo/userInfo';
11+
import { TestType } from '@constants/test';
12+
import { useRouter } from 'next/navigation';
913
import { useState } from 'react';
1014
import useEventLogger from 'src/gtm/hooks/useEventLogger';
1115

1216
import * as styles from './myPage.css';
1317

18+
// const MOCK_USER_DATA_DONE = {
19+
// type: 'IAJ',
20+
// typeContent: 'μž”μž”ν•œ ν˜Έμˆ˜ν˜• λͺ©νƒμ΄',
21+
// nickname: '배영경',
22+
// email: 'jjeolloga@gmail.com',
23+
// hasType: true,
24+
// };
25+
26+
// const MOCK_USER_DATA_NONE = {
27+
// type: null,
28+
// typeContent: null,
29+
// nickname: '배영경',
30+
// email: 'jjeolloga@gmail.com',
31+
// hasType: false,
32+
// };
33+
1434
const MyPage = () => {
35+
const router = useRouter();
1536
const [isLogoutModalOpen, setIsLogoutModalOpen] = useState(false);
1637
const [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false);
1738

39+
// const userData = MOCK_USER_DATA_DONE;
40+
// const userData = MOCK_USER_DATA_NONE;
41+
1842
const postLogout = usePostLogout();
1943
const postWithdraw = usePostWithdraw();
2044

2145
const { data, isLoading, isError } = useGetMyPage();
46+
const userData = data?.data;
2247

2348
const { logClickEvent } = useEventLogger('my');
2449

50+
const handleGoToTest = () => {
51+
router.push('/test');
52+
};
53+
54+
const handleRecommend = () => {
55+
router.push('/');
56+
// router.push('/curation');
57+
};
58+
59+
const handleReTest = () => {
60+
router.push('/test');
61+
};
62+
2563
const handleLogoutClick = () => {
2664
setIsLogoutModalOpen(true);
2765

@@ -68,10 +106,42 @@ const MyPage = () => {
68106
return <ExceptLayout type="networkError" />;
69107
}
70108

109+
if (!userData) {
110+
return <ExceptLayout type="networkError" />;
111+
}
112+
71113
return (
72114
<div className={styles.myPageWrapper}>
73115
<div className={styles.userInfoContainer}>
74116
<PageName title="λ§ˆμ΄νŽ˜μ΄μ§€" />
117+
118+
<section className={styles.resultSection}>
119+
<div className={styles.cardWrapper}>
120+
<ResultCard color="NONE" type={(userData.type as TestType) || undefined} />
121+
</div>
122+
123+
<div className={styles.profileInfoBox}>
124+
<p className={styles.nameRow}>
125+
{userData.hasType && (
126+
<span className={styles.typeContent}>{userData.typeContent}</span>
127+
)}
128+
<span className={styles.nickname}>{userData.nickname}</span> λ‹˜
129+
</p>
130+
<p className={styles.email}>{userData.email}</p>
131+
</div>
132+
133+
<div className={styles.buttonGroup}>
134+
{userData.hasType ? (
135+
<>
136+
<PopupBtn color="green" label="절 μΆ”μ²œλ°›κΈ°" onClick={handleRecommend} />
137+
<PopupBtn color="gray" label="ν…ŒμŠ€νŠΈ λ‹€μ‹œν•˜κΈ°" onClick={handleReTest} />
138+
</>
139+
) : (
140+
<PopupBtn color="green" label="μ„±ν–₯ ν…ŒμŠ€νŠΈν•˜κΈ°" onClick={handleGoToTest} />
141+
)}
142+
</div>
143+
</section>
144+
75145
<UserInfo
76146
data={data?.data}
77147
onLogoutClick={handleLogoutClick}

β€Žsrc/components/userInfo/userInfo.tsxβ€Ž

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@ import useEventLogger from 'src/gtm/hooks/useEventLogger';
33
import infoContainerStyle from './userInfo.css';
44
import AccountActions from './userInfoContent/accountAction/AccountAction';
55
import HelpSection from './userInfoContent/helpContent/HelpContent';
6-
import TopInfo from './userInfoContent/nameContent/NameContent';
7-
import MemberInfo from './userInfoContent/userDetailInfo.tsx/UserDetailInfo';
8-
import UserInfoSection from './userInfoContent/userInfoSection/userInfoSection';
96

107
interface UserInfoProps {
118
data?: {
@@ -37,17 +34,7 @@ const UserInfo = ({ data, onLogoutClick, onDeleteClick }: UserInfoProps) => {
3734

3835
return (
3936
<div className={infoContainerStyle}>
40-
<TopInfo nickname={data.nickname} email={data.email} />
41-
<UserInfoSection title="νšŒμ›μ •λ³΄">
42-
<MemberInfo
43-
ageRange={data.ageRange || '정보 μ—†μŒ'}
44-
gender={data.gender || '정보 μ—†μŒ'}
45-
religion={data.religion || '정보 μ—†μŒ'}
46-
/>
47-
</UserInfoSection>
48-
<UserInfoSection title="도움말">
49-
<HelpSection onNoticeClick={handleNoticeClick} onQuestionClick={handleQuestionClick} />
50-
</UserInfoSection>
37+
<HelpSection onNoticeClick={handleNoticeClick} onQuestionClick={handleQuestionClick} />
5138
<AccountActions onLogoutClick={onLogoutClick} onDeleteClick={onDeleteClick} />
5239
</div>
5340
);

0 commit comments

Comments
Β (0)