"use client"; import { IconRefresh } from "@tabler/icons-react"; import { Button } from "@kandev/ui/button"; import { Input } from "@kandev/ui/input"; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@kandev/ui/select"; import { cn } from "@/lib/utils"; import { formatRelativeTime } from "@/lib/utils"; const ALL_REPOS = "__all__"; type ListToolbarProps = { title: string; count: number; loading: boolean; lastFetchedAt: Date | null; customQuery: string; committedQuery: string; onCustomQueryChange: (value: string) => void; onCommitCustomQuery: () => void; repoFilter: string; onRepoFilterChange: (value: string) => void; repoOptions: string[]; onRefresh: () => void; }; export function ListToolbar({ title, count, loading, lastFetchedAt, customQuery, committedQuery, onCustomQueryChange, onCommitCustomQuery, repoFilter, onRepoFilterChange, repoOptions, onRefresh, }: ListToolbarProps) { const selectValue = repoFilter || ALL_REPOS; const dirty = customQuery !== committedQuery; return (

{title}

{loading ? "…" : count}
onCustomQueryChange(e.target.value)} onKeyDown={(e) => { if (e.key === "Enter") { e.preventDefault(); onCommitCustomQuery(); } }} onBlur={() => { if (dirty) onCommitCustomQuery(); }} placeholder='Custom query — press Enter. e.g. "is:open review-requested:@me"' className="h-8 pr-20" /> {dirty && ( Press Enter )}
{lastFetchedAt && !loading && ( Updated {formatRelativeTime(lastFetchedAt.toISOString())} )}
); }