From cc84e0177753af6e0517e855187b022d80be3226 Mon Sep 17 00:00:00 2001 From: MohamedBassem Date: Sat, 23 Nov 2024 19:28:55 +0000 Subject: ui(mobile): Remove the dedicated search page and add a search bar in home --- apps/mobile/app/dashboard/search.tsx | 55 ++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 apps/mobile/app/dashboard/search.tsx (limited to 'apps/mobile/app/dashboard/search.tsx') diff --git a/apps/mobile/app/dashboard/search.tsx b/apps/mobile/app/dashboard/search.tsx new file mode 100644 index 00000000..884345e7 --- /dev/null +++ b/apps/mobile/app/dashboard/search.tsx @@ -0,0 +1,55 @@ +import { useState } from "react"; +import { Pressable, Text, View } from "react-native"; +import { router } from "expo-router"; +import BookmarkList from "@/components/bookmarks/BookmarkList"; +import FullPageError from "@/components/FullPageError"; +import CustomSafeAreaView from "@/components/ui/CustomSafeAreaView"; +import FullPageSpinner from "@/components/ui/FullPageSpinner"; +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, 10); + + const onRefresh = api.useUtils().bookmarks.searchBookmarks.invalidate; + + const { data, error, refetch, isPending } = + api.bookmarks.searchBookmarks.useQuery( + { text: query }, + { placeholderData: keepPreviousData }, + ); + + if (error) { + return refetch()} />; + } + + return ( + + + + router.back()}> + Cancel + + + {!data && } + {data && ( + + )} + + ); +} -- cgit v1.3-1-g0d28