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 { idbanner: row.idbanner, titolo: row.titolo, testo: row.testo, is_unskippable: row.is_unskippable, has_cta: row.has_cta, cta_href: row.cta_href, cta_icon: row.cta_icon, cta_text: row.cta_text, color: row.color, is_active: row.is_active, show_public: row.show_public, show_private: row.show_private, hide_duration: row.hide_duration, actions: "Azioni", }; }); const columns_titles = { idbanner: "Codice", titolo: "Titolo", testo: "Testo", is_unskippable: "Non saltabile", has_cta: "Ha link", hide_duration: "Durata", cta_href: "Indirizzo", cta_icon: "Icona", cta_text: "Testo", color: "Colore", is_active: "Attivo", actions: "Azioni", show_public: "Pubblico", show_private: "A. Riservata", }; type Column = (typeof tabledata)[number]; const columns: ColumnDef[] = [ { header: ({ column }) => ( ), 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 }) => ( ), cell: ({ row }) => { const data = row.original; return ( ); }, accessorKey: "actions", enableHiding: false, enableSorting: false, }, ]; const searchFiltro: SearchFiltro = { columnName: "idbanner", placeholder: "Filtra codice...", }; return (
); };