Skip to content

Commit

Permalink
fix: 행사에 나갔던 멤버 추가할 수 없던 오류 수정 (#637)
Browse files Browse the repository at this point in the history
  • Loading branch information
Todari authored Sep 26, 2024
1 parent b771c52 commit a930ad1
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions client/src/hooks/useMembersStep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -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;
Expand All @@ -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();
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit a930ad1

Please sign in to comment.