From c712f3175911390a282808e4fa6798c7810b4b6b Mon Sep 17 00:00:00 2001 From: Citali Date: Sat, 31 Jan 2026 16:04:29 +0100 Subject: [PATCH] Refactor code --- .../commissions/submitCommissionRequest.ts | 14 ----------- .../portfolio/getPortfolioArtworksMeta.ts | 2 +- .../portfolio/getPortfolioArtworksPage.ts | 2 -- src/app/(normal)/page.tsx | 23 ------------------- src/app/(normal)/tos/page.tsx | 2 -- src/app/api/image/[...key]/route.ts | 2 +- src/components/SocialLinks.tsx | 1 + src/components/artworks/RawCloseButton.tsx | 1 + src/components/artworks/TagFilterDialog.tsx | 12 ---------- src/components/commissions/CommissionCard.tsx | 2 +- .../commissions/CommissionOrderForm.tsx | 4 ++-- src/components/global/Banner.tsx | 3 --- src/components/global/ThemeProvider.tsx | 2 +- src/components/ui/accordion.tsx | 5 ++-- src/utils/calculatePrice.ts | 6 ++--- 15 files changed, 14 insertions(+), 67 deletions(-) diff --git a/src/actions/commissions/submitCommissionRequest.ts b/src/actions/commissions/submitCommissionRequest.ts index e7c51f5..adf373e 100644 --- a/src/actions/commissions/submitCommissionRequest.ts +++ b/src/actions/commissions/submitCommissionRequest.ts @@ -2,15 +2,6 @@ import { z } from "zod"; -/** - * Server action - * Forwards a multipart/form-data request (payload + files[]) - * from the public app to the admin app's public commissions endpoint. - * - * Server-only env required: - * ADMIN_URL=https://admin.domain.com - */ - const submitPayloadSchema = z.object({ typeId: z.string().optional().nullable(), optionId: z.string().optional().nullable(), @@ -36,7 +27,6 @@ export async function submitCommissionRequest(input: { const payload = submitPayloadSchema.parse(input.payload); const files = input.files ?? []; - // Optional safety limits const MAX_FILES = 10; const MAX_BYTES_EACH = 10 * 1024 * 1024; // 10MB @@ -70,7 +60,6 @@ export async function submitCommissionRequest(input: { const raw = await res.text().catch(() => ""); const statusLine = `${res.status} ${res.statusText || ""}`.trim(); - // Show something useful even if raw is empty let message = `Admin API error: ${statusLine}`; if (raw) { @@ -87,12 +76,9 @@ export async function submitCommissionRequest(input: { } } - // Log full body server-side for debugging (safe; this is server-only) console.error("[submitCommissionRequest] upstream error", { statusLine, raw }); throw new Error(message); } - - // Expected response: { id: string; createdAt: string } return (await res.json()) as { id: string; createdAt: string }; } diff --git a/src/actions/portfolio/getPortfolioArtworksMeta.ts b/src/actions/portfolio/getPortfolioArtworksMeta.ts index 882c817..4eb53c4 100644 --- a/src/actions/portfolio/getPortfolioArtworksMeta.ts +++ b/src/actions/portfolio/getPortfolioArtworksMeta.ts @@ -1,7 +1,7 @@ "use server"; import type { PortfolioFilters } from "@/actions/portfolio/getPortfolioArtworksPage"; -import { Prisma } from "@/generated/prisma/browser"; +import type { Prisma } from "@/generated/prisma/browser"; import { prisma } from "@/lib/prisma"; function coerceYear(y: PortfolioFilters["year"]) { diff --git a/src/actions/portfolio/getPortfolioArtworksPage.ts b/src/actions/portfolio/getPortfolioArtworksPage.ts index b690521..7b310ef 100644 --- a/src/actions/portfolio/getPortfolioArtworksPage.ts +++ b/src/actions/portfolio/getPortfolioArtworksPage.ts @@ -107,7 +107,6 @@ export async function getPortfolioArtworksPage(args: { .filter((y): y is number => typeof y === "number") .sort((a, b) => b - a); - // Segment logic (sortKey != null first, then null) const inNullSegment = cursor?.afterSortKey === null; const select = { @@ -180,7 +179,6 @@ export async function getPortfolioArtworksPage(args: { if (!last) { return { items, nextCursor: null, total, years, albums }; } - // last.sortKey can be null only in null-segment, which we are not in here. if (last.sortKey == null) { return { items, nextCursor: null, total, years, albums }; } diff --git a/src/app/(normal)/page.tsx b/src/app/(normal)/page.tsx index a96089e..1c55a4e 100644 --- a/src/app/(normal)/page.tsx +++ b/src/app/(normal)/page.tsx @@ -19,29 +19,6 @@ export default function Home() { - - - {/* Section Cards */} -
- {/*

- If you want to commission me you can find all the information you need under following link: Linktree -

*/} - {/* {sections.map((section) => ( - - - - - - {section.title} - - - - {section.description} - - - - ))} */} -
); } diff --git a/src/app/(normal)/tos/page.tsx b/src/app/(normal)/tos/page.tsx index e6c9fd2..2bf507f 100644 --- a/src/app/(normal)/tos/page.tsx +++ b/src/app/(normal)/tos/page.tsx @@ -6,8 +6,6 @@ export default async function TosPage() { orderBy: [{ version: "desc" }], }) - // console.log(tos?.markdown) - return (
diff --git a/src/app/api/image/[...key]/route.ts b/src/app/api/image/[...key]/route.ts index f4d4d68..6580d64 100644 --- a/src/app/api/image/[...key]/route.ts +++ b/src/app/api/image/[...key]/route.ts @@ -24,7 +24,7 @@ export async function GET(_req: NextRequest, context: { params: Promise<{ key: s headers: { "Content-Type": contentType, "Cache-Control": "public, max-age=3600", - "Content-Disposition": "inline", // use 'attachment' to force download + "Content-Disposition": "inline", }, }); } catch (err) { diff --git a/src/components/SocialLinks.tsx b/src/components/SocialLinks.tsx index 4cc1c23..bc8ce24 100644 --- a/src/components/SocialLinks.tsx +++ b/src/components/SocialLinks.tsx @@ -67,6 +67,7 @@ function BrandSvg({ icon }: { icon: SimpleIcon }) { className="h-5 w-5 fill-current" aria-hidden="true" focusable="false" + // biome-ignore lint: lint/security/noDangerouslySetInnerHtml dangerouslySetInnerHTML={{ __html: icon.svg }} /> ); diff --git a/src/components/artworks/RawCloseButton.tsx b/src/components/artworks/RawCloseButton.tsx index f6fa062..582e5a8 100644 --- a/src/components/artworks/RawCloseButton.tsx +++ b/src/components/artworks/RawCloseButton.tsx @@ -26,6 +26,7 @@ export default function RawCloseButton({ targetHref }: RawCloseButtonProps) { onClick={() => router.push(targetHref)} className="absolute top-4 right-4 z-50 rounded-md bg-background/80 p-2 hover:bg-background/60 transition" title="Close full view (ESC)" + type="button" > diff --git a/src/components/artworks/TagFilterDialog.tsx b/src/components/artworks/TagFilterDialog.tsx index 505ff80..5dbedcd 100644 --- a/src/components/artworks/TagFilterDialog.tsx +++ b/src/components/artworks/TagFilterDialog.tsx @@ -25,7 +25,6 @@ type Tag = { slug: string; sortIndex: number; parentId: string | null; - // these may exist, but we do NOT rely on them: parent?: { id: string; name: string; slug: string; sortIndex: number } | null; children?: { id: string; name: string; slug: string; sortIndex: number; parentId: string | null }[]; }; @@ -65,7 +64,6 @@ export default function TagFilterDialog({ const byId = useMemo(() => new Map(tags.map((t) => [t.id, t])), [tags]); - // Build children mapping from the flat list: parentId -> Tag[] const childrenByParentId = useMemo(() => { const map = new Map(); for (const t of tags) { @@ -74,7 +72,6 @@ export default function TagFilterDialog({ arr.push(t); map.set(t.parentId, arr); } - // sort each child list for (const [k, arr] of map) { map.set(k, arr.slice().sort(sortTags)); } @@ -101,7 +98,6 @@ export default function TagFilterDialog({ const s = new Set(prev); if (next) { s.add(parent.slug); - // when selecting parent, remove child selections (redundant) for (const c of children) s.delete(c.slug); } else { s.delete(parent.slug); @@ -188,9 +184,6 @@ export default function TagFilterDialog({ />
{p.name}
- {/*
- {children.length ? "Parent tag" : "Tag"} -
*/}
@@ -231,11 +224,6 @@ export default function TagFilterDialog({ {orphanChildren.length ? (
- {/*
Other tags
*/} - {/*
- These tags are not currently assigned to a visible parent. -
*/} -
{orphanChildren.map((t) => { const checked = selectedSet.has(t.slug); diff --git a/src/components/commissions/CommissionCard.tsx b/src/components/commissions/CommissionCard.tsx index 73164d7..b6d4858 100644 --- a/src/components/commissions/CommissionCard.tsx +++ b/src/components/commissions/CommissionCard.tsx @@ -1,7 +1,7 @@ "use client" import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card" -import { CommissionExtra, CommissionOption, CommissionType, CommissionTypeExtra, CommissionTypeOption } from "@/generated/prisma/client" +import type { CommissionExtra, CommissionOption, CommissionType, CommissionTypeExtra, CommissionTypeOption } from "@/generated/prisma/client" type CommissionTypeWithItems = CommissionType & { options: (CommissionTypeOption & { diff --git a/src/components/commissions/CommissionOrderForm.tsx b/src/components/commissions/CommissionOrderForm.tsx index 18d400a..d6622bb 100644 --- a/src/components/commissions/CommissionOrderForm.tsx +++ b/src/components/commissions/CommissionOrderForm.tsx @@ -12,7 +12,7 @@ import { } from "@/components/ui/form"; import { Input } from "@/components/ui/input"; import { Textarea } from "@/components/ui/textarea"; -import { +import type { CommissionCustomInput, CommissionExtra, CommissionOption, @@ -28,7 +28,7 @@ import Link from "next/link"; import { useMemo, useState } from "react"; import { useForm, useWatch } from "react-hook-form"; import { toast } from "sonner"; -import * as z from "zod/v4"; +import type * as z from "zod/v4"; import { FileDropzone } from "./FileDropzone"; type CommissionTypeWithRelations = CommissionType & { diff --git a/src/components/global/Banner.tsx b/src/components/global/Banner.tsx index 7e20b41..8d0a140 100644 --- a/src/components/global/Banner.tsx +++ b/src/components/global/Banner.tsx @@ -1,11 +1,8 @@ import { prisma } from "@/lib/prisma"; import { cn } from "@/lib/utils"; -// import { Fraunces } from "next/font/google"; import localFont from 'next/font/local'; import Image from "next/image"; -// const pacifico = Fraunces({ weight: "700", subsets: ["latin"] }); - const myFont = localFont({ src: './Echotopia-Regular.woff2', }) diff --git a/src/components/global/ThemeProvider.tsx b/src/components/global/ThemeProvider.tsx index 120faea..1fa2df4 100644 --- a/src/components/global/ThemeProvider.tsx +++ b/src/components/global/ThemeProvider.tsx @@ -1,7 +1,7 @@ "use client" import { ThemeProvider as NextThemesProvider } from "next-themes" -import * as React from "react" +import type * as React from "react" export function ThemeProvider({ children, diff --git a/src/components/ui/accordion.tsx b/src/components/ui/accordion.tsx index 4a8cca4..80da8c8 100644 --- a/src/components/ui/accordion.tsx +++ b/src/components/ui/accordion.tsx @@ -1,8 +1,8 @@ "use client" -import * as React from "react" import * as AccordionPrimitive from "@radix-ui/react-accordion" import { ChevronDownIcon } from "lucide-react" +import * as React from "react" import { cn } from "@/lib/utils" @@ -63,4 +63,5 @@ function AccordionContent({ ) } -export { Accordion, AccordionItem, AccordionTrigger, AccordionContent } +export { Accordion, AccordionContent, AccordionItem, AccordionTrigger } + diff --git a/src/utils/calculatePrice.ts b/src/utils/calculatePrice.ts index 99b9c1d..c2e2c40 100644 --- a/src/utils/calculatePrice.ts +++ b/src/utils/calculatePrice.ts @@ -10,7 +10,7 @@ export function calculatePrice(source: PriceSource, base: number): number { if (source.priceRange) { const parts = source.priceRange.split("–").map(Number) const max = Math.max(...parts) - return isNaN(max) ? 0 : max + return Number.isNaN(max) ? 0 : max } return 0 } @@ -39,8 +39,8 @@ export function calculatePriceRange( const min = Number(minStr) const max = Number(maxStr) - if (!isNaN(min)) minExtra += min - if (!isNaN(max)) maxExtra += max + if (!Number.isNaN(min)) minExtra += min + if (!Number.isNaN(max)) maxExtra += max } }