Files
EpicNext-Cms/src/app/(site)/redeem/page.tsx
T
openhands b57697b2e0 Polish content pages: share AuthTopBar, page-grid helper and responsive tables
- Extract shared AuthTopBar frosted top bar; reuse in login & register
- Add .page-grid class replacing 48 inline grid styles
- Add .table-scroll + .table-cell-truncate helpers; wrap leaderboard/staff tables
- Constrain settings page width (max-w-5xl) and stack profile card on mobile
- Use theme background var for shop category icon (dark-mode safe)
2026-08-31 12:23:06 +02:00

69 lines
1.7 KiB
TypeScript

import { eq } from "drizzle-orm";
import { redirect } from "next/navigation";
import { getTranslations } from "next-intl/server";
import { ContentCard, StatBlock } from "@/components/public/ui";
import { auth } from "@/lib/auth";
import { db, User } from "@/lib/db";
import RedeemForm from "./RedeemForm";
export default async function RedeemPage() {
const session = await auth();
if (!session?.user?.id) redirect("/login");
const t = await getTranslations("pages.redeem");
const id = Number(session.user.id);
// Show the signed-in user's current credit balance for context (fail soft).
let user: { username: string; credits: number } | null = null;
try {
const [row] = await db
.select({ username: User.username, credits: User.credits })
.from(User)
.where(eq(User.id, id))
.limit(1);
user = row ?? null;
} catch {
user = null;
}
if (!user) redirect("/login");
return (
<main className="page-grid">
<ContentCard icon="🎟️" title={t("title")} subtitle={t("subtitle")} />
<div className="card-grid sm-2">
<ContentCard icon="🔑" title={t("enterCode")}>
<RedeemForm />
<p
className="muted"
style={{ marginBottom: 0, marginTop: "0.85rem" }}
>
{t("oncePerAccount")}
</p>
</ContentCard>
<ContentCard
icon="💰"
title={t("balanceTitle")}
subtitle={t("signedInAs", { username: user.username })}
>
<div className="stat-grid">
<StatBlock
value={user.credits.toLocaleString()}
label={t("credits")}
icon="🪙"
/>
</div>
<p
className="muted"
style={{ marginBottom: 0, marginTop: "0.85rem" }}
>
{t("instantCredit")}
</p>
</ContentCard>
</div>
</main>
);
}