revert style: clean up code with prettier and eslint
This commit is contained in:
remco committed 2026-07-12 21:02:03 +02:00
1 parent 27de078f54
commit e85e4d74ea
378 files changed
+20710 -22428

No files matched your search

+36 -36
View File
@@ -1,64 +1,64 @@
"use client";
'use client'
import { Pencil } from "lucide-react";
import Link from "next/link";
import { DataTable } from "@/components/admin/data-table";
import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
import type { DataTableColumn, PaginatedResult } from "@/types";
import { Pencil } from 'lucide-react'
import Link from 'next/link'
import { DataTable } from '@/components/admin/data-table'
import { Badge } from '@/components/ui/badge'
import { Button } from '@/components/ui/button'
import type { DataTableColumn, PaginatedResult } from '@/types'
interface PollRow {
id: number;
title: string;
status: string;
showResults: number;
multipleChoice: number;
startsAt: Date | null;
endsAt: Date | null;
createdAt: Date;
id: number
title: string
status: string
showResults: number
multipleChoice: number
startsAt: Date | null
endsAt: Date | null
createdAt: Date
}
const statusVariants: Record<string, "default" | "secondary" | "outline"> = {
active: "default",
draft: "secondary",
closed: "outline",
};
const statusVariants: Record<string, 'default' | 'secondary' | 'outline'> = {
active: 'default',
draft: 'secondary',
closed: 'outline',
}
function getColumns(): DataTableColumn<PollRow>[] {
return [
{ key: "id", label: "ID", sortable: true },
{ key: 'id', label: 'ID', sortable: true },
{
key: "title",
label: "Title",
key: 'title',
label: 'Title',
sortable: true,
render: (value) => <span className="font-medium">{String(value)}</span>,
},
{
key: "status",
label: "Status",
key: 'status',
label: 'Status',
sortable: true,
render: (value) => (
<Badge variant={statusVariants[String(value)] ?? "secondary"}>{String(value)}</Badge>
<Badge variant={statusVariants[String(value)] ?? 'secondary'}>{String(value)}</Badge>
),
},
{
key: "multipleChoice",
label: "Type",
key: 'multipleChoice',
label: 'Type',
render: (value) => (
<span className="text-sm">{Number(value) ? "Multiple choice" : "Single choice"}</span>
<span className="text-sm">{Number(value) ? 'Multiple choice' : 'Single choice'}</span>
),
},
{
key: "createdAt",
label: "Created",
key: 'createdAt',
label: 'Created',
sortable: true,
render: (value) => (
<span className="text-sm">{new Date(value as unknown as string).toLocaleDateString()}</span>
),
},
{
key: "actions",
label: "Actions",
key: 'actions',
label: 'Actions',
render: (_, row) => (
<Button variant="ghost" size="icon" asChild>
<Link href={`/admin/polls/${row.id}`}>
@@ -67,13 +67,13 @@ function getColumns(): DataTableColumn<PollRow>[] {
</Button>
),
},
];
]
}
interface PollsTableProps {
data: PaginatedResult<PollRow>;
data: PaginatedResult<PollRow>
}
export function PollsTable({ data }: PollsTableProps) {
return <DataTable data={data} columns={getColumns()} searchPlaceholder="Search polls..." />;
return <DataTable data={data} columns={getColumns()} searchPlaceholder="Search polls..." />
}