diff --git a/src/apis/fetch.ts b/src/apis/fetch.ts index ce20ac7..6f83f68 100644 --- a/src/apis/fetch.ts +++ b/src/apis/fetch.ts @@ -74,13 +74,21 @@ class Fetch { body: JSON.stringify(body), }); - const data = await response.json(); - if (!response.ok) { + const data = await response.json(); throw new ResponseError(data); } - return data as TData; + // 응답 본문이 있는지 확인 + const text = await response.text(); + if (text) { + // 응답 본문이 있으면 JSON으로 파싱 + const data = JSON.parse(text); + return data as TData; + } else { + // 응답 본문이 없으면 null 반환 + return null; + } } async delete(path: string, body?: object): Promise { diff --git a/src/apis/profile/useProfile.ts b/src/apis/profile/useProfile.ts index 888259c..3d503b7 100644 --- a/src/apis/profile/useProfile.ts +++ b/src/apis/profile/useProfile.ts @@ -1,18 +1,13 @@ import { useMutation } from '@tanstack/react-query'; -import { PresignedURLResponse, ProfileResponse } from '@interfaces/api/profile'; +import { + ModifyProfileRequestDTO, + PresignedURLResponse, + ProfileResponse, +} from '@interfaces/api/profile'; import client from '@apis/fetch'; -// export interface profileRequestDTO { -// status?: 'VOTING' | 'CLOSED'; -// keyword_id?: number; -// page?: number; -// size?: number; -// sort?: string; -// side?: 'TOPIC_A' | 'TOPIC_B'; -// } - const getProfile = () => { return client.get('/members/profile'); }; @@ -35,6 +30,13 @@ const updateProfileImgURL = (profileImgURL: string) => { }); }; +const modifyProfile = (req: ModifyProfileRequestDTO) => { + return client.put({ + path: `/members/profile/information`, + body: req, + }); +}; + const deleteProfileImg = () => { return client.delete(`/members/profile/image`); }; @@ -51,4 +53,14 @@ const useDeleteProfileImg = () => { return useMutation({ mutationFn: () => deleteProfileImg() }); }; -export { getProfile, useGetPresignedURL, useUpdateProfileImgURL, useDeleteProfileImg }; +const useModifyProfile = () => { + return useMutation({ mutationFn: modifyProfile }); +}; + +export { + getProfile, + useGetPresignedURL, + useUpdateProfileImgURL, + useDeleteProfileImg, + useModifyProfile, +}; diff --git a/src/components/commons/Modal/ActionModalButton.tsx b/src/components/commons/Modal/ActionModalButton.tsx index 0577c1a..20e85f1 100644 --- a/src/components/commons/Modal/ActionModalButton.tsx +++ b/src/components/commons/Modal/ActionModalButton.tsx @@ -1,5 +1,7 @@ import React from 'react'; +import { colors } from '@styles/theme'; + import { Row } from '../Flex/Flex'; import Text from '../Text/Text'; @@ -14,7 +16,7 @@ const ActionModalButton = ({ handleClick, Icon, label }: ActionModalButtonProps)