50 lines
1.7 KiB
TypeScript
50 lines
1.7 KiB
TypeScript
import Footer from "@/components/footer";
|
|
import Header from "@/components/header";
|
|
import { getCurrentUser } from "@/lib/user";
|
|
import { redirect } from "next/navigation";
|
|
import { AccountMenu } from "../../account-menu";
|
|
import { CitizenshipApplicationForm } from "./form";
|
|
import { getApplicationEligibility } from "@/lib/citizenship/repository";
|
|
import { prisma } from "@/lib/prisma";
|
|
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
|
|
import { InfoIcon } from "lucide-react";
|
|
|
|
export default async function CitizenshipApplication() {
|
|
const user = await getCurrentUser();
|
|
if (!user) redirect("/");
|
|
|
|
const eligibility = await getApplicationEligibility(user.id, user.birthDate);
|
|
const regions = await prisma.region.findMany({ orderBy: { name: "asc" } });
|
|
|
|
return (
|
|
<>
|
|
<Header />
|
|
<div className="flex flex-row py-16 gap-8">
|
|
<AccountMenu />
|
|
<div className="flex flex-col gap-8">
|
|
<div className="flex flex-col gap-6">
|
|
<h2>Citizenship application</h2>
|
|
<div className="w-96 flex flex-col gap-6">
|
|
{!eligibility.eligible ? (
|
|
<Alert variant="warning">
|
|
<InfoIcon />
|
|
<AlertTitle>Cannot submit application</AlertTitle>
|
|
<AlertDescription>{eligibility.reason}</AlertDescription>
|
|
</Alert>
|
|
) : (
|
|
<CitizenshipApplicationForm
|
|
firstName={user.firstName}
|
|
secondName={user.secondName}
|
|
sex={user.sex}
|
|
birthDate={user.birthDate!}
|
|
regions={regions}
|
|
/>
|
|
)}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<Footer />
|
|
</>
|
|
);
|
|
} |