import { POPULAR_SHOWS, TRENDING_SHOWS, TOP_SHOWS } from "./data-fetch"; import styles from "../styles/pages.module.css"; import Image from "next/image"; import Link from "next/link"; import PreFecthSeriesInfo from "./cacher"; const HomepageUtils = async (type) => { const fetchFunctions = { popular: POPULAR_SHOWS, trending: TRENDING_SHOWS, top: TOP_SHOWS, }; const fetchData = fetchFunctions[type]; if (fetchData) { return await fetchData(); } else { return; } }; const Pages = async ({ type: type }) => { const data = await HomepageUtils(type); PreFecthSeriesInfo(data); return (

{type} series

{data && data.results.length > 0 && data.results.map((item, index) => (
Series Poster

{item.name || "Not sure"}

))}
); }; export default Pages;