diff --git a/app/components/page.tsx b/app/components/page.tsx index 5cf76ff..d9383d8 100644 --- a/app/components/page.tsx +++ b/app/components/page.tsx @@ -29,7 +29,9 @@ export function Page({ children }: PageProps): ReactElement { -
{children}
+
+ {children} +
) } diff --git a/app/routes/_index.tsx b/app/routes/_index.tsx index e596ada..f263fd6 100644 --- a/app/routes/_index.tsx +++ b/app/routes/_index.tsx @@ -1,10 +1,35 @@ +import { LoaderFunction } from '@remix-run/node' +import { Link, useLoaderData } from '@remix-run/react' import { useState } from 'react' +import slugify from 'slugify' import { Page } from '~/components/page' +import { GameDetails, fetchGames } from '~/games' import { calculateRevenue, revenueBreakdown } from '~/revenue' import { RevenueBreakdownTable } from '~/revenue/revenue-breakdown-table' +interface LoaderData { + popularGames: GameDetails[] +} + +export const loader: LoaderFunction = async () => { + const popularGameIds = [ + 367520, 1817230, 1145360, 973230, 391540, 207610, 1766740, 72850, 105600, + 1332010, 2230760, 646570, 567380, 1942280, 1708091, 379430, 488821, 322170 + ] + + const games = await fetchGames() + + const popularGames = games.filter((game) => popularGameIds.includes(game.id)) + + return { popularGames } +} + export default function HomePageRoute() { + const { popularGames } = useLoaderData() + + console.log(popularGames) + const [numberOfReviews, setNumberOfReviews] = useState('1540') const [price, setPrice] = useState('14.99') @@ -72,6 +97,44 @@ export default function HomePageRoute() { + +
+
+
+ +
+

Popular games

+
+ {popularGames.map((game) => ( +
+
+ {game.name} +
+
+
+ +

{game.name}

+ +
+
{game.description}
+
+
+ ))} +
+
) }