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/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 ; 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 f9b686a..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,4 +1,5 @@ import { ColumnDef } from "@tanstack/react-table"; +import { ProblemDifficultyBadge } from "@/components/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", + }, +}));