"use client"; import { Input, Progress, Card, CardBody, Image, Chip, } from "@nextui-org/react"; import Link from "next/link"; import { useState } from "react"; import { SearchedMangaResults } from "./requests"; const MangaSearchBox = () => { const [searchedMangaTitle, setMangaSearchedTitle] = useState(""); const [results, setResults] = useState(

Start typing and results will show here

, ); const [loading, setLoading] = useState(<>); async function GetResults() { if (!searchedMangaTitle) { setResults(<>); return; } setLoading( , ); const data = await SearchedMangaResults(searchedMangaTitle); const format = (
{data && data.results.length > 0 ? ( data.results.map((item, index) => (

{item.title.english || item.title.romaji}

{item.genres && item.genres.map((item, index) => ( {item} ))}
)) ) : (

No results found for the searched title

)}
); setLoading(<>); setResults(format); } return (
{ setMangaSearchedTitle(event.target.value); }} onKeyDown={async () => { await GetResults(); }} /> {loading} {results}
); }; export default MangaSearchBox;