feat: citizenship built

This commit is contained in:
Ivan Rezchikov
2026-07-03 15:03:35 +03:00
parent c60ab9e8f9
commit 2eb0de5357
46 changed files with 1150 additions and 257 deletions
+1 -1
View File
@@ -73,7 +73,7 @@ export default function EditPageClient({ page, pageType, initialBlocks = [] }: P
return (
<div className="flex flex-col p-16 gap-12">
<div className="flex flex-row items-center justify-between">
<h1 className="">Edit page</h1>
<h1>Edit page</h1>
<div className="flex flex-row gap-3">
<Button
disabled={isPending}
+3 -3
View File
@@ -10,8 +10,8 @@ import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
import { Separator } from "@/components/ui/separator";
import Link from "next/link";
import { Button } from "@/components/ui/button";
import { ArchiveButton } from "./archiveButton";
import { PinToggleButton } from "./pinToggleButton";
import { ArchiveButton } from "./archive-button";
import { PinToggleButton } from "./pin-toggle-button";
import { getNavLinkByPageId } from "@/lib/navlinks/repository";
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table";
import Image from "next/image";
@@ -171,7 +171,7 @@ export default async function Page({ params }: { params: Promise<{ type: string;
<div className="flex flex-col p-16 gap-12">
<div className={cn("flex flex-col gap-4 justify-center", isNews && "items-center")}>
<div className="flex flex-row items-center gap-6">
<h1 className="">{page?.title}</h1>
<h1>{page?.title}</h1>
{user?.isAdmin && (
<div className="flex flex-row gap-2 items-center">
<Link href={`/${page.type.toLowerCase()}/${page.slug}/edit`}>
@@ -1,4 +1,4 @@
"use client"
"use client";
import { cn } from "@/lib/utils";
import { BookOpenTextIcon, SignatureIcon, UserIcon } from "lucide-react";
@@ -35,7 +35,7 @@ export function ApplicationsDialog({ applications }: { applications: Citizenship
<PlusIcon size={16} /><p>Created on {formatDate(application.createdAt)}</p>
</div>
<div className={cn("flex flex-row gap-2 items-center", application.status !== "PENDING" && "text-muted-foreground")}>
<ClockFadingIcon size={16} /><p>{application.status === "PENDING" ? "On review" : `Reviewed on ${formatDate(application.reviewedAt)}`}</p>
<ClockFadingIcon size={16} /><p>{application.status === "PENDING" ? "On review" : application.reviewedAt ? `Reviewed on ${formatDate(application.reviewedAt)}` : "Reviewed"}</p>
</div>
{application.status === "REJECTED" && (
<div className="flex flex-col gap-0.5 mt-2">
+76 -50
View File
@@ -37,6 +37,7 @@ type Props = {
secondName: string;
sex: string;
birthDate: Date | null;
regions: { id: string; name: string }[];
};
const initialState: ApplicationState = { success: false, errors: [] };
@@ -46,18 +47,19 @@ function formatDate(d: Date | null): string {
return d.toISOString().split("T")[0];
}
type AppType = "PREVIOUS_CITIZENSHIP" | "BORN_IN_TERRITORY" | "NATURALIZATION";
type AppType = "PREVIOUS_CITIZENSHIP" | "NATURALIZATION";
export function CitizenshipApplicationForm({ firstName, secondName, sex, birthDate }: Props) {
export function CitizenshipApplicationForm({ firstName, secondName, sex, birthDate, regions }: Props) {
const [appType, setAppType] = useState<AppType | "">("");
const [state, formAction, isPending] = useActionState(submitCitizenshipApplication, initialState);
const [isEuResident, setIsEuResident] = useState<boolean | null>(null);
return (
<form action={formAction}>
<FieldGroup>
<FieldSet>
<FieldLegend>Personal information</FieldLegend>
<Alert className="border-amber-200 bg-amber-50 text-amber-900">
<Alert variant="warning">
<InfoIcon />
<AlertTitle>Important notice</AlertTitle>
<AlertDescription>
@@ -131,18 +133,6 @@ export function CitizenshipApplicationForm({ firstName, secondName, sex, birthDa
</FieldContent>
</Field>
</FieldLabel>
<FieldLabel htmlFor="born-territory">
<Field orientation="horizontal">
<RadioGroupItem value="BORN_IN_TERRITORY" id="born-territory" />
<FieldContent>
<span className="text-sm font-medium">Born in territory</span>
<FieldDescription>
I was born in the European Federation, the former Duspean
Republic, or the Country of Reality, and do not hold citizenship.
</FieldDescription>
</FieldContent>
</Field>
</FieldLabel>
<FieldLabel htmlFor="naturalization">
<Field orientation="horizontal">
<RadioGroupItem value="NATURALIZATION" id="naturalization" />
@@ -181,26 +171,7 @@ export function CitizenshipApplicationForm({ firstName, secondName, sex, birthDa
required
/>
<FieldDescription>
The region or authority that issued your previous citizenship. The list of regions is <Link href="/page/regions">here</Link>.
</FieldDescription>
</Field>
</FieldGroup>
</FieldSet>
)}
{appType === "BORN_IN_TERRITORY" && (
<FieldSet>
<FieldLegend>Birth details</FieldLegend>
<FieldGroup>
<Field>
<FieldLabel htmlFor="birthRegion">Region of birth</FieldLabel>
<Input
id="birthRegion"
name="birthRegion"
placeholder="City, Region, Country"
required
/>
<FieldDescription>
The municipality, region, and country where you were born. The list of regions is <Link href="/page/regions">here</Link>.
The region or authority that issued your previous citizenship.
</FieldDescription>
</Field>
</FieldGroup>
@@ -225,24 +196,79 @@ export function CitizenshipApplicationForm({ firstName, secondName, sex, birthDa
</FieldGroup>
</FieldSet>
)}
<FieldSet>
<FieldLegend>Place of residence</FieldLegend>
<FieldDescription>
This will appear on your identity document.
</FieldDescription>
<FieldGroup>
<Field>
<FieldLabel>Is your residence in the European Federation?</FieldLabel>
<RadioGroup
name="isEuResident"
onValueChange={(v) => setIsEuResident(v === "yes")}
>
<Field orientation="horizontal">
<RadioGroupItem value="yes" id="eu-yes" />
<FieldLabel htmlFor="eu-yes">Yes</FieldLabel>
</Field>
<Field orientation="horizontal">
<RadioGroupItem value="no" id="eu-no" />
<FieldLabel htmlFor="eu-no">No</FieldLabel>
</Field>
</RadioGroup>
</Field>
{isEuResident === true && (
<>
<Field>
<FieldLabel htmlFor="regionId">Region</FieldLabel>
<Select name="regionId" required>
<SelectTrigger id="regionId">
<SelectValue placeholder="Select region" />
</SelectTrigger>
<SelectContent>
{regions.map((r) => (
<SelectItem key={r.id} value={r.id}>
{r.name}
</SelectItem>
))}
</SelectContent>
</Select>
</Field>
<Field>
<FieldLabel htmlFor="city">City</FieldLabel>
<Input id="city" name="city" placeholder="City or town" required />
</Field>
<Field>
<FieldLabel htmlFor="street">Street and house number</FieldLabel>
<Input id="street" name="street" placeholder="12 Via di Roma" required />
</Field>
</>
)}
{isEuResident === false && (
<Field>
<FieldLabel htmlFor="customAddress">Full address</FieldLabel>
<Input
id="customAddress"
name="customAddress"
placeholder="Street, City, Country"
required
/>
<FieldDescription>
Enter your full address as it should appear on the document.
</FieldDescription>
</Field>
)}
</FieldGroup>
</FieldSet>
<FieldSet>
<FieldLegend>Additional information</FieldLegend>
<FieldDescription>
Provide details required for your identity document.
</FieldDescription>
<FieldGroup>
<Field>
<FieldLabel htmlFor="address">Current address</FieldLabel>
<Input
id="address"
name="address"
placeholder="Street, City, Region"
required
/>
<FieldDescription>
Your current place of residence.
</FieldDescription>
</Field>
<div className="grid grid-cols-2 gap-4">
<Field>
<FieldLabel htmlFor="height">Height (in cm)</FieldLabel>
@@ -274,16 +300,16 @@ export function CitizenshipApplicationForm({ firstName, secondName, sex, birthDa
</FieldGroup>
</FieldSet>
{state.errors.length > 0 && (
<div className="rounded-lg border border-red-200 bg-red-50 p-3 text-sm text-red-900">
<Alert className="bg-red-50 p-3 text-red-900">
<ul className="list-disc pl-4">
{state.errors.map((err, i) => (
<li key={i}>{err}</li>
))}
</ul>
</div>
</Alert>
)}
<Field orientation="horizontal">
<Button type="submit">{isPending && <Spinner />}Submit application</Button>
<Button type="submit" disabled={isPending}>{isPending && <Spinner />}Submit application</Button>
</Field>
</FieldGroup>
</form>
+5 -1
View File
@@ -2,9 +2,10 @@ import Footer from "@/components/footer";
import Header from "@/components/header";
import { getCurrentUser } from "@/lib/user";
import { redirect } from "next/navigation";
import { AccountMenu } from "../../menu";
import { AccountMenu } from "../../account-menu";
import { CitizenshipApplicationForm } from "./form";
import { getUserApplications } from "@/lib/citizenship/repository";
import { prisma } from "@/lib/prisma";
export default async function CitizenshipApplication() {
const user = await getCurrentUser();
@@ -14,6 +15,8 @@ export default async function CitizenshipApplication() {
const canApply = applications.length === 0 || applications.every((a) => a.status === "REJECTED");
if (!canApply) redirect("/account/citizenship");
const regions = await prisma.region.findMany({ orderBy: { name: "asc" } });
return (
<>
<Header />
@@ -28,6 +31,7 @@ export default async function CitizenshipApplication() {
secondName={user.secondName}
sex={user.sex}
birthDate={user.birthDate}
regions={regions}
/>
</div>
</div>
+121 -81
View File
@@ -2,7 +2,7 @@ import Footer from "@/components/footer";
import Header from "@/components/header";
import { getCurrentUser } from "@/lib/user";
import { redirect } from "next/navigation";
import { AccountMenu } from "../menu";
import { AccountMenu } from "../account-menu";
import { InfoIcon } from "lucide-react";
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
import { Button } from "@/components/ui/button";
@@ -13,14 +13,31 @@ import {
AccordionItem,
AccordionTrigger,
} from "@/components/ui/accordion";
import { ApplicationsDialog } from "./applicationsDialog";
import { getUserApplications } from "@/lib/citizenship/repository";
import { ApplicationsDialog } from "./applications-dialog";
import { getPendingApplicationsCount, getUserApplications } from "@/lib/citizenship/repository";
import { prisma } from "@/lib/prisma";
import { CitizenshipApplication } from "@/lib/citizenship/types";
import { getIdentityCardData, IdentityCardData } from "@/lib/id/repository";
import IdCard from "@/components/id-card";
export default async function Citizenship() {
const user = await getCurrentUser();
if (!user) redirect("/");
const user = await getCurrentUser()
if (!user) redirect("/")
const applications = await getUserApplications(user.id);
const citizenship = await prisma.citizenship.findUnique({ where: { userId: user.id } })
let applications: CitizenshipApplication[] = []
let pendingCount = 0
let identityDocument: IdentityCardData | null = null
if (citizenship) {
identityDocument = await getIdentityCardData(user.id)
} else {
applications = await getUserApplications(user.id)
if (user.isAdmin) {
pendingCount = await getPendingApplicationsCount()
}
}
return (
<>
@@ -30,85 +47,108 @@ export default async function Citizenship() {
<div className="flex flex-col gap-8 max-w-lg">
<div className="flex flex-col gap-6 w-min">
<h2>Citizenship</h2>
<Alert className="border-amber-200 bg-amber-50 text-amber-900">
<InfoIcon />
<AlertTitle>You are not a citizen of the European Federation</AlertTitle>
<AlertDescription>
You currently hold non-citizen status. Certain civic services and
identity documents are available only to
citizens of the European Federation.
</AlertDescription>
</Alert>
<div className="flex flex-col gap-3">
<div className="flex flex-row gap-3 w-max">
<Link href="/page/citizenship"><Button variant="secondary">Learn more about citizenship</Button></Link>
<Link href="/account/citizenship/apply"><Button>Apply for the citizenship</Button></Link>
{citizenship ? (
<div className="flex flex-col gap-8">
<IdCard data={identityDocument} />
</div>
{applications.length > 0 && <ApplicationsDialog applications={applications} />}
</div>
<Accordion type="single" collapsible>
<AccordionItem value="eligibility">
<AccordionTrigger>
<h4>Who is eligible for citizenship?</h4>
</AccordionTrigger>
<AccordionContent>
Citizenship may be granted to persons born in the European
Federation, the former Duspean Republic, or the Country of Reality,
as well as to individuals who held citizenship of the Duspean
Republic or the Country of Reality on 31 March 2026.
<br />
<br />
Foreign nationals who demonstrate a commitment to the development,
prosperity, and values of the European Federation may also be
eligible for naturalisation under federal law.
</AccordionContent>
</AccordionItem>
<AccordionItem value="rights">
<AccordionTrigger>
<h4>What rights does citizenship provide?</h4>
</AccordionTrigger>
<AccordionContent>
Citizens enjoy all rights and protections guaranteed by the
Constitution and laws of the European Federation, including the
right to obtain federal identity documents, participate in federal
elections, and receive protection from federal authorities.
</AccordionContent>
</AccordionItem>
<AccordionItem value="documents">
<AccordionTrigger>
<h4>What documents are required?</h4>
</AccordionTrigger>
<AccordionContent>
Applicants may be asked to provide proof of
residence in the European Federation, evidence of eligibility, and any additional documents
required by the competent authority.
</AccordionContent>
</AccordionItem>
<AccordionItem value="processing">
<AccordionTrigger>
<h4>How long does the application process take?</h4>
</AccordionTrigger>
<AccordionContent>
Processing times vary depending on the complexity of the
application and the volume of requests currently under review.
Applicants can track the status of their application through their
account.
</AccordionContent>
</AccordionItem>
<AccordionItem value="dual">
<AccordionTrigger>
<h4>Is dual citizenship permitted?</h4>
</AccordionTrigger>
<AccordionContent>
The European Federation generally permits dual citizenship unless
otherwise restricted by federal law or international agreements.
</AccordionContent>
</AccordionItem>
</Accordion>
) : (
<div className="flex flex-col gap-6 w-min">
<Alert variant="warning">
<InfoIcon />
<AlertTitle>You are not a citizen of the European Federation</AlertTitle>
<AlertDescription>
You currently hold non-citizen status. Certain civic services and
identity documents are available only to citizens of the European Federation.
</AlertDescription>
</Alert>
<div className="flex flex-col gap-3">
<div className="flex flex-row gap-3 w-max">
<Link href="/page/citizenship">
<Button variant="secondary">Learn more about citizenship</Button>
</Link>
<Link href="/account/citizenship/apply">
<Button>Apply for citizenship</Button>
</Link>
</div>
{applications.length > 0 && (
<ApplicationsDialog applications={applications} />
)}
{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>
<Accordion type="single" collapsible>
<AccordionItem value="eligibility">
<AccordionTrigger>
<h4>Who is eligible for citizenship?</h4>
</AccordionTrigger>
<AccordionContent>
Citizenship may be granted to persons born in the European
Federation, the former Duspean Republic, or the Country of Reality,
as well as to individuals who held citizenship of the Duspean
Republic or the Country of Reality on 31 March 2026.
<br />
<br />
Foreign nationals who demonstrate a commitment to the development,
prosperity, and values of the European Federation may also be
eligible for naturalisation under federal law.
</AccordionContent>
</AccordionItem>
<AccordionItem value="rights">
<AccordionTrigger>
<h4>What rights does citizenship provide?</h4>
</AccordionTrigger>
<AccordionContent>
Citizens enjoy all rights and protections guaranteed by the
Constitution and laws of the European Federation, including the
right to obtain federal identity documents, participate in federal
elections, and receive protection from federal authorities.
</AccordionContent>
</AccordionItem>
<AccordionItem value="documents">
<AccordionTrigger>
<h4>What documents are required?</h4>
</AccordionTrigger>
<AccordionContent>
Applicants may be asked to provide proof of
residence in the European Federation, evidence of eligibility, and any additional documents
required by the competent authority.
</AccordionContent>
</AccordionItem>
<AccordionItem value="processing">
<AccordionTrigger>
<h4>How long does the application process take?</h4>
</AccordionTrigger>
<AccordionContent>
Processing times vary depending on the complexity of the
application and the volume of requests currently under review.
Applicants can track the status of their application through their
account.
</AccordionContent>
</AccordionItem>
<AccordionItem value="dual">
<AccordionTrigger>
<h4>Is dual citizenship permitted?</h4>
</AccordionTrigger>
<AccordionContent>
The European Federation generally permits dual citizenship unless
otherwise restricted by federal law or international agreements.
</AccordionContent>
</AccordionItem>
</Accordion>
</div>
)}
</div>
</div>
</div>
<Footer />
</>
);
)
}
@@ -0,0 +1,147 @@
"use client"
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
import { Button } from "@/components/ui/button";
import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from "@/components/ui/card";
import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from "@/components/ui/dialog";
import { Separator } from "@/components/ui/separator";
import { Spinner } from "@/components/ui/spinner";
import { Textarea } from "@/components/ui/textarea";
import { approveApplication, rejectApplication } from "@/lib/citizenship/actions";
import { CitizenshipApplicationWithWarning } from "@/lib/citizenship/types";
import { formatDate } from "@/lib/utils";
import { TriangleAlertIcon } from "lucide-react";
import { useState } from "react";
export default function ApplicationCard({ application, onClose }: { application: CitizenshipApplicationWithWarning | undefined, onClose: () => void }) {
const [rejectOpen, setRejectOpen] = useState(false)
const [reason, setReason] = useState("")
const [isloading, setIsLoading] = useState(false)
if (!application?.id) {
return (
<div className="w-sm flex items-center justify-center ring-1 ring-foreground/10 rounded-xl text-muted-foreground px-4">
Click on a row to see the application
</div>
)
}
async function handleApprove() {
setIsLoading(true)
await approveApplication(application.id)
setIsLoading(false)
onClose()
}
async function handleReject() {
if (!reason.trim()) return
setIsLoading(true)
await rejectApplication(application.id, reason)
setIsLoading(false)
setRejectOpen(false)
onClose()
}
return (
<>
<Card size="sm" className="mx-auto w-full">
<CardHeader>
<CardTitle><h3>{application.givenNames} {application.surname}</h3></CardTitle>
<CardDescription>{application.applicationType === "PREVIOUS_CITIZENSHIP" ? "Previous citizenship application" : "Naturalization application"}</CardDescription>
</CardHeader>
<CardContent className="max-w-sm">
<div className="flex flex-col gap-1">
<h4 className="mb-1">Personal information</h4>
{ application.nameMismatch && (
<Alert className="mb-2" variant="warning">
<TriangleAlertIcon />
<AlertTitle>Name mismatch</AlertTitle>
<AlertDescription className="w-fit max-w-full">The name on this application differs from the applicant's Kotosoft ID. Verify before approving.</AlertDescription>
</Alert>
)}
<div className="flex flex-row gap-4 items-center">
<p className="text-muted-foreground">Given names</p>
<p>{application.givenNames}</p>
</div>
<div className="flex flex-row gap-4 items-center">
<p className="text-muted-foreground">Surname</p>
<p>{application.surname}</p>
</div>
<div className="flex flex-row gap-4 items-center">
<p className="text-muted-foreground">Sex</p>
<p>{application.sex}</p>
</div>
<div className="flex flex-row gap-4 items-center">
<p className="text-muted-foreground">Birthdate</p>
<p>{formatDate(application.birthDate)}</p>
</div>
<div className="flex flex-col gap-0.5">
<p className="text-muted-foreground">Address</p>
<p className="truncate">{application.address}</p>
</div>
<div className="flex flex-row gap-4 items-center">
<p className="text-muted-foreground">Height</p>
<p>{application.height} cm</p>
</div>
<div className="flex flex-row gap-4 items-center">
<p className="text-muted-foreground">Eye color</p>
<p>{application.eyeColor}</p>
</div>
<Separator className="my-2" />
<h4 className="mb-1">Eligibility proofs</h4>
{
application.applicationType == "PREVIOUS_CITIZENSHIP" && (
<div className="flex flex-col gap-1">
<div className="flex flex-row gap-4 items-center">
<p className="text-muted-foreground truncate">Country of previous citizenship</p>
<p className="truncate">{application.previousCountry == "DUS" ? "Duspean Republic" : "Country of Reality"}</p>
</div>
<div className="flex flex-row gap-4 items-center">
<p className="text-muted-foreground truncate">Region of previous residence</p>
<p className="truncate">{application.previousRegion}</p>
</div>
</div>
)
}
{
application.applicationType == "NATURALIZATION" && (
<div className="flex flex-col gap-0.5">
<p className="text-muted-foreground">Naturalization reason</p>
<p>{application.naturalizationReason}</p>
</div>
)
}
</div>
</CardContent>
<CardFooter className="gap-2">
<Button onClick={handleApprove} disabled={isloading}>
{isloading && <Spinner />}Approve
</Button>
<Button variant="outline" onClick={() => setRejectOpen(true)} disabled={isloading}>
{isloading && <Spinner />}Reject
</Button>
<Button variant="outline" onClick={onClose}>Close</Button>
</CardFooter>
</Card>
<Dialog open={rejectOpen} onOpenChange={setRejectOpen}>
<DialogContent>
<DialogHeader>
<DialogTitle asChild><h3>Reject application</h3></DialogTitle>
<DialogDescription>Provide a reason. The applicant will see this.</DialogDescription>
</DialogHeader>
<Textarea
placeholder="Reason for rejection..."
value={reason}
onChange={(e) => setReason(e.target.value)}
/>
<DialogFooter>
<Button variant="outline" onClick={() => setRejectOpen(false)}>Cancel</Button>
<Button variant="destructive" onClick={handleReject} disabled={!reason.trim() || isloading}>
{isloading && <Spinner />}Confirm rejection
</Button>
</DialogFooter>
</DialogContent>
</Dialog>
</>
)
}
+26
View File
@@ -0,0 +1,26 @@
"use client"
import { CitizenshipApplication } from "@/lib/citizenship/types";
import { DataTable } from "./data-table";
import { columns } from "./columns";
import ApplicationCard from "./application-card";
import { useState } from "react";
export default function ReviewPageClient({ applications }: { applications: CitizenshipApplication[] }) {
const [selectedApplicationId, setSelectedApplicationId] = useState("");
return (
<>
<div className="flex flex-row gap-16">
<div className="flex flex-col gap-8">
<div className="flex flex-col gap-6">
<h2>Review citizenship applications</h2>
</div>
<DataTable columns={columns} data={applications} onRowClick={(app) => setSelectedApplicationId(app.id)} />
</div>
<ApplicationCard application={applications.find((a) => a.id === selectedApplicationId)} onClose={() => setSelectedApplicationId("")} />
</div>
</>
)
}
@@ -0,0 +1,37 @@
"use client"
import { ColumnDef } from "@tanstack/react-table";
import { CitizenshipApplication } from "@/lib/citizenship/types";
import { Badge } from "@/components/ui/badge";
import { formatDate } from "@/lib/utils";
export const columns: ColumnDef<CitizenshipApplication>[] = [
{
accessorKey: "surname",
header: "Applicant",
cell: ({ row }) => {
const application = row.original
return <span>{application.givenNames} {application.surname}</span>
},
},
{
accessorKey: "birthDate",
header: "Birth date",
cell: ({ row }) => formatDate(row.getValue("birthDate")),
},
{
accessorKey: "applicationType",
header: "Type",
cell: ({ row }) => {
return <span>{row.original.applicationType === "PREVIOUS_CITIZENSHIP" ? "Previous citizenship" : "Naturalization"}</span>
},
},
{
accessorKey: "status",
header: "Status",
cell: ({ row }) => {
const status = row.getValue("status") as string
return <Badge variant={status === "PENDING" ? "outline" : "default"}>{status}</Badge>
},
},
]
@@ -0,0 +1,51 @@
"use client"
import { ColumnDef, flexRender, getCoreRowModel, useReactTable } from "@tanstack/react-table";
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table";
interface DataTableProps<TData, TValue> {
columns: ColumnDef<TData, TValue>[];
data: TData[];
onRowClick?: (row: TData) => void;
}
export function DataTable<TData, TValue>({ columns, data, onRowClick }: DataTableProps<TData, TValue>) {
const table = useReactTable({
data,
columns,
getCoreRowModel: getCoreRowModel(),
});
return (
<div className="overflow-hidden rounded-md w-full">
<Table>
<TableHeader>
{table.getHeaderGroups().map((headerGroup) => (
<TableRow key={headerGroup.id}>
{headerGroup.headers.map((header) => (
<TableHead key={header.id}>
{header.isPlaceholder ? null : flexRender(
header.column.columnDef.header,
header.getContext()
)}
</TableHead>
))}
</TableRow>
))}
</TableHeader>
<TableBody>
{table.getRowCount() === 0 && <h5 className="mt-2 text-muted-foreground">There are no pending applications</h5>}
{table.getRowModel().rows.map((row) => (
<TableRow key={row.id} className="cursor-pointer" onClick={() => onRowClick?.(row.original)}>
{row.getVisibleCells().map((cell) => (
<TableCell key={cell.id}>
{flexRender(cell.column.columnDef.cell, cell.getContext())}
</TableCell>
))}
</TableRow>
))}
</TableBody>
</Table>
</div>
)
}
+30
View File
@@ -0,0 +1,30 @@
import Header from "@/components/header";
import Footer from "@/components/footer";
import ReviewPageClient from "./client";
import { getCurrentUser } from "@/lib/user";
import { redirect } from "next/navigation";
import { AccountMenu } from "../../account-menu";
import { getPendingApplications } from "@/lib/citizenship/repository";
export default async function ReviewPage() {
const user = await getCurrentUser();
if (!user?.isAdmin) redirect("/account/citizenship");
const applications = await getPendingApplications()
const applicationsWithWarning = applications.map((app) => ({
...app,
nameMismatch: app.givenNames !== app.user.firstName || app.surname !== app.user.secondName,
}))
return (
<>
<Header />
<div className="flex flex-row py-16 gap-8">
<AccountMenu />
<ReviewPageClient applications={applicationsWithWarning} />
</div>
<Footer />
</>
);
}
@@ -1,4 +1,4 @@
"use client"
"use client";
import { useTransition } from "react";
import {
@@ -1,4 +1,4 @@
"use client"
"use client";
import { useTransition } from "react";
import { Button } from "@/components/ui/button";
+4 -4
View File
@@ -5,10 +5,10 @@ import { getCurrentUser } from "@/lib/user";
import { formatDate } from "@/lib/utils";
import { BookOpenTextIcon, SignatureIcon, UserIcon } from "lucide-react";
import { redirect } from "next/navigation";
import { DeleteDialog } from "./deleteDialog";
import { LogoutButton } from "./logoutButton";
import { UpdateButton } from "./updateButton";
import { AccountMenu } from "./menu";
import { DeleteDialog } from "./delete-dialog";
import { LogoutButton } from "./logout-button";
import { UpdateButton } from "./update-button";
import { AccountMenu } from "./account-menu";
function ProfileField({ label, value }: { label: string; value: string }) {
return (
@@ -1,4 +1,4 @@
"use client"
"use client";
import { useTransition } from "react";
import { Button } from "@/components/ui/button";
+1 -1
View File
@@ -65,7 +65,7 @@ export default function CreatePageClient() {
return (
<div className="flex flex-col p-16 gap-12">
<div className="flex flex-row items-center justify-between">
<h1 className="">Create page</h1>
<h1>Create page</h1>
<div className="flex flex-row gap-3">
<Button
variant="outline"
+3 -3
View File
@@ -1,7 +1,7 @@
import DraftsDialog from "@/components/drafts";
import DraftsDialog from "@/components/drafts-dialog";
import Footer from "@/components/footer";
import Header from "@/components/header";
import { NewsCard } from "@/components/newsCard";
import { NewsCard } from "@/components/news-card";
import { Button } from "@/components/ui/button";
import { getPages } from "@/lib/pages/repository";
import { getCurrentUser } from "@/lib/user";
@@ -21,7 +21,7 @@ export default async function News() {
<Header />
<div className="flex flex-col p-16 gap-16">
<div className="flex flex-row items-center justify-between">
<h1 className="">News</h1>
<h1>News</h1>
<div className="flex flex-row items-center gap-4">
{user?.isAdmin && (
<div className="flex flex-row items-center gap-4">
+2 -2
View File
@@ -1,6 +1,6 @@
import Footer from "@/components/footer";
import Header from "@/components/header";
import { NewsCard } from "@/components/newsCard";
import { NewsCard } from "@/components/news-card";
import { getPages } from "@/lib/pages/repository";
import { ArrowRightIcon } from "lucide-react";
import Link from "next/link";
@@ -39,7 +39,7 @@ export default async function Home() {
</div>
</div>
<div className="flex flex-col gap-8 mt-8">
<h1 className="">Recent news</h1>
<h1>Recent news</h1>
<div className="flex flex-col gap-6">
{
news.length > 0 ? news.map((n) => (