"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

); async function GetResults() { if (!searchedMangaTitle) { setResults(<>); return; } setResults( ); const data = await SearchedMangaResults(searchedMangaTitle); const format = (
{data && data.results && 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

)}
); setResults(format); } return (
{ setMangaSearchedTitle(event.target.value); }} onKeyDown={async (event) => { if (event.key === "Enter" || event.code === "Enter") { await GetResults(); } }} /> {results}
); }; export default MangaSearchBox;