started connect with api
This commit is contained in:
@@ -19,7 +19,8 @@ export interface ColumnMeta {
|
||||
export interface FilterField {
|
||||
id: string;
|
||||
label: string;
|
||||
options: { value: string; label: string }[];
|
||||
type?: "select" | "text";
|
||||
options?: { value: string; label: string }[];
|
||||
}
|
||||
|
||||
export interface ActiveFilter {
|
||||
@@ -246,37 +247,65 @@ function FilterDropdown({
|
||||
<label className="block text-[11px] font-semibold text-muted-foreground uppercase tracking-wider">{field.label}</label>
|
||||
|
||||
<div className="flex items-center gap-1">
|
||||
<Select value={current || "__all__"} onValueChange={(val) => onFilterChange(field.id, val === "__all__" ? "" : val)}>
|
||||
<SelectTrigger
|
||||
className={cn(
|
||||
"h-8 flex-1 text-sm gap-1.5 transition-colors",
|
||||
isFieldActive ? "border-primary text-primary [&>svg:last-child]:text-primary" : "text-muted-foreground",
|
||||
{field.type === "text" ? (
|
||||
<>
|
||||
<input
|
||||
type="text"
|
||||
value={current}
|
||||
onChange={(e) => onFilterChange(field.id, e.target.value)}
|
||||
placeholder="—"
|
||||
className={cn(
|
||||
"h-8 flex-1 rounded-md border border-input bg-background px-2.5 text-sm text-foreground",
|
||||
"placeholder:text-muted-foreground/50 focus:outline-none focus:ring-1 focus:ring-ring",
|
||||
"transition-colors",
|
||||
isFieldActive && "border-primary",
|
||||
)}
|
||||
/>
|
||||
{isFieldActive && (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => onFilterChange(field.id, "")}
|
||||
className="h-6 w-6 rounded flex items-center justify-center text-muted-foreground hover:text-foreground hover:bg-muted/60 transition-colors shrink-0"
|
||||
>
|
||||
<X size={11} />
|
||||
</button>
|
||||
)}
|
||||
>
|
||||
<span className="flex-1 text-left truncate">
|
||||
{isFieldActive ? field.options.find((o) => o.value === current)?.label : "—"}
|
||||
</span>
|
||||
</SelectTrigger>
|
||||
<SelectContent position="popper" sideOffset={4} className="p-1">
|
||||
<SelectItem value="__all__">
|
||||
<span className="text-muted-foreground">— Ählisi</span>
|
||||
</SelectItem>
|
||||
{field.options.map((opt) => (
|
||||
<SelectItem key={opt.value} value={opt.value}>
|
||||
{opt.label}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<Select value={current || "__all__"} onValueChange={(val) => onFilterChange(field.id, val === "__all__" ? "" : val)}>
|
||||
<SelectTrigger
|
||||
className={cn(
|
||||
"h-8 flex-1 text-sm gap-1.5 transition-colors",
|
||||
isFieldActive ? "border-primary text-primary [&>svg:last-child]:text-primary" : "text-muted-foreground",
|
||||
)}
|
||||
>
|
||||
<span className="flex-1 text-left truncate">
|
||||
{isFieldActive ? (field.options ?? []).find((o) => o.value === current)?.label : "—"}
|
||||
</span>
|
||||
</SelectTrigger>
|
||||
<SelectContent position="popper" sideOffset={4} className="p-1">
|
||||
<SelectItem value="__all__">
|
||||
<span className="text-muted-foreground">— Ählisi</span>
|
||||
</SelectItem>
|
||||
{(field.options ?? []).map((opt) => (
|
||||
<SelectItem key={opt.value} value={opt.value}>
|
||||
{opt.label}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
|
||||
{isFieldActive && (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => onFilterChange(field.id, "")}
|
||||
className="h-6 w-6 rounded flex items-center justify-center text-muted-foreground hover:text-foreground hover:bg-muted/60 transition-colors shrink-0"
|
||||
>
|
||||
<X size={11} />
|
||||
</button>
|
||||
{isFieldActive && (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => onFilterChange(field.id, "")}
|
||||
className="h-6 w-6 rounded flex items-center justify-center text-muted-foreground hover:text-foreground hover:bg-muted/60 transition-colors shrink-0"
|
||||
>
|
||||
<X size={11} />
|
||||
</button>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user