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(() => { diff --git a/client/src/types/serviceType.ts b/client/src/types/serviceType.ts index a90e77317..2172bd3f3 100644 --- a/client/src/types/serviceType.ts +++ b/client/src/types/serviceType.ts @@ -59,12 +59,19 @@ export interface EventCreationData { password: Password; } -export interface Event { - eventName: EventName; +export type BankAccount = { bankName: string; accountNumber: string; +}; + +export type Event = BankAccount & { + eventName: EventName; createdByGuest: boolean; -} +}; + +export type User = BankAccount & { + nickname: Nickname; +}; export interface Report { memberId: number;