49 lines
1.6 KiB
TypeScript
49 lines
1.6 KiB
TypeScript
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";
|
|
import { Metadata } from "next";
|
|
|
|
export const metadata: Metadata = {
|
|
title: "Citizenship",
|
|
robots: {
|
|
index: false,
|
|
follow: false,
|
|
},
|
|
};
|
|
|
|
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 (
|
|
<div className="flex flex-col md:flex-row p-4 md:p-16 gap-8 md:gap-16 mb-4 md:mb-0">
|
|
<AccountMenu />
|
|
<div className="flex flex-col gap-8 max-w-lg">
|
|
<div className="flex flex-col gap-6 md: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>
|
|
)
|
|
} |