-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #135 from prgrms-web-devcourse-final-project/134-f…
…eature/mypage-setting [Feature] #134 마이페이지 데이터바인딩, 알람설정 부분 구현
- Loading branch information
Showing
17 changed files
with
220 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// import { AxiosError } from 'axios' | ||
// import { APIResponse, ErrorResponse } from '~types/api' | ||
// import { axiosInstance } from '~apis/axiosInstance' | ||
|
||
// export type UpdateGangbunttaRequest = {} | ||
|
||
// export type UpdateGangbunttaResponse = Pick<APIResponse> | ||
|
||
// export const updateGangbuntta = async ( | ||
// req: UpdateGangbunttaRequest | ||
// ): Promise<APIResponse<UpdateGangbunttaResponse>> => { | ||
// try { | ||
// const { data } = await axiosInstance.patch<APIResponse<UpdateGangbunttaResponse>>(`/member`, req) | ||
// return data | ||
// } catch (error) { | ||
// if (error instanceof AxiosError) { | ||
// const { response } = error as AxiosError<ErrorResponse> | ||
|
||
// if (response) { | ||
// const { code, message } = response.data | ||
// switch (code) { | ||
// case 400: | ||
// throw new Error(message || '잘못된 요청입니다.') | ||
// case 401: | ||
// throw new Error(message || '인증에 실패했습니다.') | ||
// case 500: | ||
// throw new Error(message || '서버 오류가 발생했습니다.') | ||
// default: | ||
// throw new Error(message || '알 수 없는 오류가 발생했습니다.') | ||
// } | ||
// } | ||
// // 요청 자체가 실패한 경우 | ||
// throw new Error('네트워크 연결을 확인해주세요') | ||
// } | ||
|
||
// console.error('예상치 못한 에러:', error) | ||
// throw new Error('다시 시도해주세요') | ||
// } | ||
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { AxiosError } from 'axios' | ||
import { APIResponse, ErrorResponse, Setting } from '~types/api' | ||
import { axiosInstance } from '~apis/axiosInstance' | ||
|
||
export type UpdateSettingRequest = Pick<Setting, 'type' | 'isAgreed'> | ||
|
||
export type UpdateSettingResponse = Pick<Setting, 'notificationSettingsId' | 'memberId' | 'type' | 'isAgreed'> | ||
|
||
export const updateSetting = async (req: UpdateSettingRequest): Promise<APIResponse<UpdateSettingResponse>> => { | ||
try { | ||
const { data } = await axiosInstance.patch<APIResponse<UpdateSettingResponse>>(`/notification-settings/update`, req) | ||
console.log('알림 상태변경 : ', data.data) | ||
return data | ||
} catch (error) { | ||
if (error instanceof AxiosError) { | ||
const { response } = error as AxiosError<ErrorResponse> | ||
|
||
if (response) { | ||
const { code, message } = response.data | ||
switch (code) { | ||
case 400: | ||
throw new Error(message || '잘못된 요청입니다.') | ||
case 401: | ||
throw new Error(message || '인증에 실패했습니다.') | ||
case 500: | ||
throw new Error(message || '서버 오류가 발생했습니다.') | ||
default: | ||
throw new Error(message || '알 수 없는 오류가 발생했습니다.') | ||
} | ||
} | ||
// 요청 자체가 실패한 경우 | ||
throw new Error('네트워크 연결을 확인해주세요') | ||
} | ||
|
||
console.error('예상치 못한 에러:', error) | ||
throw new Error('다시 시도해주세요') | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.