mirror of
https://github.com/documenso/documenso.git
synced 2026-08-20 21:41:50 +10:00
Swaps the tab row and dropdowns for faceted filter pills (status, sender, period) with a shared reset, and moves URL param handling to nuqs. <img width="2198" height="1674" alt="image" src="https://github.com/user-attachments/assets/6996431c-09c8-45c3-bc30-f0a1e503c941" />
33 lines
1023 B
TypeScript
33 lines
1023 B
TypeScript
import { useDebouncedValue } from '@documenso/lib/client-only/hooks/use-debounced-value';
|
|
import { Input } from '@documenso/ui/primitives/input';
|
|
import { msg } from '@lingui/core/macro';
|
|
import { useLingui } from '@lingui/react';
|
|
import { useQueryState } from 'nuqs';
|
|
import { useEffect, useState } from 'react';
|
|
|
|
import { documentsSearchParams } from '~/utils/documents-search-params';
|
|
|
|
export const DocumentSearch = () => {
|
|
const { _ } = useLingui();
|
|
|
|
const [query, setQuery] = useQueryState('query', documentsSearchParams.query);
|
|
|
|
const [searchTerm, setSearchTerm] = useState(query ?? '');
|
|
const debouncedSearchTerm = useDebouncedValue(searchTerm, 500);
|
|
|
|
useEffect(() => {
|
|
if (debouncedSearchTerm !== (query ?? '')) {
|
|
void setQuery(debouncedSearchTerm || null);
|
|
}
|
|
}, [debouncedSearchTerm, query, setQuery]);
|
|
|
|
return (
|
|
<Input
|
|
type="search"
|
|
placeholder={_(msg`Search documents...`)}
|
|
value={searchTerm}
|
|
onChange={(e) => setSearchTerm(e.target.value)}
|
|
/>
|
|
);
|
|
};
|