From f6cd6362593700f513e56056dbc912a2217d8dc2 Mon Sep 17 00:00:00 2001 From: admclamb Date: Mon, 25 May 2026 14:31:28 -0400 Subject: [PATCH 1/5] Use difficulty badge in problems table and remove unused dep --- package.json | 1 - pnpm-lock.yaml | 9 --------- .../problems-table-v2/problems-columns-v2.tsx | 4 ++++ vitest.setup.ts | 14 ++++++++++++-- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index 63804d6..1cabc61 100644 --- a/package.json +++ b/package.json @@ -111,7 +111,6 @@ "@vitest/coverage-v8": "3.2.4", "@vitest/ui": "^3.2.4", "cypress": "^15.12.0", - "dotenv": "^17.2.3", "eslint": "^9.39.1", "eslint-config-next": "16.0.8", "istanbul-badges-readme": "^1.9.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e957a58..744edac 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -274,9 +274,6 @@ importers: cypress: specifier: ^15.12.0 version: 15.12.0 - dotenv: - specifier: ^17.2.3 - version: 17.2.3 eslint: specifier: ^9.39.1 version: 9.39.1(jiti@2.6.1) @@ -3028,10 +3025,6 @@ packages: dom-accessibility-api@0.6.3: resolution: {integrity: sha512-7ZgogeTnjuHbo+ct10G9Ffp0mif17idi0IyWNVA/wcwcm7NPOD/WEHVP3n7n3MhXqxoIYm8d6MuZohYWIZ4T3w==} - dotenv@17.2.3: - resolution: {integrity: sha512-JVUnt+DUIzu87TABbhPmNfVdBDt18BLOWjMUFJMSi/Qqg7NTYtabbvSNJGOJ7afbRuv9D/lngizHtP7QyLQ+9w==} - engines: {node: '>=12'} - dunder-proto@1.0.1: resolution: {integrity: sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==} engines: {node: '>= 0.4'} @@ -8153,8 +8146,6 @@ snapshots: dom-accessibility-api@0.6.3: {} - dotenv@17.2.3: {} - dunder-proto@1.0.1: dependencies: call-bind-apply-helpers: 1.0.2 diff --git a/src/features/problems/problems-table-v2/problems-columns-v2.tsx b/src/features/problems/problems-table-v2/problems-columns-v2.tsx index f9b686a..7b06c26 100644 --- a/src/features/problems/problems-table-v2/problems-columns-v2.tsx +++ b/src/features/problems/problems-table-v2/problems-columns-v2.tsx @@ -1,4 +1,5 @@ import { ColumnDef } from "@tanstack/react-table"; +import { ProblemDifficultyBadge } from "@/features/problem/problem-difficulty-badge/problem-difficulty-badge"; import { Problem } from "../models/problem"; export const problemColumnsV2: ColumnDef[] = [ @@ -9,6 +10,9 @@ export const problemColumnsV2: ColumnDef[] = [ { accessorKey: "difficulty", header: "Difficulty", + cell: ({ row }) => ( + + ), }, { accessorKey: "tags", diff --git a/vitest.setup.ts b/vitest.setup.ts index 362c14e..aa8c9cd 100644 --- a/vitest.setup.ts +++ b/vitest.setup.ts @@ -1,4 +1,14 @@ import "@testing-library/jest-dom"; -import { config } from "dotenv"; +import { vi } from "vitest"; -config({ path: ".env.test" }); +vi.mock("@/env", () => ({ + env: { + AUTH0_DOMAIN: "test-auth0-domain", + AUTH0_CLIENT_ID: "test-auth0-client-id", + AUTH0_SECRET: "test-auth0-secret", + AUTH0_CLIENT_SECRET: "test-auth0-client-secret", + AUTH0_CALLBACK_URL: "http://localhost:3000/account/callback", + AUTH0_AUDIENCE: "test-auth0-audience", + NEXT_PUBLIC_API_SERVER_URL: "http://localhost:5035", + }, +})); From 3b53107cd21f935a786bd41d1a5957d571188cb2 Mon Sep 17 00:00:00 2001 From: admclamb Date: Mon, 25 May 2026 14:32:45 -0400 Subject: [PATCH 2/5] format --- src/app/problems/[slug]/problem-layout-client.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/app/problems/[slug]/problem-layout-client.tsx b/src/app/problems/[slug]/problem-layout-client.tsx index 806c332..bc4574d 100644 --- a/src/app/problems/[slug]/problem-layout-client.tsx +++ b/src/app/problems/[slug]/problem-layout-client.tsx @@ -8,7 +8,9 @@ type ProblemLayoutClientProps = { problem: Problem; }; -export default function ProblemLayoutClient({ problem }: ProblemLayoutClientProps) { +export default function ProblemLayoutClient({ + problem, +}: ProblemLayoutClientProps) { const account = accountStore((state) => state.account); return ; From 81262abd835144101bb26a3865b9f52d4b182f80 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 25 May 2026 18:45:16 +0000 Subject: [PATCH 3/5] fix: remove cross-feature difficulty badge import in problems table Agent-Logs-Url: https://github.com/algowars/web/sessions/73ae2ae3-e122-4f5f-9093-eebfa71d7dfe Co-authored-by: admclamb <90528159+admclamb@users.noreply.github.com> --- .../problems-table-v2/problems-columns-v2.tsx | 38 +++++++++++++++++-- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/src/features/problems/problems-table-v2/problems-columns-v2.tsx b/src/features/problems/problems-table-v2/problems-columns-v2.tsx index 7b06c26..39f91b5 100644 --- a/src/features/problems/problems-table-v2/problems-columns-v2.tsx +++ b/src/features/problems/problems-table-v2/problems-columns-v2.tsx @@ -1,7 +1,31 @@ import { ColumnDef } from "@tanstack/react-table"; -import { ProblemDifficultyBadge } from "@/features/problem/problem-difficulty-badge/problem-difficulty-badge"; +import { Badge } from "@/components/ui/badge"; import { Problem } from "../models/problem"; +function getDifficultyLabel(difficulty: number): { + label: string; + className: string; +} { + if (difficulty < 1000) { + return { + label: "Easy", + className: + "bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400", + }; + } + if (difficulty < 2000) { + return { + label: "Medium", + className: + "bg-yellow-100 text-yellow-700 dark:bg-yellow-900/30 dark:text-yellow-400", + }; + } + return { + label: "Hard", + className: "bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400", + }; +} + export const problemColumnsV2: ColumnDef[] = [ { accessorKey: "title", @@ -10,9 +34,15 @@ export const problemColumnsV2: ColumnDef[] = [ { accessorKey: "difficulty", header: "Difficulty", - cell: ({ row }) => ( - - ), + cell: ({ row }) => { + const { label, className } = getDifficultyLabel(row.original.difficulty); + + return ( + + {label} + + ); + }, }, { accessorKey: "tags", From 9e421d8208d44a6fc68ba297452ac0d5cbd70e03 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 25 May 2026 18:45:55 +0000 Subject: [PATCH 4/5] refactor: inline difficulty badge mapping in problems columns Agent-Logs-Url: https://github.com/algowars/web/sessions/73ae2ae3-e122-4f5f-9093-eebfa71d7dfe Co-authored-by: admclamb <90528159+admclamb@users.noreply.github.com> --- .../problems-table-v2/problems-columns-v2.tsx | 34 +++++-------------- 1 file changed, 9 insertions(+), 25 deletions(-) diff --git a/src/features/problems/problems-table-v2/problems-columns-v2.tsx b/src/features/problems/problems-table-v2/problems-columns-v2.tsx index 39f91b5..bae058f 100644 --- a/src/features/problems/problems-table-v2/problems-columns-v2.tsx +++ b/src/features/problems/problems-table-v2/problems-columns-v2.tsx @@ -2,30 +2,6 @@ import { ColumnDef } from "@tanstack/react-table"; import { Badge } from "@/components/ui/badge"; import { Problem } from "../models/problem"; -function getDifficultyLabel(difficulty: number): { - label: string; - className: string; -} { - if (difficulty < 1000) { - return { - label: "Easy", - className: - "bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400", - }; - } - if (difficulty < 2000) { - return { - label: "Medium", - className: - "bg-yellow-100 text-yellow-700 dark:bg-yellow-900/30 dark:text-yellow-400", - }; - } - return { - label: "Hard", - className: "bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400", - }; -} - export const problemColumnsV2: ColumnDef[] = [ { accessorKey: "title", @@ -35,7 +11,15 @@ export const problemColumnsV2: ColumnDef[] = [ accessorKey: "difficulty", header: "Difficulty", cell: ({ row }) => { - const { label, className } = getDifficultyLabel(row.original.difficulty); + const difficulty = row.original.difficulty; + const label = + difficulty < 1000 ? "Easy" : difficulty < 2000 ? "Medium" : "Hard"; + const className = + difficulty < 1000 + ? "bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400" + : difficulty < 2000 + ? "bg-yellow-100 text-yellow-700 dark:bg-yellow-900/30 dark:text-yellow-400" + : "bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400"; return ( From a5d08f806355a7f5995accf94b29860f7a3f8bd7 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 25 May 2026 18:53:54 +0000 Subject: [PATCH 5/5] refactor: move problem difficulty badge to shared component Agent-Logs-Url: https://github.com/algowars/web/sessions/6b4202cb-2c5e-4625-bcca-15b363c40dce Co-authored-by: admclamb <90528159+admclamb@users.noreply.github.com> --- .../problem-difficulty-badge.test.tsx | 0 .../problem-difficulty-badge.tsx | 9 ++++---- .../problem-question/problem-question.tsx | 2 +- .../problems-table-v2/problems-columns-v2.tsx | 22 ++++--------------- 4 files changed, 10 insertions(+), 23 deletions(-) rename src/{features/problem/problem-difficulty-badge => components}/problem-difficulty-badge.test.tsx (100%) rename src/{features/problem/problem-difficulty-badge => components}/problem-difficulty-badge.tsx (86%) diff --git a/src/features/problem/problem-difficulty-badge/problem-difficulty-badge.test.tsx b/src/components/problem-difficulty-badge.test.tsx similarity index 100% rename from src/features/problem/problem-difficulty-badge/problem-difficulty-badge.test.tsx rename to src/components/problem-difficulty-badge.test.tsx diff --git a/src/features/problem/problem-difficulty-badge/problem-difficulty-badge.tsx b/src/components/problem-difficulty-badge.tsx similarity index 86% rename from src/features/problem/problem-difficulty-badge/problem-difficulty-badge.tsx rename to src/components/problem-difficulty-badge.tsx index 6c9bfc6..b805569 100644 --- a/src/features/problem/problem-difficulty-badge/problem-difficulty-badge.tsx +++ b/src/components/problem-difficulty-badge.tsx @@ -1,23 +1,24 @@ -"use client"; - import { Badge } from "@/components/ui/badge"; type ProblemDifficultyBadgeProps = { difficulty: number; }; +const EASY_THRESHOLD = 1000; +const MEDIUM_THRESHOLD = 2000; + function getDifficultyLabel(difficulty: number): { label: string; className: string; } { - if (difficulty < 1000) { + if (difficulty < EASY_THRESHOLD) { return { label: "Easy", className: "bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400", }; } - if (difficulty < 2000) { + if (difficulty < MEDIUM_THRESHOLD) { return { label: "Medium", className: diff --git a/src/features/problem/problem-question/problem-question.tsx b/src/features/problem/problem-question/problem-question.tsx index 4a71db3..a073dc2 100644 --- a/src/features/problem/problem-question/problem-question.tsx +++ b/src/features/problem/problem-question/problem-question.tsx @@ -4,9 +4,9 @@ import { AccordionItem, AccordionTrigger, } from "@/components/ui/accordion"; +import { ProblemDifficultyBadge } from "@/components/problem-difficulty-badge"; import { Separator } from "@/components/ui/separator"; import { Problem } from "@/features/problems/models/problem"; -import { ProblemDifficultyBadge } from "@/features/problem/problem-difficulty-badge/problem-difficulty-badge"; import { Tag } from "lucide-react"; import React from "react"; import ProblemEditorTags from "./problem-editor-tags"; diff --git a/src/features/problems/problems-table-v2/problems-columns-v2.tsx b/src/features/problems/problems-table-v2/problems-columns-v2.tsx index bae058f..cc37581 100644 --- a/src/features/problems/problems-table-v2/problems-columns-v2.tsx +++ b/src/features/problems/problems-table-v2/problems-columns-v2.tsx @@ -1,5 +1,5 @@ import { ColumnDef } from "@tanstack/react-table"; -import { Badge } from "@/components/ui/badge"; +import { ProblemDifficultyBadge } from "@/components/problem-difficulty-badge"; import { Problem } from "../models/problem"; export const problemColumnsV2: ColumnDef[] = [ @@ -10,23 +10,9 @@ export const problemColumnsV2: ColumnDef[] = [ { accessorKey: "difficulty", header: "Difficulty", - cell: ({ row }) => { - const difficulty = row.original.difficulty; - const label = - difficulty < 1000 ? "Easy" : difficulty < 2000 ? "Medium" : "Hard"; - const className = - difficulty < 1000 - ? "bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400" - : difficulty < 2000 - ? "bg-yellow-100 text-yellow-700 dark:bg-yellow-900/30 dark:text-yellow-400" - : "bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400"; - - return ( - - {label} - - ); - }, + cell: ({ row }) => ( + + ), }, { accessorKey: "tags",