import { LoaderIcon, RefreshIcon } from "@lume/icons"; import { cn } from "@lume/utils"; import { useQuery } from "@tanstack/react-query"; export function HomeRoute({ colKey }: { colKey: string }) { const { data, isLoading, isError, isRefetching, refetch } = useQuery({ queryKey: [colKey], queryFn: async ({ signal }: { signal: AbortSignal }) => { const apiUrl = "https://api.waifu.im/search"; const params = { included_tags: "waifu", height: ">=2000", }; const queryParams = new URLSearchParams(params); const requestUrl = `${apiUrl}?${queryParams}`; const res = await fetch(requestUrl, { signal }); if (!res.ok) throw new Error("Failed to get image url"); const data = await res.json(); return data.images[0]; }, refetchOnMount: false, refetchOnWindowFocus: false, }); return (
{isLoading ? ( ) : isError ? (

Failed to get image, please try again later.

) : (
{data.signature}
Source
)}
); }