import type { ColumnDef } from "@tanstack/react-table"; import { Cog } from "lucide-react"; import { DataTable } from "~/components/custom_ui/data-table"; import { DataTableColumnHeader } from "~/components/custom_ui/dataTable-header"; import type { SearchFiltro } from "~/components/custom_ui/dataTable-toolbar"; import { Button } from "~/components/ui/button"; import type { Banners } from "~/schemas/public/Banners"; export const BannersTable = (props: { data: Banners[]; setOpenEdit: (status: boolean) => void; setEditData: (data: Banners | null) => void; }) => { const { data, setOpenEdit, setEditData } = props; const tabledata = data.map((row) => { return { actions: "Azioni", color: row.color, cta_href: row.cta_href, cta_icon: row.cta_icon, cta_text: row.cta_text, has_cta: row.has_cta, hide_duration: row.hide_duration, idbanner: row.idbanner, is_active: row.is_active, is_unskippable: row.is_unskippable, show_private: row.show_private, show_public: row.show_public, testo: row.testo, titolo: row.titolo, }; }); const columns_titles = { actions: "Azioni", color: "Colore", cta_href: "Indirizzo", cta_icon: "Icona", cta_text: "Testo", has_cta: "Ha link", hide_duration: "Durata", idbanner: "Codice", is_active: "Attivo", is_unskippable: "Non saltabile", show_private: "A. Riservata", show_public: "Pubblico", testo: "Testo", titolo: "Titolo", }; type Column = (typeof tabledata)[number]; const columns: ColumnDef[] = [ { accessorKey: "idbanner", header: ({ column }) => ( ), }, { accessorKey: "titolo", header: ({ column }) => ( ), }, { accessorKey: "testo", header: ({ column }) => ( ), }, { accessorKey: "is_unskippable", cell: ({ row }) => { const data = row.original; return data.is_unskippable ? "Vero" : "Falso"; }, header: ({ column }) => ( ), }, { accessorKey: "has_cta", cell: ({ row }) => { const data = row.original; return data.has_cta ? "Vero" : "Falso"; }, header: ({ column }) => ( ), }, { accessorKey: "hide_duration", header: ({ column }) => ( ), }, { accessorKey: "cta_href", header: ({ column }) => ( ), }, { accessorKey: "cta_icon", header: ({ column }) => ( ), }, { accessorKey: "cta_text", header: ({ column }) => ( ), }, { accessorKey: "color", header: ({ column }) => ( ), }, { accessorKey: "is_active", cell: ({ row }) => { const data = row.original; return data.is_active ? "Vero" : "Falso"; }, header: ({ column }) => ( ), }, { accessorKey: "show_public", cell: ({ row }) => { const data = row.original; return data.show_public ? "Vero" : "Falso"; }, header: ({ column }) => ( ), }, { accessorKey: "show_private", cell: ({ row }) => { const data = row.original; return data.show_private ? "Vero" : "Falso"; }, header: ({ column }) => ( ), }, { accessorKey: "actions", cell: ({ row }) => { const data = row.original; return ( ); }, enableHiding: false, enableSorting: false, header: ({ column }) => ( ), }, ]; const searchFiltro: SearchFiltro = { columnName: "idbanner", placeholder: "Filtra codice...", }; return (
); };