feat(dashboard): add basic search to profiles

This commit is contained in:
Carl-Gerhard Lindesvärd
2024-09-05 22:08:35 +02:00
parent 9881f34e53
commit b19a874a0b
4 changed files with 74 additions and 38 deletions

View File

@@ -1,6 +1,9 @@
'use client';
import { TableButtons } from '@/components/data-table';
import { ProfilesTable } from '@/components/profiles/table';
import { Input } from '@/components/ui/input';
import { useDebounceValue } from '@/hooks/useDebounceValue';
import { api } from '@/trpc/client';
import { parseAsInteger, useQueryState } from 'nuqs';
@@ -14,12 +17,17 @@ const Events = ({ projectId }: Props) => {
'cursor',
parseAsInteger.withDefault(0)
);
const [search, setSearch] = useQueryState('search', {
defaultValue: '',
shallow: true,
});
const debouncedSearch = useDebounceValue(search, 500);
const query = api.profile.list.useQuery(
{
cursor,
projectId,
take: 50,
// filters,
search: debouncedSearch,
},
{
keepPreviousData: true,
@@ -28,6 +36,13 @@ const Events = ({ projectId }: Props) => {
return (
<div>
<TableButtons>
<Input
value={search}
onChange={(e) => setSearch(e.target.value)}
placeholder="Search profiles"
/>
</TableButtons>
<ProfilesTable query={query} cursor={cursor} setCursor={setCursor} />
</div>
);