From efceb01b69573c68977b5d07676db4f29d648e62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=A7=84=ED=98=B8?= Date: Sat, 7 Dec 2024 21:25:31 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EB=B0=B1=EC=97=94=EB=93=9C=20=EA=B3=84?= =?UTF-8?q?=EC=A2=8C=EB=B2=88=ED=98=B8=20=EA=B5=AC=EC=A1=B0=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD=EC=9C=BC=EB=A1=9C=20=EC=9D=B8=ED=95=9C=20api=20?= =?UTF-8?q?=EB=B3=80=EB=8F=99=EC=9D=84=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/src/apis/request/event.ts | 19 +++++++++++--- ...chEvent.ts => useRequestPatchEventName.ts} | 8 +++--- .../queries/event/useRequestPatchUser.ts | 25 +++++++++++++++++++ client/src/hooks/useAccount.ts | 6 ++--- 4 files changed, 47 insertions(+), 11 deletions(-) rename client/src/hooks/queries/event/{useRequestPatchEvent.ts => useRequestPatchEventName.ts} (69%) create mode 100644 client/src/hooks/queries/event/useRequestPatchUser.ts diff --git a/client/src/apis/request/event.ts b/client/src/apis/request/event.ts index aa53d0796..800a6e8d0 100644 --- a/client/src/apis/request/event.ts +++ b/client/src/apis/request/event.ts @@ -1,4 +1,4 @@ -import {Event, EventCreationData, EventId, EventName} from 'types/serviceType'; +import {Event, EventCreationData, EventId, EventName, User} from 'types/serviceType'; import {WithErrorHandlingStrategy} from '@errors/RequestGetError'; import {ADMIN_API_PREFIX, USER_API_PREFIX} from '@apis/endpointPrefix'; @@ -31,14 +31,25 @@ export const requestGetEvent = async ({eventId, ...props}: WithEventId; + eventName: string; }; -export const requestPatchEvent = async ({eventId, eventOutline}: RequestPatchEvent) => { +export const requestPatchEventName = async ({eventId, eventName}: RequestPatchEvent) => { return requestPatch({ endpoint: `${ADMIN_API_PREFIX}/${eventId}`, body: { - ...eventOutline, + eventName, + }, + }); +}; + +export type RequestPatchUser = Partial; + +export const requestPatchUser = async (args: RequestPatchUser) => { + return requestPatch({ + endpoint: `/api/users`, + body: { + ...args, }, }); }; diff --git a/client/src/hooks/queries/event/useRequestPatchEvent.ts b/client/src/hooks/queries/event/useRequestPatchEventName.ts similarity index 69% rename from client/src/hooks/queries/event/useRequestPatchEvent.ts rename to client/src/hooks/queries/event/useRequestPatchEventName.ts index e09a19c8b..56c1bce43 100644 --- a/client/src/hooks/queries/event/useRequestPatchEvent.ts +++ b/client/src/hooks/queries/event/useRequestPatchEventName.ts @@ -2,19 +2,19 @@ import type {Event} from 'types/serviceType'; import {useMutation, useQueryClient} from '@tanstack/react-query'; -import {requestPatchEvent} from '@apis/request/event'; +import {requestPatchEventName} from '@apis/request/event'; import getEventIdByUrl from '@utils/getEventIdByUrl'; import QUERY_KEYS from '@constants/queryKeys'; -const useRequestPatchEventOutline = () => { +const useRequestPatchEventName = () => { const eventId = getEventIdByUrl(); const queryClient = useQueryClient(); const {mutateAsync, ...rest} = useMutation({ - mutationFn: (eventOutline: Partial) => requestPatchEvent({eventId, eventOutline}), + mutationFn: (eventName: string) => requestPatchEventName({eventId, eventName}), onSuccess: () => { queryClient.invalidateQueries({ queryKey: [QUERY_KEYS.event], @@ -28,4 +28,4 @@ const useRequestPatchEventOutline = () => { }; }; -export default useRequestPatchEventOutline; +export default useRequestPatchEventName; diff --git a/client/src/hooks/queries/event/useRequestPatchUser.ts b/client/src/hooks/queries/event/useRequestPatchUser.ts new file mode 100644 index 000000000..6ebfc70cf --- /dev/null +++ b/client/src/hooks/queries/event/useRequestPatchUser.ts @@ -0,0 +1,25 @@ +import {useMutation, useQueryClient} from '@tanstack/react-query'; + +import {RequestPatchUser, requestPatchUser} from '@apis/request/event'; + +import QUERY_KEYS from '@constants/queryKeys'; + +const useRequestPatchUser = () => { + const queryClient = useQueryClient(); + + const {mutateAsync, ...rest} = useMutation({ + mutationFn: (args: RequestPatchUser) => requestPatchUser({...args}), + onSuccess: () => { + queryClient.invalidateQueries({ + queryKey: [QUERY_KEYS.event], + }); + }, + }); + + return { + patchUser: mutateAsync, + ...rest, + }; +}; + +export default useRequestPatchUser; diff --git a/client/src/hooks/useAccount.ts b/client/src/hooks/useAccount.ts index c472270ec..99f882c52 100644 --- a/client/src/hooks/useAccount.ts +++ b/client/src/hooks/useAccount.ts @@ -4,8 +4,8 @@ import validateAccountNumber from '@utils/validate/validateAccountNumber'; import RULE from '@constants/rule'; -import useRequestPatchEvent from './queries/event/useRequestPatchEvent'; import useRequestGetEvent from './queries/event/useRequestGetEvent'; +import useRequestPatchUser from './queries/event/useRequestPatchUser'; const useAccount = () => { const {bankName, accountNumber} = useRequestGetEvent(); @@ -20,7 +20,7 @@ const useAccount = () => { setAccountNumber(accountNumber); }, [bankName, accountNumber]); - const {patchEventOutline} = useRequestPatchEvent(); + const {patchUser} = useRequestPatchUser(); const selectBank = (name: string) => { setBankName(name); @@ -56,7 +56,7 @@ const useAccount = () => { }; const enrollAccount = async () => { - await patchEventOutline({bankName: bankNameState, accountNumber: accountNumberState}); + await patchUser({bankName: bankNameState, accountNumber: accountNumberState}); }; useEffect(() => {