2023-02-28 21:17:58 +01:00
|
|
|
import { SimpleGrid, Text } from "@chakra-ui/react";
|
2023-02-28 20:29:37 +01:00
|
|
|
import useGames from "../hooks/useGames";
|
2023-02-28 21:17:58 +01:00
|
|
|
import GameCard from "./GameCard";
|
2023-03-01 19:53:06 +01:00
|
|
|
import GameCardSkeleton from "./GameCardSkeleton";
|
2023-02-28 20:13:26 +01:00
|
|
|
|
|
|
|
|
const GameGrid = () => {
|
2023-03-01 19:53:06 +01:00
|
|
|
const { games, error, isLoading } = useGames();
|
|
|
|
|
const skeletons = [1, 2, 3, 4, 5, 6];
|
2023-02-28 20:13:26 +01:00
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
{error && <Text>{error}</Text>}
|
2023-02-28 21:17:58 +01:00
|
|
|
<SimpleGrid
|
|
|
|
|
columns={{ sm: 1, md: 2, lg: 3, xl: 5 }}
|
|
|
|
|
padding="10px"
|
|
|
|
|
spacing={10}
|
|
|
|
|
>
|
2023-03-01 19:53:06 +01:00
|
|
|
{isLoading &&
|
|
|
|
|
skeletons.map((skeleton) => <GameCardSkeleton key={skeleton} />)}
|
2023-02-28 20:13:26 +01:00
|
|
|
{games.map((game) => (
|
2023-02-28 21:17:58 +01:00
|
|
|
<GameCard key={game.id} game={game} />
|
2023-02-28 20:13:26 +01:00
|
|
|
))}
|
2023-02-28 21:17:58 +01:00
|
|
|
</SimpleGrid>
|
2023-02-28 20:13:26 +01:00
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default GameGrid;
|