Skip to content

Commit 7bcd98f

Browse files
committed
✨ Feature : 홈화면, 마이페이지 email 받음
1 parent 97012b3 commit 7bcd98f

File tree

5 files changed

+47
-5
lines changed

5 files changed

+47
-5
lines changed

src/apis/myPage/updateGangbuntta.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// import { AxiosError } from 'axios'
2+
// import { APIResponse, ErrorResponse } from '~types/api'
3+
// import { axiosInstance } from '~apis/axiosInstance'
4+
5+
// export type UpdateGangbunttaRequest = {}
6+
7+
// export type UpdateGangbunttaResponse = Pick<APIResponse>
8+
9+
// export const updateGangbuntta = async (
10+
// req: UpdateGangbunttaRequest
11+
// ): Promise<APIResponse<UpdateGangbunttaResponse>> => {
12+
// try {
13+
// const { data } = await axiosInstance.patch<APIResponse<UpdateGangbunttaResponse>>(`/member`, req)
14+
// return data
15+
// } catch (error) {
16+
// if (error instanceof AxiosError) {
17+
// const { response } = error as AxiosError<ErrorResponse>
18+
19+
// if (response) {
20+
// const { code, message } = response.data
21+
// switch (code) {
22+
// case 400:
23+
// throw new Error(message || '잘못된 요청입니다.')
24+
// case 401:
25+
// throw new Error(message || '인증에 실패했습니다.')
26+
// case 500:
27+
// throw new Error(message || '서버 오류가 발생했습니다.')
28+
// default:
29+
// throw new Error(message || '알 수 없는 오류가 발생했습니다.')
30+
// }
31+
// }
32+
// // 요청 자체가 실패한 경우
33+
// throw new Error('네트워크 연결을 확인해주세요')
34+
// }
35+
36+
// console.error('예상치 못한 에러:', error)
37+
// throw new Error('다시 시도해주세요')
38+
// }
39+
// }

src/apis/register/createRegister.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export type CreateRegisterResponse = Pick<
1515
export const createRegister = async (req: CreateRegisterRequest): Promise<APIResponse<CreateRegisterResponse>> => {
1616
try {
1717
const response = await axiosInstance.post<APIResponse<CreateRegisterResponse>>(`/member/join`, req)
18-
18+
console.log(response)
1919
// 토큰 추출 및 저장
2020
const accessToken = (response.headers['authorization'] as string).split('Bearer ')[1]
2121

src/pages/HomePage/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ function HomeContent() {
3333

3434
<S.Visual>
3535
<Typo24 $weight='700' $textAlign='center'>
36-
오늘은 {data && FAMILY_ROLE[data.familyRole as keyof typeof FAMILY_ROLE]}
36+
오늘은 {data?.familyRole ? FAMILY_ROLE[data.familyRole] : ''}
3737
</Typo24>
3838
<Typo24 $weight='700' $textAlign='center'>
3939
산책가는 날!

src/pages/RegisterPage/Register/index.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { useSearchParams } from 'react-router-dom'
1717
import { createRegister } from '~apis/register/createRegister'
1818
import { FamilyRole } from '~types/common'
1919
import { useEffect } from 'react'
20+
import { FAMILY_ROLE } from '~constants/familyRole'
2021

2122
export default function Register() {
2223
const { ownerProfile, setOwnerProfile } = useOwnerProfileStore()
@@ -33,15 +34,17 @@ export default function Register() {
3334
showToast(alertMessage)
3435
return
3536
}
36-
3737
try {
38+
const familyRoleKey = Object.keys(FAMILY_ROLE).find(
39+
key => FAMILY_ROLE[key as keyof typeof FAMILY_ROLE] === ownerProfile.familyRole
40+
)
3841
const registerData = {
3942
email,
4043
provider,
4144
name: ownerProfile.name,
4245
gender: ownerProfile.gender as 'MALE' | 'FEMALE',
4346
address: ownerProfile.address,
44-
familyRole: ownerProfile.familyRole as FamilyRole,
47+
familyRole: familyRoleKey as FamilyRole,
4548
profileImg: ownerProfile.profileImg || '',
4649
}
4750

src/stores/ownerProfileStore.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ export const useOwnerProfileStore = create<OwnerProfileStore>(set => ({
2121
set(state => ({
2222
ownerProfile: { ...state.ownerProfile, ...profile },
2323
})),
24-
}))
24+
}))

0 commit comments

Comments
 (0)