feat: citizenship built
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
"use client"
|
||||
"use client";
|
||||
|
||||
import { Button } from "@/components/ui/button"
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
Dialog,
|
||||
DialogContent,
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
DialogTrigger,
|
||||
} from "@/components/ui/dialog"
|
||||
} from "@/components/ui/dialog";
|
||||
import { deletePageAction } from "@/lib/pages/actions";
|
||||
import { PencilIcon, XIcon } from "lucide-react";
|
||||
import Link from "next/link";
|
||||
@@ -24,9 +24,9 @@ export default function DraftsDialog({ drafts }: { drafts: Draft[]}) {
|
||||
async function deletePage(id: string, type: PageType) {
|
||||
setIsDeletingId(id);
|
||||
try {
|
||||
await deletePageAction(id, type)
|
||||
await deletePageAction(id, type);
|
||||
} finally {
|
||||
setIsDeletingId("")
|
||||
setIsDeletingId("");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,161 @@
|
||||
import { IdentityCardData } from "@/lib/id/repository";
|
||||
import { formatDate } from "@/lib/utils";
|
||||
import Image from "next/image";
|
||||
import { Button } from "./ui/button";
|
||||
import { Menu } from "lucide-react";
|
||||
import {
|
||||
Dialog,
|
||||
DialogContent,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
DialogTrigger,
|
||||
} from "@/components/ui/dialog";
|
||||
|
||||
type DialogField = {
|
||||
key: keyof IdentityCardData;
|
||||
label: string;
|
||||
};
|
||||
|
||||
const DIALOG_FIELDS: DialogField[] = [
|
||||
{ key: "sex", label: "Sex" },
|
||||
{ key: "birthDate", label: "Date of birth" },
|
||||
{ key: "authority", label: "Authority" },
|
||||
{ key: "nationality", label: "Nationality" },
|
||||
{ key: "issueDate", label: "Date of issue" },
|
||||
{ key: "expiryDate", label: "Date of expiry" },
|
||||
{ key: "issuingCountry", label: "Issuing country" },
|
||||
{ key: "origin", label: "Place of origin" },
|
||||
{ key: "height", label: "Height" },
|
||||
{ key: "eyeColor", label: "Eye color" },
|
||||
];
|
||||
|
||||
const ADDRESS_FIELD: DialogField = { key: "address", label: "Address" };
|
||||
|
||||
function formatFieldValue(key: keyof IdentityCardData, value: unknown) {
|
||||
if (value instanceof Date) return formatDate(value);
|
||||
if (value == null) return "—";
|
||||
if (key === "height") return `${value} cm`;
|
||||
return String(value);
|
||||
}
|
||||
|
||||
function CardPattern() {
|
||||
return (
|
||||
<svg className="absolute inset-0 w-full h-full" aria-hidden="true">
|
||||
<defs>
|
||||
<pattern id="id-card-waves" width="120" height="16" patternUnits="userSpaceOnUse">
|
||||
<path d="M0 8 Q15 2 30 8 T60 8 T90 8 T120 8" fill="none" stroke="#bfdbfe" strokeWidth="1" />
|
||||
</pattern>
|
||||
<pattern id="id-card-dots" width="24" height="24" patternUnits="userSpaceOnUse">
|
||||
<circle cx="4" cy="4" r="1.5" fill="white" />
|
||||
<circle cx="16" cy="14" r="1.5" fill="white" />
|
||||
</pattern>
|
||||
</defs>
|
||||
<rect width="100%" height="100%" fill="url(#id-card-waves)" />
|
||||
<rect width="100%" height="100%" fill="url(#id-card-dots)" />
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
|
||||
export default function IdCard({ data }: { data: IdentityCardData }) {
|
||||
return (
|
||||
<div className="relative w-96 bg-blue-50 rounded-lg p-4 overflow-hidden">
|
||||
<CardPattern />
|
||||
<div className="relative z-10">
|
||||
<div className="flex flex-row items-center justify-between">
|
||||
<div className="flex flex-row gap-3 items-center">
|
||||
<Image src="/emblem.png" width={24} height={24} alt="Emblem" />
|
||||
<h2>ID Card</h2>
|
||||
</div>
|
||||
<h3>{data.documentNumber}</h3>
|
||||
<Dialog>
|
||||
<DialogTrigger asChild>
|
||||
<Button size="icon-sm">
|
||||
<Menu />
|
||||
</Button>
|
||||
</DialogTrigger>
|
||||
<DialogContent>
|
||||
<DialogHeader>
|
||||
<div className="flex flex-row gap-3">
|
||||
<div className="relative w-12 h-14 shrink-0 rounded overflow-hidden">
|
||||
<Image src="/profile.png" fill alt="Profile" className="object-cover" />
|
||||
</div>
|
||||
<div className="flex flex-col gap-0 justify-center">
|
||||
<DialogTitle asChild>
|
||||
<h4 className="uppercase">{data.surname} {data.givenNames}</h4>
|
||||
</DialogTitle>
|
||||
<h4 className="text-muted-foreground">{data.documentNumber}</h4>
|
||||
</div>
|
||||
</div>
|
||||
</DialogHeader>
|
||||
<div className="grid grid-cols-2 gap-x-6 gap-y-2">
|
||||
{DIALOG_FIELDS.map(({ key, label }) => (
|
||||
<div className="flex flex-col" key={key}>
|
||||
<h5 className="text-blue-500">{label}</h5>
|
||||
<h4 className="leading-6">{formatFieldValue(key, data[key])}</h4>
|
||||
</div>
|
||||
))}
|
||||
<div className="flex flex-col col-span-2">
|
||||
<h5 className="text-blue-500">{ADDRESS_FIELD.label}</h5>
|
||||
<h4 className="leading-6">{formatFieldValue(ADDRESS_FIELD.key, data[ADDRESS_FIELD.key])}</h4>
|
||||
</div>
|
||||
</div>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</div>
|
||||
|
||||
<div className="flex flex-row gap-8 mt-4">
|
||||
<div className="flex flex-col gap-4 w-24 shrink-0">
|
||||
<div className="relative w-24 h-28 shrink-0">
|
||||
<Image src="/profile.png" fill alt="Profile" className="object-cover" />
|
||||
</div>
|
||||
<div className="relative w-24 h-12 shrink-0">
|
||||
<Image src="/signature.png" fill alt="Signature" className="object-contain" />
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex flex-col gap-2">
|
||||
<div className="flex flex-wrap gap-x-6 gap-y-2">
|
||||
<div className="flex flex-col min-w-fit">
|
||||
<h5 className="text-blue-500">Surname</h5>
|
||||
<h4 className="uppercase">{data.surname}</h4>
|
||||
</div>
|
||||
<div className="flex flex-col min-w-fit">
|
||||
<h5 className="text-blue-500">Given name(s)</h5>
|
||||
<h4 className="uppercase">{data.givenNames}</h4>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex flex-wrap gap-x-6 gap-y-2">
|
||||
<div className="flex flex-col min-w-fit">
|
||||
<h5 className="text-blue-500">Sex</h5>
|
||||
<h4>{data.sex}</h4>
|
||||
</div>
|
||||
<div className="flex flex-col min-w-fit">
|
||||
<h5 className="text-blue-500">Date of birth</h5>
|
||||
<h4>{formatDate(data.birthDate)}</h4>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex flex-wrap gap-x-6 gap-y-2">
|
||||
<div className="flex flex-col min-w-fit">
|
||||
<h5 className="text-blue-500">Authority</h5>
|
||||
<h4 className="leading-6">{data.authority}</h4>
|
||||
</div>
|
||||
<div className="flex flex-col min-w-fit">
|
||||
<h5 className="text-blue-500">Nationality</h5>
|
||||
<h4>{data.nationality}</h4>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex flex-wrap gap-x-6 gap-y-2">
|
||||
<div className="flex flex-col min-w-fit">
|
||||
<h5 className="text-blue-500">Issue date</h5>
|
||||
<h4>{formatDate(data.issueDate)}</h4>
|
||||
</div>
|
||||
<div className="flex flex-col min-w-fit">
|
||||
<h5 className="text-blue-500">Date of expiry</h5>
|
||||
<h4>{formatDate(data.expiryDate)}</h4>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
import { Page, PageMeta } from "@/lib/pages/types";
|
||||
import { PageMeta, PagePublic } from "@/lib/pages/types";
|
||||
import { CalendarIcon, Globe2Icon } from "lucide-react";
|
||||
import Link from "next/link";
|
||||
import { Badge } from "./ui/badge";
|
||||
import { formatDate } from "@/lib/utils";
|
||||
|
||||
export function NewsCard({ news }: { news: Page }) {
|
||||
export function NewsCard({ news }: { news: PagePublic }) {
|
||||
return (
|
||||
<div className="flex flex-col gap-2">
|
||||
<Link href={`/news/${news.slug}`} className="w-max">
|
||||
@@ -20,5 +20,5 @@ export function NewsCard({ news }: { news: Page }) {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -11,6 +11,8 @@ const alertVariants = cva(
|
||||
default: "bg-card text-card-foreground",
|
||||
destructive:
|
||||
"bg-card text-destructive *:data-[slot=alert-description]:text-destructive/90 *:[svg]:text-current",
|
||||
warning:
|
||||
"border-amber-200 bg-amber-50 text-amber-900 dark:border-amber-900 dark:bg-amber-950 dark:text-amber-5",
|
||||
},
|
||||
},
|
||||
defaultVariants: {
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
import * as React from "react"
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
function Card({
|
||||
className,
|
||||
size = "default",
|
||||
...props
|
||||
}: React.ComponentProps<"div"> & { size?: "default" | "sm" }) {
|
||||
return (
|
||||
<div
|
||||
data-slot="card"
|
||||
data-size={size}
|
||||
className={cn(
|
||||
"group/card flex flex-col gap-(--card-spacing) overflow-hidden rounded-xl bg-card py-(--card-spacing) text-sm text-card-foreground ring-1 ring-foreground/10 [--card-spacing:--spacing(4)] has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:[--card-spacing:--spacing(3)] data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function CardHeader({ className, ...props }: React.ComponentProps<"div">) {
|
||||
return (
|
||||
<div
|
||||
data-slot="card-header"
|
||||
className={cn(
|
||||
"group/card-header @container/card-header grid auto-rows-min items-start gap-1 rounded-t-xl px-(--card-spacing) has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-(--card-spacing)",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function CardTitle({ className, ...props }: React.ComponentProps<"div">) {
|
||||
return (
|
||||
<div
|
||||
data-slot="card-title"
|
||||
className={cn(
|
||||
"cn-font-heading text-base leading-snug font-medium group-data-[size=sm]/card:text-sm",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function CardDescription({ className, ...props }: React.ComponentProps<"div">) {
|
||||
return (
|
||||
<div
|
||||
data-slot="card-description"
|
||||
className={cn("text-sm text-muted-foreground", className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function CardAction({ className, ...props }: React.ComponentProps<"div">) {
|
||||
return (
|
||||
<div
|
||||
data-slot="card-action"
|
||||
className={cn(
|
||||
"col-start-2 row-span-2 row-start-1 self-start justify-self-end",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function CardContent({ className, ...props }: React.ComponentProps<"div">) {
|
||||
return (
|
||||
<div
|
||||
data-slot="card-content"
|
||||
className={cn("px-(--card-spacing)", className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function CardFooter({ className, ...props }: React.ComponentProps<"div">) {
|
||||
return (
|
||||
<div
|
||||
data-slot="card-footer"
|
||||
className={cn(
|
||||
"flex items-center rounded-b-xl border-t bg-muted/50 p-(--card-spacing)",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
export {
|
||||
Card,
|
||||
CardHeader,
|
||||
CardFooter,
|
||||
CardTitle,
|
||||
CardAction,
|
||||
CardDescription,
|
||||
CardContent,
|
||||
}
|
||||
Reference in New Issue
Block a user