diff --git a/resources/js/components/data-table.tsx b/resources/js/components/data-table.tsx index 4edea72..e40234a 100644 --- a/resources/js/components/data-table.tsx +++ b/resources/js/components/data-table.tsx @@ -35,7 +35,7 @@ import { } from "@/components/ui/dropdown-menu"; import React from "react"; import { Input } from "./ui/input"; -import { Settings2, ChevronDown, ListFilter, Trash2, ChevronLeft, ChevronRight, ChevronsLeft, ChevronsRight, List } from "lucide-react"; +import { Settings2, ChevronDown, ListFilter, Trash2, ChevronLeft, ChevronRight, ChevronsLeft, ChevronsRight, List, X } from "lucide-react"; import { Empty, @@ -52,6 +52,7 @@ import { SelectTrigger, SelectValue, } from "@/components/ui/select" +import { Badge } from "./ui/badge"; interface DataTableFilterOption { columnId: string; @@ -168,6 +169,43 @@ export function DataTable({ onChange={(event) => setGlobalFilter(event.target.value)} className="max-w-sm" /> + + {columnFilters.length > 0 && ( +
+ {columnFilters.map((filter) => { + const filterDef = filters?.find((f) => f.columnId === filter.id); + const option = filterDef?.options.find((o) => String(o.value) === String(filter.value)); + const label = option ? option.label : String(filter.value); + + return ( + + {filterDef?.title || filter.id}: + {label} + + + ); + })} + +
+ )}
@@ -216,6 +254,7 @@ export function DataTable({ e.preventDefault()} onClick={() => column.setFilterValue(undefined)} > Semua @@ -224,6 +263,7 @@ export function DataTable({ {filter.options.map((option) => ( e.preventDefault()} onClick={() => { if (option.value === "true") column.setFilterValue(true); else if (option.value === "false") column.setFilterValue(false);