|
| 1 | +import Link from "next/link"; |
| 2 | +import { listActiveAiGames } from "@/lib/ai-pipeline/publish"; |
| 3 | +import { dictFor } from "@/lib/i18n"; |
| 4 | +import { getLang } from "@/lib/i18n-server"; |
| 5 | +import { LiveCountdown } from "@/components/live-countdown"; |
| 6 | + |
| 7 | +/* G-07 — `/games/ai` parent route. |
| 8 | + * |
| 9 | + * Pre-PR-P: only `app/games/ai/[id]/page.tsx` existed; visiting the |
| 10 | + * bare `/games/ai` returned the generic 404 (now PR-P G-03 root |
| 11 | + * not-found, but still a dead-end for kids who guess the URL). |
| 12 | + * |
| 13 | + * This server component lists 0-3 currently-live AI envelopes via |
| 14 | + * the same `listActiveAiGames()` reader the dashboard preview uses. |
| 15 | + * Empty state is graceful: rotation hint + cron timing copy so the |
| 16 | + * player knows when the next game lands instead of seeing a blank. |
| 17 | + */ |
| 18 | +export const dynamic = "force-dynamic"; |
| 19 | + |
| 20 | +export default async function AiGamesHub() { |
| 21 | + const lang = await getLang(); |
| 22 | + const t = dictFor(lang).aiHub; |
| 23 | + const active = await listActiveAiGames(); |
| 24 | + |
| 25 | + return ( |
| 26 | + <main className="flex flex-col gap-6 max-w-4xl mx-auto animate-slide-up"> |
| 27 | + <header className="flex flex-col gap-2"> |
| 28 | + <h1 className="t-h2 text-[var(--accent)]">{t.title}</h1> |
| 29 | + <p className="text-[var(--ink-muted)]">{t.body}</p> |
| 30 | + </header> |
| 31 | + |
| 32 | + {active.length === 0 ? ( |
| 33 | + <div className="card p-6 flex flex-col items-center gap-2 text-center"> |
| 34 | + <span className="text-3xl" aria-hidden> |
| 35 | + 🤖 |
| 36 | + </span> |
| 37 | + <p className="font-semibold">{t.emptyTitle}</p> |
| 38 | + <p className="text-[var(--ink-muted)]">{t.emptyBody}</p> |
| 39 | + <p className="t-caption text-[var(--ink-subtle)] mt-2"> |
| 40 | + {t.rotationHint} |
| 41 | + </p> |
| 42 | + </div> |
| 43 | + ) : ( |
| 44 | + <ul className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4"> |
| 45 | + {active.map((envelope) => ( |
| 46 | + <li key={envelope.id}> |
| 47 | + <Link |
| 48 | + href={`/games/ai/${envelope.id}`} |
| 49 | + className="card card--interactive p-5 flex flex-col gap-2 h-full" |
| 50 | + > |
| 51 | + <div className="flex items-baseline gap-2"> |
| 52 | + <span className="text-3xl" aria-hidden> |
| 53 | + {envelope.buildingGlyph} |
| 54 | + </span> |
| 55 | + <span className="chip text-[10px] border-[var(--accent)] text-[var(--accent)]"> |
| 56 | + AI |
| 57 | + </span> |
| 58 | + </div> |
| 59 | + <h2 |
| 60 | + className="font-semibold tracking-tight text-base" |
| 61 | + lang="pl" |
| 62 | + > |
| 63 | + {envelope.title} |
| 64 | + </h2> |
| 65 | + <p |
| 66 | + className="text-sm text-[var(--ink-muted)] line-clamp-2" |
| 67 | + lang="pl" |
| 68 | + > |
| 69 | + {envelope.tagline} |
| 70 | + </p> |
| 71 | + <span className="t-caption text-[var(--ink-muted)] mt-auto"> |
| 72 | + ⏱{" "} |
| 73 | + <LiveCountdown |
| 74 | + validUntil={envelope.validUntil} |
| 75 | + svg={false} |
| 76 | + color="var(--ink-muted)" |
| 77 | + /> |
| 78 | + </span> |
| 79 | + </Link> |
| 80 | + </li> |
| 81 | + ))} |
| 82 | + </ul> |
| 83 | + )} |
| 84 | + </main> |
| 85 | + ); |
| 86 | +} |
0 commit comments