From 446abd7998862659a9a65f5baba46c2880f099de Mon Sep 17 00:00:00 2001 From: KIM HYOJUNG Date: Sun, 13 Oct 2024 13:06:23 +0900 Subject: [PATCH] fix(fe): fix contestdenied message (#2155) * fix(fe): fix contestdenied message * fix(fe): fix contestdenied message delete message * fix(fe): fix contestdenied message ifelse --- .../[contestId]/@tabs/problem/page.tsx | 42 +++++++++++++++---- 1 file changed, 35 insertions(+), 7 deletions(-) diff --git a/apps/frontend/app/(main)/contest/[contestId]/@tabs/problem/page.tsx b/apps/frontend/app/(main)/contest/[contestId]/@tabs/problem/page.tsx index 46b8202ff0..274c206d61 100644 --- a/apps/frontend/app/(main)/contest/[contestId]/@tabs/problem/page.tsx +++ b/apps/frontend/app/(main)/contest/[contestId]/@tabs/problem/page.tsx @@ -1,6 +1,9 @@ import DataTable from '@/components/DataTable' import { fetcherWithAuth } from '@/lib/utils' +import { getStatusWithStartEnd } from '@/lib/utils' +import { dateFormatter } from '@/lib/utils' import type { ContestProblem } from '@/types/type' +import type { Contest } from '@/types/type' import { columns } from './_components/Columns' interface ContestProblemProps { @@ -21,17 +24,42 @@ export default async function ContestProblem({ params }: ContestProblemProps) { }) if (!res.ok) { - const { statusCode, message }: { statusCode: number; message: string } = - await res.json() + const { statusCode }: { statusCode: number } = await res.json() + + const contest: Contest = await fetcherWithAuth + .get(`contest/${contestId}`) + .then((res) => res.json()) + + const formattedStartTime = dateFormatter( + contest.startTime, + 'YYYY-MM-DD HH:mm:ss' + ) + const formattedEndTime = dateFormatter( + contest.endTime, + 'YYYY-MM-DD HH:mm:ss' + ) + const contestStatus = getStatusWithStartEnd( + formattedStartTime, + formattedEndTime + ) + + let displayMessage = '' + + if (statusCode === 401) { + displayMessage = 'Log in first to check the problems.' + } else { + if (contestStatus === 'ongoing') { + displayMessage = 'Please register first to view the problem list' + } else { + displayMessage = 'You can access after the contest started' + } + } + return (

Access Denied

-

- {statusCode === 401 - ? 'Log in first to check the problems.' - : message} -

+

{displayMessage}

)