Is there someone using shadcn/ui data-table here? I am looking for samples to filter my data using shadcn/ui Date Range Picker to filter the current table.
Here is my Date Range Picker component:
<div className={cn("grid gap-2", className)}>
<Popover>
<PopoverTrigger asChild>
<Button
id="date"
variant={"outline"}
className={cn(
"w-[300px] justify-start text-left font-normal",
!date && "text-muted-foreground"
)}
>
<CalendarIcon className="mr-2 h-4 w-4" />
{date?.from ? (
date.to ? (
<>
{format(date.from, "LLL dd, y")} -{" "}
{format(date.to, "LLL dd, y")}
</>
) : (
format(date.from, "LLL dd, y")
)
) : (
<span>Pick a date</span>
)}
</Button>
</PopoverTrigger>
<PopoverContent className="w-auto p-0" align="start">
<Calendar
initialFocus
mode="range"
defaultMonth={date?.from}
selected={date}
onSelect={setDate}
numberOfMonths={2}
/>
</PopoverContent>
</Popover>
</div>
Here is the sample code that is currently working to filter file names:
<Input
placeholder="Search File Name..."
value={(table.getColumn("contentUri")?.getFilterValue() as string) ?? ""}
onChange={(event) =>
table.getColumn("contentUri")?.setFilterValue(event.target.value)
}
className="max-w-sm border-primary text-primary"
/>
Any help would be appreciated Thanks a lot!
I tried to create a function that handle the onSelect
but I am having an error and I think that is not the way