diff --git a/src/pages/match/components/match-tab-pannel.tsx b/src/pages/match/components/match-tab-pannel.tsx index 8efc6483..8237ed47 100644 --- a/src/pages/match/components/match-tab-pannel.tsx +++ b/src/pages/match/components/match-tab-pannel.tsx @@ -1,3 +1,4 @@ +import { matchMutations } from '@apis/match/match-mutations'; import Card from '@components/card/match-card/card'; import type { GroupCardProps, SingleCardProps } from '@components/card/match-card/types/card'; import { getColorType } from '@components/card/match-card/utils/get-color-type'; @@ -6,6 +7,7 @@ import { cn } from '@libs/cn'; import { CLICKABLE_STATUS_MAP } from '@pages/match/constants/matching'; import { getCardColor, statusToCategory } from '@pages/match/utils/match-status'; import { ROUTES } from '@routes/routes-config'; +import { useMutation } from '@tanstack/react-query'; import { useNavigate } from 'react-router-dom'; type MatchableCardProps = SingleCardProps | GroupCardProps; @@ -18,13 +20,22 @@ interface MatchTabPanelProps { const MatchTabPanel = ({ cards, filter }: MatchTabPanelProps) => { const navigate = useNavigate(); + const patchStageMutation = useMutation(matchMutations.MATCH_STAGE()); + const filteredCards = filter === '전체' ? cards : cards.filter((card) => statusToCategory(card.status) === filter); - const handleCardClick = (card: MatchableCardProps) => { + const handleCardClick = async (card: MatchableCardProps) => { const query = CLICKABLE_STATUS_MAP[card.status ?? '']; - if (query) { + if (!query) return; + + try { + if (card.status === '승인 완료') { + await patchStageMutation.mutateAsync(card.id); + } navigate(`${ROUTES.RESULT(card.id.toString())}?type=${query}&cardtype=${card.type}`); + } catch (error) { + console.error('매칭 상태 전환 실패', error); } };