import { PlusIcon, SearchIcon, Loader2 } from "lucide-react"; import { Button } from "../ui"; import { Textarea } from "../ui/textarea"; import { useState } from "react"; import { z } from "zod"; import { EpisodeType } from "@core/types"; import { useFetcher } from "@remix-run/react"; export const Search = () => { const [text, setText] = useState(""); const fetcher = useFetcher>(); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); fetcher.submit( { query: text }, { method: "POST", action: "/home/dashboard" }, ); }; const searchResults = () => { const data = fetcher.data as { episodes?: string[]; facts?: string[]; }; if ( (!data.episodes || data.episodes.length === 0) && (!data.facts || data.facts.length === 0) ) { return (

No results found

); } return (
{data.episodes && data.episodes.length > 0 && (

Episodes

{data.episodes.map((episode, index) => (
{episode}
))}
)} {data.facts && data.facts.length > 0 && (

Facts

{data.facts.map((fact, index) => (
{fact}
))}
)}
); }; const isLoading = fetcher.state === "submitting"; return (