From bc92368abc6f7370f33fec10cb2fee5148d5ee52 Mon Sep 17 00:00:00 2001 From: Marco Pedone Date: Fri, 29 Aug 2025 16:22:54 +0200 Subject: [PATCH] feat: update AnnunciTable to enhance actions and filter functionality --- .../src/components/tables/annunci-tables.tsx | 157 +++++++++++------- 1 file changed, 93 insertions(+), 64 deletions(-) diff --git a/apps/infoalloggi/src/components/tables/annunci-tables.tsx b/apps/infoalloggi/src/components/tables/annunci-tables.tsx index 455a68b..d69f092 100644 --- a/apps/infoalloggi/src/components/tables/annunci-tables.tsx +++ b/apps/infoalloggi/src/components/tables/annunci-tables.tsx @@ -1,9 +1,12 @@ import type { ColumnDef } from "@tanstack/react-table"; -import { Cog } from "lucide-react"; +import { Wrench } from "lucide-react"; import Link from "next/link"; 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 type { + PinnedFiltro, + SearchFiltro, +} from "~/components/custom_ui/dataTable-toolbar"; import { Button } from "~/components/ui/button"; import { StatusBadge } from "~/pages/area-riservata/admin/edit-annuncio/[id]"; import type { Annunci } from "~/schemas/public/Annunci"; @@ -17,78 +20,30 @@ export const AnnunciTable = ({ }) => { const tabledata = data.map((row) => { return { - id: row.id, + actions: "Azioni", codice: row.codice, - titolo_it: row.titolo_it, comune: row.comune, - tipo: row.tipo, + id: row.id, locatore: row.locatore, stato: row.stato, - actions: "Azioni", + tipo: row.tipo, + titolo_it: row.titolo_it, }; }); const columns_titles = { + actions: "Azioni", codice: "Codice", - titolo_it: "Titolo", comune: "Comune", - tipo: "Tipo", locatore: "Locatore", stato: "Stato", - actions: "Azioni", + tipo: "Tipo", + titolo_it: "Titolo", }; type Column = (typeof tabledata)[number]; const columns: ColumnDef[] = [ { - header: ({ column }) => ( - - ), - accessorKey: "codice", - }, - { - header: ({ column }) => ( - - ), - accessorKey: "titolo_it", - }, - { - header: ({ column }) => ( - - ), - - accessorKey: "comune", - }, - { - header: ({ column }) => ( - - ), - accessorKey: "tipo", - }, - { - header: ({ column }) => ( - - ), - accessorKey: "locatore", - }, - { - header: ({ column }) => ( - - ), - cell: ({ row }) => { - return ; - }, - accessorKey: "stato", - }, - { - header: ({ column }) => ( - - ), + accessorKey: "actions", cell: ({ row }) => { return ( - ); }, - accessorKey: "actions", enableHiding: false, enableSorting: false, + header: ({ column }) => ( + + ), + }, + { + accessorKey: "codice", + header: ({ column }) => ( + + ), + }, + { + accessorKey: "stato", + cell: ({ row }) => { + return ; + }, + header: ({ column }) => ( + + ), + }, + { + accessorKey: "titolo_it", + header: ({ column }) => ( + + ), + }, + { + accessorKey: "comune", + header: ({ column }) => ( + + ), + }, + { + accessorKey: "tipo", + header: ({ column }) => ( + + ), + }, + { + accessorKey: "locatore", + header: ({ column }) => ( + + ), }, ]; @@ -112,15 +118,38 @@ export const AnnunciTable = ({ columnName: "codice", placeholder: "Filtra codice...", }; + const pinnedFiltri: PinnedFiltro[] = [ + { + columnName: "stato", + options: [ + { label: "Attivo", value: "Attivo" }, + { + label: "Sospeso", + value: "Sospeso", + }, + { + label: "Trattativa", + value: "Trattativa", + }, + ], + title: "Stato", + }, + ]; return (
);