feat: images upload

This commit is contained in:
Ivan Rezchikov
2026-07-04 15:45:05 +03:00
parent 2eb0de5357
commit e192717466
38 changed files with 1334 additions and 615 deletions
@@ -1,5 +1,5 @@
import { IdentityCardData } from "@/lib/id/repository";
import { formatDate } from "@/lib/utils";
import { cn, formatDate } from "@/lib/utils";
import Image from "next/image";
import { Button } from "./ui/button";
import { Menu } from "lucide-react";
@@ -24,7 +24,6 @@ const DIALOG_FIELDS: DialogField[] = [
{ 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" },
];
@@ -38,25 +37,38 @@ function formatFieldValue(key: keyof IdentityCardData, value: unknown) {
return String(value);
}
function expiryDateClass(date: Date): string {
const now = new Date();
if (date < now) return "text-red-600";
const warningThreshold = new Date(now);
warningThreshold.setDate(warningThreshold.getDate() + 90);
if (date <= warningThreshold) return "text-yellow-600";
return "";
}
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">
<pattern id="identity-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">
<pattern id="identity-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)" />
<rect width="100%" height="100%" fill="url(#identity-card-waves)" />
<rect width="100%" height="100%" fill="url(#identity-card-dots)" />
</svg>
);
}
export default function IdCard({ data }: { data: IdentityCardData }) {
export default function IdentityCard({ data }: { data: IdentityCardData }) {
const expiryClass = expiryDateClass(data.expiryDate);
return (
<div className="relative w-96 bg-blue-50 rounded-lg p-4 overflow-hidden">
<CardPattern />
@@ -77,7 +89,7 @@ export default function IdCard({ data }: { data: IdentityCardData }) {
<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" />
<img src={data.profileUrl} alt="Profile" className="object-cover" />
</div>
<div className="flex flex-col gap-0 justify-center">
<DialogTitle asChild>
@@ -91,7 +103,14 @@ export default function IdCard({ data }: { data: IdentityCardData }) {
{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>
<h4
className={cn(
"leading-6",
key === "expiryDate" && expiryClass
)}
>
{formatFieldValue(key, data[key])}
</h4>
</div>
))}
<div className="flex flex-col col-span-2">
@@ -104,12 +123,12 @@ export default function IdCard({ data }: { data: IdentityCardData }) {
</div>
<div className="flex flex-row gap-8 mt-4">
<div className="flex flex-col gap-4 w-24 shrink-0">
<div className="flex flex-col gap-8 w-24 shrink-0">
<div className="relative w-24 h-28 shrink-0">
<Image src="/profile.png" fill alt="Profile" className="object-cover" />
<img src={data.profileUrl} 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" />
<img src={data.signatureUrl} alt="Signature" className="object-contain" />
</div>
</div>
<div className="flex flex-col gap-2">
@@ -150,7 +169,7 @@ export default function IdCard({ data }: { data: IdentityCardData }) {
</div>
<div className="flex flex-col min-w-fit">
<h5 className="text-blue-500">Date of expiry</h5>
<h4>{formatDate(data.expiryDate)}</h4>
<h4 className={cn(expiryClass)}>{formatDate(data.expiryDate)}</h4>
</div>
</div>
</div>
@@ -158,4 +177,4 @@ export default function IdCard({ data }: { data: IdentityCardData }) {
</div>
</div>
);
}
}