diff --git a/apps/web/src/app/[locale]/catalog/page.tsx b/apps/web/src/app/[locale]/catalog/page.tsx new file mode 100644 index 0000000..3bb467a --- /dev/null +++ b/apps/web/src/app/[locale]/catalog/page.tsx @@ -0,0 +1,32 @@ +import { Suspense } from "react"; +import { getGames } from "@/lib/api"; +import { CatalogFilters } from "@/components/catalog/CatalogFilters"; +import { CatalogGrid } from "@/components/catalog/CatalogGrid"; + +export default async function CatalogPage({ + params, +}: { + params: Promise<{ locale: string }>; +}) { + const { locale } = await params; + + let games: any[] = []; + try { + const res = await getGames(locale); + games = res.data; + } catch { + // Strapi not running + } + + return ( +
+

+ {locale === "es" ? "Catálogo de Juegos" : "Game Catalog"} +

+ + + + +
+ ); +} diff --git a/apps/web/src/components/catalog/CatalogFilters.tsx b/apps/web/src/components/catalog/CatalogFilters.tsx new file mode 100644 index 0000000..d42db97 --- /dev/null +++ b/apps/web/src/components/catalog/CatalogFilters.tsx @@ -0,0 +1,56 @@ +"use client"; + +import { useTranslations } from "next-intl"; +import { useRouter, useSearchParams, usePathname } from "next/navigation"; +import type { Genre, ServerStatus } from "@afterlife/shared"; + +const GENRES: Genre[] = ["MMORPG", "FPS", "Casual", "Strategy", "Sports", "Other"]; +const STATUSES: ServerStatus[] = ["online", "maintenance", "coming_soon"]; + +export function CatalogFilters() { + const t = useTranslations("catalog"); + const tGame = useTranslations("game"); + const router = useRouter(); + const pathname = usePathname(); + const searchParams = useSearchParams(); + + const currentGenre = searchParams.get("genre") || ""; + const currentStatus = searchParams.get("status") || ""; + + function setFilter(key: string, value: string) { + const params = new URLSearchParams(searchParams.toString()); + if (value) { + params.set(key, value); + } else { + params.delete(key); + } + router.push(`${pathname}?${params.toString()}`); + } + + return ( +
+ + +
+ ); +} diff --git a/apps/web/src/components/catalog/CatalogGrid.tsx b/apps/web/src/components/catalog/CatalogGrid.tsx new file mode 100644 index 0000000..9416536 --- /dev/null +++ b/apps/web/src/components/catalog/CatalogGrid.tsx @@ -0,0 +1,28 @@ +import { useTranslations } from "next-intl"; +import type { Game } from "@afterlife/shared"; +import { GameCard } from "../shared/GameCard"; + +interface CatalogGridProps { + games: Game[]; + locale: string; +} + +export function CatalogGrid({ games, locale }: CatalogGridProps) { + const t = useTranslations("catalog"); + + if (games.length === 0) { + return ( +
+

{t("no_results")}

+
+ ); + } + + return ( +
+ {games.map((game) => ( + + ))} +
+ ); +}