46 lines
1.6 KiB
TypeScript
46 lines
1.6 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 { Button } from "@/components/ui/button";
|
|
import Link from "next/link";
|
|
import { getPendingApplicationsCount, getActiveCitizenship } from "@/lib/citizenship/repository";
|
|
import { HasCitizenship } from "./has-citizenship";
|
|
import { NoCitizenship } from "./no-citizenship";
|
|
|
|
export default async function Citizenship() {
|
|
const user = await getCurrentUser()
|
|
if (!user) redirect("/")
|
|
|
|
const citizenship = await getActiveCitizenship(user.id)
|
|
const pendingCount = user.isAdmin ? await getPendingApplicationsCount() : 0
|
|
|
|
return (
|
|
<>
|
|
<Header />
|
|
<div className="flex flex-row py-16 gap-8">
|
|
<AccountMenu />
|
|
<div className="flex flex-col gap-8 max-w-lg">
|
|
<div className="flex flex-col gap-6 w-min">
|
|
<h2>Citizenship</h2>
|
|
|
|
{citizenship ? <HasCitizenship userId={user.id} /> : <NoCitizenship userId={user.id} />}
|
|
|
|
{user.isAdmin && (
|
|
<Link href="/account/citizenship/review">
|
|
<Button variant="secondary" className="w-full">
|
|
Review citizenship applications
|
|
<div className="flex items-center justify-center bg-black/50 text-white w-3.5 h-3.5 text-xs rounded-full">
|
|
{pendingCount}
|
|
</div>
|
|
</Button>
|
|
</Link>
|
|
)}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<Footer />
|
|
</>
|
|
)
|
|
} |