"use client"; import { Pencil } from "lucide-react"; import Link from "next/link"; import { useTranslations } from "next-intl"; 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; } const statusVariants: Record = { active: "default", draft: "secondary", closed: "outline", }; interface PollsTableProps { data: PaginatedResult; } export function PollsTable({ data }: PollsTableProps) { const t = useTranslations("pages.admin.polls"); const statusLabel: Record = { active: t("statusActive"), draft: t("statusDraft"), closed: t("statusClosed"), }; const columns: DataTableColumn[] = [ { key: "id", label: t("colId"), sortable: true }, { key: "title", label: t("colTitle"), sortable: true, render: (value) => {String(value)}, }, { key: "status", label: t("colStatus"), sortable: true, render: (value) => { const key = String(value); return ( {statusLabel[key] ?? key} ); }, }, { key: "multipleChoice", label: t("colType"), render: (value) => ( {Number(value) ? t("typeMultiple") : t("typeSingle")} ), }, { key: "createdAt", label: t("colCreated"), sortable: true, render: (value) => ( {new Date(value as unknown as string).toLocaleDateString()} ), }, { key: "actions", label: t("colActions"), render: (_, row) => ( ), }, ]; return ( ); }