"use client"; import { useState } from "react"; import { TMDB } from "@/lib/tmdb"; import { MovieCard } from "@/components/atoms/MovieCard"; import { SearchResult } from "@/lib/tmdb/types"; import { FC } from "react"; import { useEffect } from "react"; import { Pagination } from "@/components/atoms/Pagination"; type Props = { query: string; }; export const SearchList: FC = ({ query }) => { const [response, setResponse] = useState(null); const { results, total_results = 0, total_pages = 0, page = 1, } = response ?? {}; const handleSearch = async (query: string, page: number) => { const data = await TMDB.search({ query, page, }); setResponse(data); }; const handlePageChange = (page: number) => { window.history.replaceState({}, "", `?s=${query}&page=${page}`); window.scrollTo({ top: 0, behavior: "smooth" }); handleSearch(query, page); }; useEffect(() => { handleSearch(query, page); }, [query]); return (

{total_results} movies found for your search

{results?.map((result) => ( ))}
); };