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
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import { useMutation } from '@tanstack/react-query';
import { isAxiosError } from 'axios';
import { useRouter } from 'next/navigation';
import { toast } from 'sonner';

import { ANALYTICS_EVENT } from '@/consts/analytics';
import { ROUTES } from '@/consts/route';
import type { ApiErrorResponseT } from '@/types/api';
import { logAnalyticsEvent } from '@/utils/analytics';
import { getApiErrorMessage } from '@/utils/getApiErrorMessage';

import { postTournamentStart } from '../_apis/postTournamentStart';

Expand All @@ -23,6 +27,20 @@ export const usePostTournamentStart = (tournamentId: number) => {
});
router.push(ROUTES.TOURNAMENT_LOADING(nextTournamentId));
},
onError: error => {
if (!isAxiosError<ApiErrorResponseT>(error) || !error.response) return;

const { status } = error.response;

if (status === 409) {
router.push(ROUTES.TOURNAMENT_MATCH(tournamentId));
return;
}

if (status < 500) {
toast.error(getApiErrorMessage(error));
Comment on lines +40 to +41

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

토스트 처리를 4xx 응답으로 제한해 주세요.

status < 500은 3xx 또는 1xx 응답까지 포함하므로, PR 요구사항인 “409 이외의 4xx 오류만 토스트 표시”보다 범위가 넓습니다. status >= 400 && status < 500으로 제한하는 편이 안전합니다.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/web/src/app/tournament/`[id]/create/_hooks/usePostTournamentStart.ts
around lines 40 - 41, Update the status condition in the error handling around
getApiErrorMessage to show a toast only for 4xx responses, using a range check
from 400 inclusive to 500 exclusive; preserve the existing behavior that
excludes status 409 if handled elsewhere.

}
},
});

return { postTournamentStartMutation, isPostTournamentStartPending };
Expand Down
Loading