"use client"; import { useState } from "react"; import { Input, Progress } from "@nextui-org/react"; import { SearchMovie } from "./requestsHandler"; import MovieSearchFormatter from "./searchFormatter"; const MovieSearchBar = () => { const [movieTitle, setMovieTitle] = useState(""); const [loading, setLoading] = useState(<>>); const [movieResults, setMovieResults] = useState(<>>); async function handleInputChange() { setLoading( ); const data = await SearchMovie(movieTitle); setLoading(<>>); setMovieResults(await MovieSearchFormatter(data)); } return ( { if (event.target.value.trim() !== "") { setMovieTitle(event.target.value); } }} onKeyDown={async (event) => { if (event.key === "Enter" || event.code === "Enter") { await handleInputChange(); } }} /> {loading} {movieResults} ); }; export default MovieSearchBar;