From f6b569e26094c9ff3adf166e26c6d5f97905ef57 Mon Sep 17 00:00:00 2001 From: kanghaeun Date: Sun, 12 Jul 2026 19:08:32 +0900 Subject: [PATCH 1/2] =?UTF-8?q?refactor:=20=ED=86=A0=EB=84=88=EB=A8=BC?= =?UTF-8?q?=ED=8A=B8=20=EC=8B=9C=EC=9E=91=20409=20=EC=8B=9C=20match=20?= =?UTF-8?q?=ED=8E=98=EC=9D=B4=EC=A7=80=EB=A1=9C=20=EB=B3=B5=EA=B5=AC=20?= =?UTF-8?q?=EC=9D=B4=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../create/_hooks/usePostTournamentStart.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/apps/web/src/app/tournament/[id]/create/_hooks/usePostTournamentStart.ts b/apps/web/src/app/tournament/[id]/create/_hooks/usePostTournamentStart.ts index a1b522b6..7022319f 100644 --- a/apps/web/src/app/tournament/[id]/create/_hooks/usePostTournamentStart.ts +++ b/apps/web/src/app/tournament/[id]/create/_hooks/usePostTournamentStart.ts @@ -1,8 +1,11 @@ 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 { postTournamentStart } from '../_apis/postTournamentStart'; @@ -23,6 +26,20 @@ export const usePostTournamentStart = (tournamentId: number) => { }); router.push(ROUTES.TOURNAMENT_LOADING(nextTournamentId)); }, + onError: error => { + if (!isAxiosError(error) || !error.response) return; + + const { status, data } = error.response; + + if (status === 409) { + router.push(ROUTES.TOURNAMENT_MATCH(tournamentId)); + return; + } + + if (status < 500) { + toast.error(data.detail ?? '요청을 처리하지 못했어요.'); + } + }, }); return { postTournamentStartMutation, isPostTournamentStartPending }; From 4a33e36c3e4775e015bb7e9b193307c9e9c630c9 Mon Sep 17 00:00:00 2001 From: kanghaeun Date: Mon, 13 Jul 2026 18:45:22 +0900 Subject: [PATCH 2/2] =?UTF-8?q?refactor:=204xx=20=EC=97=90=EB=9F=AC=20?= =?UTF-8?q?=EB=AC=B8=EA=B5=AC=EB=A5=BC=20getApiErrorMessage=20=EC=9C=A0?= =?UTF-8?q?=ED=8B=B8=EB=A1=9C=20=ED=86=B5=EC=9D=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tournament/[id]/create/_hooks/usePostTournamentStart.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/web/src/app/tournament/[id]/create/_hooks/usePostTournamentStart.ts b/apps/web/src/app/tournament/[id]/create/_hooks/usePostTournamentStart.ts index 7022319f..b9c0cb50 100644 --- a/apps/web/src/app/tournament/[id]/create/_hooks/usePostTournamentStart.ts +++ b/apps/web/src/app/tournament/[id]/create/_hooks/usePostTournamentStart.ts @@ -7,6 +7,7 @@ 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'; @@ -29,7 +30,7 @@ export const usePostTournamentStart = (tournamentId: number) => { onError: error => { if (!isAxiosError(error) || !error.response) return; - const { status, data } = error.response; + const { status } = error.response; if (status === 409) { router.push(ROUTES.TOURNAMENT_MATCH(tournamentId)); @@ -37,7 +38,7 @@ export const usePostTournamentStart = (tournamentId: number) => { } if (status < 500) { - toast.error(data.detail ?? '요청을 처리하지 못했어요.'); + toast.error(getApiErrorMessage(error)); } }, });