style: format code with prettier
This commit is contained in:
1 parent
e85e4d74ea
commit
2e4ed76121
378 files changed
+22404
-20686
No files matched your search
@@ -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..." />;
|
||||
}
|
||||
Reference in new issue
Block a user