blob: 043dffab4ddd8f1a0f78231bed3641ad857d6714 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
import { useState } from "react";
import { View } from "react-native";
import BookmarkList from "@/components/bookmarks/BookmarkList";
import { Divider } from "@/components/ui/Divider";
import { Input } from "@/components/ui/Input";
import { api } from "@/lib/trpc";
import { keepPreviousData } from "@tanstack/react-query";
import { useDebounce } from "use-debounce";
export default function Search() {
const [search, setSearch] = useState("");
const [query] = useDebounce(search, 200);
const { data } = api.bookmarks.searchBookmarks.useQuery(
{ text: query },
{ placeholderData: keepPreviousData },
);
return (
<View>
<Input
placeholder="Search"
className="mx-4 mt-4 bg-white"
value={search}
onChangeText={setSearch}
autoFocus
autoCapitalize="none"
/>
<Divider orientation="horizontal" className="mt-4 w-full" />
{data && <BookmarkList ids={data.bookmarks.map((b) => b.id)} />}
</View>
);
}
|