import { Button } from '@/Components/ui/button'; import { CardHeader } from '@/Components/ui/card'; import { Input } from '@/Components/ui/input'; import { Search } from 'lucide-react'; import { FormEvent, ReactNode } from 'react'; interface DataTableToolbarProps { searchValue?: string; searchPlaceholder?: string; onSearchChange?: (value: string) => void; onSearchSubmit?: (e: FormEvent) => void; filters?: ReactNode; actions?: ReactNode; children?: ReactNode; } export function DataTableToolbar({ searchValue, searchPlaceholder = 'Search...', onSearchChange, onSearchSubmit, filters, actions, children, }: DataTableToolbarProps) { const hasSearch = searchValue !== undefined && onSearchChange; if (children) { return (
{children} {actions && (
{actions}
)}
); } return (
{hasSearch && (
{ e.preventDefault(); onSearchSubmit?.(e); }} className="flex flex-1 min-w-[200px] gap-2" >
onSearchChange(e.target.value)} className="pl-10" />
{onSearchSubmit && ( )}
)} {filters} {actions && (
{actions}
)}
); }