feat: images upload
This commit is contained in:
@@ -11,7 +11,9 @@ import { approveApplication, rejectApplication } from "@/lib/citizenship/actions
|
||||
import { CitizenshipApplicationWithWarning } from "@/lib/citizenship/types";
|
||||
import { formatDate } from "@/lib/utils";
|
||||
import { TriangleAlertIcon } from "lucide-react";
|
||||
import Image from "next/image";
|
||||
import { useState } from "react";
|
||||
import { toast } from "sonner";
|
||||
|
||||
export default function ApplicationCard({ application, onClose }: { application: CitizenshipApplicationWithWarning | undefined, onClose: () => void }) {
|
||||
const [rejectOpen, setRejectOpen] = useState(false)
|
||||
@@ -26,20 +28,32 @@ export default function ApplicationCard({ application, onClose }: { application:
|
||||
)
|
||||
}
|
||||
|
||||
const applicationId = application.id;
|
||||
|
||||
async function handleApprove() {
|
||||
setIsLoading(true)
|
||||
await approveApplication(application.id)
|
||||
const result = await approveApplication(applicationId)
|
||||
setIsLoading(false)
|
||||
onClose()
|
||||
if (result.success) {
|
||||
toast.success("Application approved")
|
||||
onClose()
|
||||
} else {
|
||||
toast.error(result.error ?? "Failed to approve application")
|
||||
}
|
||||
}
|
||||
|
||||
async function handleReject() {
|
||||
if (!reason.trim()) return
|
||||
setIsLoading(true)
|
||||
await rejectApplication(application.id, reason)
|
||||
const result = await rejectApplication(applicationId, reason)
|
||||
setIsLoading(false)
|
||||
setRejectOpen(false)
|
||||
onClose()
|
||||
if (result.success) {
|
||||
toast.success("Application rejected")
|
||||
setRejectOpen(false)
|
||||
onClose()
|
||||
} else {
|
||||
toast.error(result.error ?? "Failed to reject application")
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
@@ -50,6 +64,18 @@ export default function ApplicationCard({ application, onClose }: { application:
|
||||
<CardDescription>{application.applicationType === "PREVIOUS_CITIZENSHIP" ? "Previous citizenship application" : "Naturalization application"}</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent className="max-w-sm">
|
||||
<div className="flex flex-row gap-2 mb-2">
|
||||
<img
|
||||
src={application.profileUrl}
|
||||
alt="Profile"
|
||||
className={"w-18 h-24 rounded-md object-cover ring-1 ring-foreground/10 shrink-0"}
|
||||
/>
|
||||
<img
|
||||
src={application.signatureUrl}
|
||||
alt="Profile"
|
||||
className={"w-36 h-18 rounded-md object-cover ring-1 ring-foreground/10 shrink-0"}
|
||||
/>
|
||||
</div>
|
||||
<div className="flex flex-col gap-1">
|
||||
<h4 className="mb-1">Personal information</h4>
|
||||
{ application.nameMismatch && (
|
||||
@@ -59,6 +85,13 @@ export default function ApplicationCard({ application, onClose }: { application:
|
||||
<AlertDescription className="w-fit max-w-full">The name on this application differs from the applicant's Kotosoft ID. Verify before approving.</AlertDescription>
|
||||
</Alert>
|
||||
)}
|
||||
{ application.previousCitizenship && (
|
||||
<Alert className="mb-2" variant="warning">
|
||||
<TriangleAlertIcon />
|
||||
<AlertTitle>Previous citizenship holder</AlertTitle>
|
||||
<AlertDescription className="w-fit max-w-full">This person previously held citizenship of the European Federation. Please verify the reason for renunciation.</AlertDescription>
|
||||
</Alert>
|
||||
)}
|
||||
<div className="flex flex-row gap-4 items-center">
|
||||
<p className="text-muted-foreground">Given names</p>
|
||||
<p>{application.givenNames}</p>
|
||||
|
||||
Reference in New Issue
Block a user