diff --git a/apps/frontend/app/admin/contest/[id]/(overall)/@tabs/submission/_components/Columns.tsx b/apps/frontend/app/admin/contest/[id]/(overall)/@tabs/submission/_components/Columns.tsx index 4d41230892..44dcacd3c3 100644 --- a/apps/frontend/app/admin/contest/[id]/(overall)/@tabs/submission/_components/Columns.tsx +++ b/apps/frontend/app/admin/contest/[id]/(overall)/@tabs/submission/_components/Columns.tsx @@ -1,7 +1,7 @@ 'use client' import type { OverallSubmission } from '@/app/admin/contest/utils' -import { cn } from '@/lib/utils' +import { cn, getResultColor } from '@/lib/utils' import type { ColumnDef } from '@tanstack/react-table' import dayjs from 'dayjs' @@ -51,11 +51,7 @@ export const columns: ColumnDef[] = [
{row.getValue('result')} diff --git a/apps/frontend/app/admin/contest/[id]/_components/SubmissionDetailAdmin.tsx b/apps/frontend/app/admin/contest/[id]/_components/SubmissionDetailAdmin.tsx index 343753bb1e..7c7d111b63 100644 --- a/apps/frontend/app/admin/contest/[id]/_components/SubmissionDetailAdmin.tsx +++ b/apps/frontend/app/admin/contest/[id]/_components/SubmissionDetailAdmin.tsx @@ -11,7 +11,7 @@ import { TableRow } from '@/components/ui/table' import { GET_SUBMISSION } from '@/graphql/submission/queries' -import { dateFormatter } from '@/lib/utils' +import { dateFormatter, getResultColor } from '@/lib/utils' import type { Language } from '@/types/type' import { useQuery } from '@apollo/client' @@ -51,13 +51,7 @@ export default function SubmissionDetailAdmin({

Result

-

+

{submission?.result}

@@ -100,13 +94,7 @@ export default function SubmissionDetailAdmin({ {submission?.testcaseResult.map((item) => ( {item.id} - + {item.result} {item.cpuTime} ms diff --git a/apps/frontend/app/admin/contest/[id]/participant/[userId]/_components/SubmissionColumns.tsx b/apps/frontend/app/admin/contest/[id]/participant/[userId]/_components/SubmissionColumns.tsx index 8fc1c6cae3..afd339a018 100644 --- a/apps/frontend/app/admin/contest/[id]/participant/[userId]/_components/SubmissionColumns.tsx +++ b/apps/frontend/app/admin/contest/[id]/participant/[userId]/_components/SubmissionColumns.tsx @@ -1,7 +1,7 @@ 'use client' import type { UserSubmission } from '@/app/admin/contest/utils' -import { cn } from '@/lib/utils' +import { cn, getResultColor } from '@/lib/utils' import type { ColumnDef } from '@tanstack/react-table' import dayjs from 'dayjs' @@ -23,11 +23,7 @@ export const submissionColumns: ColumnDef[] = [
{row.getValue('submissionResult')} diff --git a/apps/frontend/app/admin/problem/[id]/_components/Columns.tsx b/apps/frontend/app/admin/problem/[id]/_components/Columns.tsx index 3f8de83be0..6f5c493cdf 100644 --- a/apps/frontend/app/admin/problem/[id]/_components/Columns.tsx +++ b/apps/frontend/app/admin/problem/[id]/_components/Columns.tsx @@ -1,6 +1,6 @@ 'use client' -import { dateFormatter } from '@/lib/utils' +import { dateFormatter, getResultColor } from '@/lib/utils' import type { SubmissionItem } from '@/types/type' import type { ColumnDef } from '@tanstack/react-table' @@ -25,12 +25,10 @@ export const columns: ColumnDef[] = [ header: () => 'Result', accessorKey: 'result', cell: ({ row }) => { - return row.original.result === 'Accepted' ? ( -

{row.original.result}

- ) : row.original.result === 'Judging' ? ( -

{row.original.result}

- ) : ( -

{row.original.result}

+ return ( +

+ {row.original.result} +

) } }, diff --git a/apps/frontend/app/contest/[contestId]/problem/[problemId]/submission/_components/Columns.tsx b/apps/frontend/app/contest/[contestId]/problem/[problemId]/submission/_components/Columns.tsx index aa4904a969..df60f2901b 100644 --- a/apps/frontend/app/contest/[contestId]/problem/[problemId]/submission/_components/Columns.tsx +++ b/apps/frontend/app/contest/[contestId]/problem/[problemId]/submission/_components/Columns.tsx @@ -1,6 +1,6 @@ 'use client' -import { dateFormatter } from '@/lib/utils' +import { dateFormatter, getResultColor } from '@/lib/utils' import type { SubmissionItem } from '@/types/type' import type { ColumnDef } from '@tanstack/react-table' @@ -19,13 +19,10 @@ export const columns: ColumnDef[] = [ header: () => 'Result', accessorKey: 'result', cell: ({ row }) => { - return row.original.result === 'Accepted' ? ( -

{row.original.result}

- ) : row.original.result === 'Judging' || - row.original.result === 'Blind' ? ( -

{row.original.result}

- ) : ( -

{row.original.result}

+ return ( +

+ {row.original.result} +

) } }, diff --git a/apps/frontend/app/contest/[contestId]/problem/[problemId]/submission/_components/SubmissionDetail.tsx b/apps/frontend/app/contest/[contestId]/problem/[problemId]/submission/_components/SubmissionDetail.tsx index 8da06ebc5e..b7196832ab 100644 --- a/apps/frontend/app/contest/[contestId]/problem/[problemId]/submission/_components/SubmissionDetail.tsx +++ b/apps/frontend/app/contest/[contestId]/problem/[problemId]/submission/_components/SubmissionDetail.tsx @@ -8,7 +8,7 @@ import { TableHeader, TableRow } from '@/components/ui/table' -import { dateFormatter, fetcherWithAuth } from '@/lib/utils' +import { dateFormatter, fetcherWithAuth, getResultColor } from '@/lib/utils' import type { SubmissionDetail } from '@/types/type' import { revalidateTag } from 'next/cache' import { IoIosLock } from 'react-icons/io' @@ -48,15 +48,7 @@ export default async function SubmissionDetail({

Result

-

+

{submission.result}

@@ -98,11 +90,9 @@ export default async function SubmissionDetail({ {item.id} {item.result} diff --git a/apps/frontend/app/problem/[problemId]/submission/_components/Columns.tsx b/apps/frontend/app/problem/[problemId]/submission/_components/Columns.tsx index 86e20c3ecc..8de2396031 100644 --- a/apps/frontend/app/problem/[problemId]/submission/_components/Columns.tsx +++ b/apps/frontend/app/problem/[problemId]/submission/_components/Columns.tsx @@ -1,6 +1,6 @@ 'use client' -import { dateFormatter } from '@/lib/utils' +import { dateFormatter, getResultColor } from '@/lib/utils' import type { SubmissionItem } from '@/types/type' import type { ColumnDef } from '@tanstack/react-table' @@ -19,12 +19,10 @@ export const columns: ColumnDef[] = [ header: () => 'Result', accessorKey: 'result', cell: ({ row }) => { - return row.original.result === 'Accepted' ? ( -

{row.original.result}

- ) : row.original.result === 'Judging' ? ( -

{row.original.result}

- ) : ( -

{row.original.result}

+ return ( +

+ {row.original.result} +

) } }, diff --git a/apps/frontend/app/problem/[problemId]/submission/_components/SubmissionDetail.tsx b/apps/frontend/app/problem/[problemId]/submission/_components/SubmissionDetail.tsx index 9e1c2eb522..77d9756244 100644 --- a/apps/frontend/app/problem/[problemId]/submission/_components/SubmissionDetail.tsx +++ b/apps/frontend/app/problem/[problemId]/submission/_components/SubmissionDetail.tsx @@ -8,7 +8,7 @@ import { TableHeader, TableRow } from '@/components/ui/table' -import { dateFormatter, fetcherWithAuth } from '@/lib/utils' +import { dateFormatter, fetcherWithAuth, getResultColor } from '@/lib/utils' import type { SubmissionDetail } from '@/types/type' import { revalidateTag } from 'next/cache' import dataIfError from './dataIfError' @@ -45,13 +45,7 @@ export default async function SubmissionDetail({

Result

-

+

{submission.result}

@@ -91,13 +85,7 @@ export default async function SubmissionDetail({ {submission.testcaseResult.map((item) => ( {item.problemTestcaseId.toString()} - + {item.result} {item.cpuTime} ms diff --git a/apps/frontend/components/TestcasePanel.tsx b/apps/frontend/components/TestcasePanel.tsx index 398424a4db..d750a02f7b 100644 --- a/apps/frontend/components/TestcasePanel.tsx +++ b/apps/frontend/components/TestcasePanel.tsx @@ -1,6 +1,6 @@ 'use client' -import { cn } from '@/lib/utils' +import { cn, getResultColor } from '@/lib/utils' import type { TestResultDetail } from '@/types/type' import { useState } from 'react' import { IoMdClose } from 'react-icons/io' @@ -202,15 +202,7 @@ function TestResultDetail({
Result - + {dataWithIndex[currentTab - 1].result}
diff --git a/apps/frontend/components/TestcaseTable.tsx b/apps/frontend/components/TestcaseTable.tsx index 6cda488515..613ee74cae 100644 --- a/apps/frontend/components/TestcaseTable.tsx +++ b/apps/frontend/components/TestcaseTable.tsx @@ -6,7 +6,7 @@ import { TableHeader, TableRow } from '@/components/ui/table' -import { cn } from '@/lib/utils' +import { cn, getResultColor } from '@/lib/utils' import type { TestResultDetail } from '@/types/type' import { WhitespaceVisualizer } from './WhitespaceVisualizer' @@ -77,11 +77,7 @@ export default function TestcaseTable({ {testResult.result} diff --git a/apps/frontend/lib/utils.ts b/apps/frontend/lib/utils.ts index 8ac35b97b3..fcc9b258c1 100644 --- a/apps/frontend/lib/utils.ts +++ b/apps/frontend/lib/utils.ts @@ -86,3 +86,28 @@ export const getStatusWithStartEnd = (startTime: string, endTime: string) => { return 'ongoing' } } + +/** + * Returns the appropriate color class based on the result status. + * + * @param {string} result - The result status to be evaluated. + * @returns {string} The corresponding color class name based on the result status: + * - '!text-green-500' for 'Accepted'. + * - '!text-neutral-400' for 'Judging' or 'Blind' or null or undefined. + * - '!text-red-500' for any other result status. + * @see tailwind.config.ts - Refer to the safelist section in the TailwindCSS configuration file. + */ +export const getResultColor = (result: string | null | undefined): string => { + if (result === 'Accepted') { + return '!text-green-500' + } else if ( + result === 'Judging' || + result === 'Blind' || + result === null || + result === undefined + ) { + return '!text-neutral-400' + } else { + return '!text-red-500' + } +} diff --git a/apps/frontend/tailwind.config.ts b/apps/frontend/tailwind.config.ts index 8fb509df8d..da53f92246 100644 --- a/apps/frontend/tailwind.config.ts +++ b/apps/frontend/tailwind.config.ts @@ -87,5 +87,6 @@ export default { } }) } - ] + ], + safelist: ['!text-green-500', '!text-neutral-400', '!text-red-500'] } satisfies Config