add: news search bar, application history
This commit is contained in:
@@ -10,8 +10,8 @@ import { Textarea } from "@/components/ui/textarea";
|
||||
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
|
||||
import { approveApplication, rejectApplication } from "@/lib/citizenship/actions";
|
||||
import { CitizenshipApplicationWithWarning } from "@/lib/citizenship/types";
|
||||
import { formatDate } from "@/lib/utils";
|
||||
import { TriangleAlertIcon } from "lucide-react";
|
||||
import { cn, formatDate } from "@/lib/utils";
|
||||
import { CheckIcon, ClockFadingIcon, PlusIcon, TriangleAlertIcon, XIcon } from "lucide-react";
|
||||
import { useState } from "react";
|
||||
import { toast } from "sonner";
|
||||
|
||||
@@ -36,7 +36,6 @@ export default function ApplicationCard({ application, onClose }: { application:
|
||||
setIsLoading(false)
|
||||
if (result.success) {
|
||||
toast.success("Application approved")
|
||||
onClose()
|
||||
} else {
|
||||
toast.error(result.error ?? "Failed to approve application")
|
||||
}
|
||||
@@ -50,7 +49,6 @@ export default function ApplicationCard({ application, onClose }: { application:
|
||||
if (result.success) {
|
||||
toast.success("Application rejected")
|
||||
setRejectOpen(false)
|
||||
onClose()
|
||||
} else {
|
||||
toast.error(result.error ?? "Failed to reject application")
|
||||
}
|
||||
@@ -64,14 +62,14 @@ 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-3 mb-4">
|
||||
{application.status !== "REJECTED" && (<div className="flex flex-row gap-3 mb-4">
|
||||
<div className="w-20 aspect-4/5 rounded-md overflow-hidden ring-1 ring-foreground/10 shrink-0">
|
||||
<img src={application.profileUrl} alt="Profile photo" className="w-full h-full object-cover" />
|
||||
</div>
|
||||
<div className="w-40 px-2 aspect-5/2 rounded-md overflow-hidden ring-1 ring-foreground/10 shrink-0 bg-white">
|
||||
<img src={application.signatureUrl} alt="Signature" className="w-full h-full object-contain" />
|
||||
</div>
|
||||
</div>
|
||||
</div>)}
|
||||
<div className="flex flex-col gap-1">
|
||||
<h4 className="mb-1">Personal information</h4>
|
||||
{ application.nameMismatch && (
|
||||
@@ -147,17 +145,51 @@ export default function ApplicationCard({ application, onClose }: { application:
|
||||
</div>
|
||||
)
|
||||
}
|
||||
<Separator className="my-2" />
|
||||
<div className="flex flex-col gap-1">
|
||||
<h4 className="mb-1">Application history</h4>
|
||||
</div>
|
||||
<div className="flex flex-col gap-1">
|
||||
<div className="flex flex-row gap-2 items-center text-muted-foreground">
|
||||
<PlusIcon size={16} /><p>Created on {formatDate(application.createdAt)}</p>
|
||||
</div>
|
||||
{application.status !== "PENDING" && (<div className="flex flex-row gap-2 items-center text-muted-foreground">
|
||||
<ClockFadingIcon size={16} /><p>{application.reviewedAt ? `Reviewed on ${formatDate(application.reviewedAt)} by ${application.reviewer?.firstName} ${application.reviewer?.secondName}` : "Reviewed"}</p>
|
||||
</div>)}
|
||||
{application.status === "REJECTED" && (
|
||||
<div className="flex flex-col gap-0.5">
|
||||
<div className="flex flex-row gap-2 items-center text-destructive">
|
||||
<XIcon size={16} /><p>Rejected</p>
|
||||
</div>
|
||||
<div className="flex flex-col">
|
||||
<p>Rejection reason</p>
|
||||
<p className="text-muted-foreground">{application.rejectionReason}</p>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
{application.status === "APPROVED" && (
|
||||
<div className="flex flex-row gap-2 items-center">
|
||||
<CheckIcon size={16} /><p>Approved</p>
|
||||
</div>
|
||||
)}
|
||||
</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>
|
||||
{application.status === "PENDING" ? (
|
||||
<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>
|
||||
) : (
|
||||
<CardFooter>
|
||||
<Button variant="outline" onClick={onClose}>Close</Button>
|
||||
</CardFooter>
|
||||
)}
|
||||
</Card>
|
||||
<Dialog open={rejectOpen} onOpenChange={setRejectOpen}>
|
||||
<DialogContent>
|
||||
|
||||
Reference in New Issue
Block a user