2026-10-23 19:56:38 -07:00
|
|
|
'use client';
|
|
|
|
|
|
2026-11-16 21:58:18 +06:00
|
|
|
import { Input } from '@/components/ui/Input';
|
2026-10-23 19:56:38 -07:00
|
|
|
import { Pill } from '@/components/ui/Pill';
|
|
|
|
|
import type { ClientStatusFilter } from './clients/types';
|
|
|
|
|
|
|
|
|
|
interface ClientsFiltersProps {
|
|
|
|
|
search: string;
|
|
|
|
|
onSearchChange: (value: string) => void;
|
|
|
|
|
status: ClientStatusFilter;
|
|
|
|
|
onStatusChange: (status: ClientStatusFilter) => void;
|
|
|
|
|
counts: Record<ClientStatusFilter, number>;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const FILTERS: { key: ClientStatusFilter; label: string }[] = [
|
|
|
|
|
{ key: 'all', label: 'All' },
|
|
|
|
|
{ key: 'online', label: 'Online' },
|
|
|
|
|
{ key: 'offline', label: 'Offline' },
|
|
|
|
|
{ key: 'pending', label: 'Pending' },
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
export function ClientsFilters({
|
|
|
|
|
search,
|
|
|
|
|
onSearchChange,
|
|
|
|
|
status,
|
|
|
|
|
onStatusChange,
|
|
|
|
|
counts,
|
|
|
|
|
}: ClientsFiltersProps) {
|
|
|
|
|
return (
|
2026-11-16 21:58:18 +06:00
|
|
|
<div className="mb-2.5 flex flex-wrap items-center gap-2">
|
|
|
|
|
<div className="w-full flex-1 sm:max-w-xs">
|
|
|
|
|
<Input
|
|
|
|
|
compact
|
|
|
|
|
icon="Search"
|
2026-10-23 19:56:38 -07:00
|
|
|
type="search"
|
|
|
|
|
aria-label="Search clients"
|
|
|
|
|
value={search}
|
|
|
|
|
onChange={(event) => onSearchChange(event.target.value)}
|
2026-11-16 21:58:18 +06:00
|
|
|
placeholder="Search client..."
|
|
|
|
|
className="bg-[var(--surface)]"
|
2026-10-23 19:56:38 -07:00
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="ml-auto flex min-w-0 gap-1 overflow-x-auto" role="group" aria-label="Filter clients by status">
|
|
|
|
|
{FILTERS.map((filter) => (
|
|
|
|
|
<Pill
|
|
|
|
|
key={filter.key}
|
|
|
|
|
active={status === filter.key}
|
|
|
|
|
onClick={() => onStatusChange(filter.key)}
|
|
|
|
|
>
|
|
|
|
|
{filter.label}
|
2026-11-16 21:58:18 +06:00
|
|
|
<span className="font-mono text-[9.5px] tabular-nums text-[var(--text-faint)]">
|
2026-10-23 19:56:38 -07:00
|
|
|
{counts[filter.key].toLocaleString()}
|
|
|
|
|
</span>
|
|
|
|
|
</Pill>
|
|
|
|
|
))}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|