makearmy-app/app/page.tsx

50 lines
1.5 KiB
TypeScript
Raw Normal View History

2025-09-30 22:38:25 -04:00
// app/page.tsx
import { cookies } from "next/headers";
import { redirect } from "next/navigation";
import SignIn from "@/app/auth/sign-in/sign-in";
import SignUp from "@/app/auth/sign-up/sign-up";
import { isJwtValid } from "@/lib/jwt";
2025-09-30 22:38:25 -04:00
type SearchParams = { [key: string]: string | string[] | undefined };
export default async function HomePage({
searchParams,
}: {
searchParams?: SearchParams;
}) {
// If already signed in with a VALID token, go straight to the app
2025-09-30 22:38:25 -04:00
const ck = await cookies();
const at = ck.get("ma_at")?.value;
if (isJwtValid(at)) redirect("/portal");
const reauth = searchParams?.reauth === "1";
2025-09-22 10:37:53 -04:00
return (
2025-09-30 22:38:25 -04:00
<main className="mx-auto max-w-5xl px-4 py-12">
{reauth && (
<p className="mb-6 rounded-md border bg-yellow-50 p-3 text-sm text-yellow-900">
Your session expired. Please sign in again.
</p>
)}
2025-09-30 22:38:25 -04:00
<section className="mb-10 text-center">
<h1 className="text-3xl font-bold tracking-tight">MakeArmy</h1>
<p className="mt-2 text-base text-muted-foreground">
Free to use. Manage laser rigs, settings, and projectsall in one
place.
2025-09-30 22:38:25 -04:00
</p>
</section>
<section className="grid gap-6 md:grid-cols-2">
<SignUp nextPath="/portal" />
<SignIn nextPath="/portal" reauth={reauth} />
2025-09-30 22:38:25 -04:00
</section>
<section className="mt-8 text-center text-xs text-muted-foreground">
We only use cookies strictly necessary to operate the site (e.g., your
sign-in session).
2025-09-30 22:38:25 -04:00
</section>
2025-09-22 10:37:53 -04:00
</main>
);
}