From 8c4229f59023fdc3a1685df45e9114c20efcff23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=8B=E1=85=B5=E1=84=90=E1=85=A2=E1=84=92=E1=85=AE?= =?UTF-8?q?=E1=86=AB?= Date: Thu, 26 Sep 2024 12:20:16 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=ED=96=89=EC=82=AC=EC=97=90=20=EB=82=98?= =?UTF-8?q?=EA=B0=94=EB=8D=98=20=EB=A9=A4=EB=B2=84=20=EC=B6=94=EA=B0=80?= =?UTF-8?q?=ED=95=A0=20=EC=88=98=20=EC=97=86=EB=8D=98=20=EC=98=A4=EB=A5=98?= =?UTF-8?q?=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/src/hooks/useMembersStep.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/client/src/hooks/useMembersStep.ts b/client/src/hooks/useMembersStep.ts index 9cd68f2a4..8f8aeb8f0 100644 --- a/client/src/hooks/useMembersStep.ts +++ b/client/src/hooks/useMembersStep.ts @@ -2,7 +2,7 @@ import {useEffect, useState} from 'react'; import {useNavigate} from 'react-router-dom'; import {BillInfo} from '@pages/AddBillFunnel/AddBillFunnel'; -import {Member} from 'types/serviceType'; +import {Member, AllMembers} from 'types/serviceType'; import getEventIdByUrl from '@utils/getEventIdByUrl'; @@ -11,6 +11,7 @@ import REGEXP from '@constants/regExp'; import useRequestPostMembers from './queries/member/useRequestPostMembers'; import useRequestPostBill from './queries/bill/useRequestPostBill'; import {BillStep} from './useAddBillFunnel'; +import useRequestGetAllMembers from './queries/member/useRequestGetAllMembers'; interface Props { billInfo: BillInfo; @@ -23,6 +24,7 @@ const useMembersStep = ({billInfo, setBillInfo, currentMembers, setStep}: Props) const [errorMessage, setErrorMessage] = useState(''); const [nameInput, setNameInput] = useState(''); + const {members: allMembers} = useRequestGetAllMembers(); const {postMembersAsync, isPending: isPendingPostMembers} = useRequestPostMembers(); const {postBill, isSuccess: isSuccessPostBill, isPending: isPendingPostBill} = useRequestPostBill(); @@ -50,7 +52,7 @@ const useMembersStep = ({billInfo, setBillInfo, currentMembers, setStep}: Props) const canSubmitMembers = billInfo.members.length !== 0; const setBillInfoMemberWithId = (name: string) => { - const existingMember = currentMembers.find(currentMember => currentMember.name === name); + const existingMember = allMembers.find(currentMember => currentMember.name === name); if (existingMember) { setBillInfo(prev => ({...prev, members: [...prev.members, {id: existingMember.id, name: name}]})); } else {