Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FE] 지출 생성 시 나갔던 멤버를 다시 추가할 수 없는 오류 #637

Merged
merged 1 commit into from
Sep 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading