"use client"; import styles from "../styles/search.module.css"; import { useState } from "react"; import { FaSearch } from "react-icons/fa"; import FetchSearchTitle from "./searchQuery"; import Image from "next/image"; import Link from "next/link"; import { PreFetchAnimeInfo } from "./cacher"; export default function DramaSearch() { const [title, setTitle] = useState(""); const [infoTitle, setInfoTitle] = useState(null); const [loadingText, setLoadingText] = useState(null); const handleSearch = async (title) => { setLoadingText(true); const data = await FetchSearchTitle(title); PreFetchAnimeInfo(data); setLoadingText(false); setInfoTitle(data); }; return (
setTitle(event.target.value)} onKeyDown={async (e) => { if ((e.key === "Enter" || e.code === 13) && title) { await handleSearch(e.target.value); } }} >
{loadingText && (

Wait a moment...

)}
{infoTitle && infoTitle.results.map((item, index) => (

{item.title}

Drama Poster
))}
); }