Skip to content

[Fix] toggle button error matching list#141

Merged
Mimiminz merged 4 commits intodevelopfrom
fix/toggle-button-error-matching-list
Aug 30, 2025
Merged

[Fix] toggle button error matching list#141
Mimiminz merged 4 commits intodevelopfrom
fix/toggle-button-error-matching-list

Conversation

@Mimiminz
Copy link
Contributor

☘️ 작업 내용

토글 버튼 오류를 수정했습니다.

강제로 토글 상태를 true로 바꾸는 코드가 있는 것 같아 해당 코드 삭제 후,
쿼리를 재요청해서 토글 상태에 따라 바뀌도록 수정했습니다.

추가적으로 본인 여부 확인 코드도 수정할 부분이 필요해 반영하였습니다!

테스트를 완벽하게 한 게 아니라 또 오류가 발견될 수도 있다고 생각합니다....
찾아주시면 바로 고치도록 해보겠습니다.

<Modal.Root open={open} onOpenChange={setOpen}>
<Modal.Trigger asChild>{trigger}</Modal.Trigger>

{open && (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

여기에 open을 쓴 이유가 궁금합니다

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

음 원래는 OPEN을 쓰지 않고, 개발을 진행했는데
이게 스터디 신청 리스트를 불러올 때부터 모든 유저의 프로필을 불러오게 되더라구요
그래서 클릭 시 프로필 모달을 열리게 하려고 했는데, 방법이 USER-PROFILE-MODAL만 변경하는 것과, 입력 받는 값을 변경하는 것 두 가지가 있었는데
아무래도 유저 모달이 다른 곳에서 쓰인다.....고 생각을 했는데 생각해보니 지금 당장은 신청 리스트에서 밖에 안쓰이는 것 같네요...
아무튼 입력 값을 바꾸기보다 모달 파일 하나만 수정하기 위해 여기 OPEN을 넣는 쪽으로 수정했습니다.

이 부분은 일단 동작되는 방식을 바꾸고, 나중에 더 좋은 방식으로 리팩토링을 하면 될 것 같슴다

);
}

function UserProfileBody({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UserProfileBody로 분리하신 이유가 궁금해요!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

위 이유와 비슷합니다!
그리고 추가적으로 HEADER와 BODY 이런식으로 나눴는데
아무래도 제가 테스트 할때는 API가 너무 느려서...ㅜㅜㅜ 계속 데이터 가져오는데 지연이 생기길래
로딩 중이라는 걸 보여주기 위해 HEAER, BODY 이런 식으로 나눴습니다.

Comment on lines +36 to +46
await qc.cancelQueries({ queryKey: ['userProfile', memberId] });
const prev = qc.getQueryData(['userProfile', memberId]);
if (prev && typeof prev === 'object') {
qc.setQueryData(['userProfile', memberId], {
...(prev as any),
autoMatching,
});
}

return { prev };
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

여기는 낙관적 업데이트 로직인걸까요?!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

넵 그렇습니다!!

const prev = qc.getQueryData(['userProfile', memberId]);
if (prev && typeof prev === 'object') {
qc.setQueryData(['userProfile', memberId], {
...(prev as any),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any 대신 GetUserProfileResponse 타입을 이용하는건 어떨까요?!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

좋습니다...이 부분은...나중에 리뷰 확인하면서 고치도록 하겠습니다..ㅜㅜ

interface ReservationCardProps {
participant: Participant;
isCurrentUser?: boolean;
currentMemberId?: number;
Copy link
Contributor

@aken-you aken-you Aug 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ReservationCard가 한 곳에서만 사용되는데, 거기에선 currentMemberId 타입이 number더라구요!
혹시 undefined일 경우가 있을까요?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

앗 제가 잘 이해를 못했는데,
일단 저 부분을 설명드리자면 현재 들어온 참가자의 아이디가 유저의 id와 동일한지 확인하는 코드입니다.
기존에는 boolean 값으로 넘겨줬는데
바꾼 상황에서는 currentMemberId가 reservationList에서 firstmemberId 값입니다.
이 값이 만약 유저가 참여한 상태면 멤버 아이디가 있고, 참여하지 않을 경우는 null이기 때문에 위와같이 멤버 아이디를 받고, 카드 내에서 구별하는 형식으로 변경했습니다.

Comment on lines -51 to -67
useEffect(() => {
if (!memberId || isParticipation || !userProfile) return;

const { studyApplied, autoMatching } = userProfile;

if (studyApplied && !autoMatching && !calledRef.current) {
calledRef.current = true;
patchAutoMatching(
{ memberId, autoMatching: true },
{
onError: () => {
calledRef.current = false;
},
},
);
}
}, [memberId, isParticipation, userProfile, patchAutoMatching]);
Copy link
Contributor

@aken-you aken-you Aug 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

여기 로직이 강제로 토글 상태를 true로 바꾸는 곳이었나요 😢

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

그렇습니다....😥 문제의 코드.....

const { data: userProfile } = useUserProfileQuery(memberId ?? 0);
const autoMatching = userProfile?.autoMatching ?? false;

const applied = autoMatching || isParticipation;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

주말에 조회했을 때 autoMatching이 true이고 isParticipation가 false인 경우는 어떻게 되나요?!

토요일을 기준으로 그 주차에 스터디 참여를 안했는데 (isParticipation = false)
매칭 토글을 on으로 했을 경우요!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

앗 생각해보니 isParticipation값 자체가 아예 필요 없을 것 같습니다.
매칭 토글인 autoMatching 기반으로 작동하도록 하는 게 맞을 것 같아 수정하도록 하겠습니다!

@Mimiminz Mimiminz merged commit c4ebc19 into develop Aug 30, 2025
@aken-you aken-you mentioned this pull request Aug 30, 2025
@Mimiminz Mimiminz deleted the fix/toggle-button-error-matching-list branch September 5, 2025 12:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants