Skip to content
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
15 changes: 13 additions & 2 deletions src/pages/match/components/match-tab-pannel.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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;
Expand All @@ -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);
}
};

Expand Down