import type { NextPage } from 'next' import {GetServerSideProps} from 'next'; import {Game} from '../../utils/games'; import Link from 'next/link'; import Head from 'next/head'; import Image from 'next/image'; import {useState} from 'react'; type HomeProps = { games: Game[], } const GamesPage: NextPage = ({ games, }) => { const [displayGames, setDisplayGames] = useState(games); const handleImageError = (game: Game) => () => { setDisplayGames((games) => games.map(g => ({ ...g, thumbnail: g.id === game.id ? undefined : g.thumbnail, }))) } return ( <> Flash Games
) } export const getServerSideProps: GetServerSideProps = async (ctx) => { const response = await fetch('http://localhost:3000/api/games'); if (response.status !== 200) { return { notFound: true, } } const games = await response.json(); return { props: { games, } } } export default GamesPage