260316:1117 20260316:1100 Refactor UUID
Build and Deploy / deploy (push) Successful in 9m24s

This commit is contained in:
admin
2026-03-16 11:17:15 +07:00
parent b93cd91325
commit c5c3ed9016
92 changed files with 1726 additions and 620 deletions
@@ -1,44 +0,0 @@
"use client";
import { CorrespondenceForm } from "@/components/correspondences/form";
import { useCorrespondence } from "@/hooks/use-correspondence";
import { Loader2 } from "lucide-react";
import { useParams } from "next/navigation";
export default function EditCorrespondencePage() {
const params = useParams();
const id = Number(params?.id);
const { data: correspondence, isLoading, isError } = useCorrespondence(id);
if (isLoading) {
return (
<div className="flex bg-muted/20 min-h-screen justify-center items-center">
<Loader2 className="h-8 w-8 animate-spin" />
</div>
);
}
if (isError || !correspondence) {
return (
<div className="flex flex-col items-center justify-center min-h-screen">
<h1 className="text-xl font-bold text-red-500">Failed to load correspondence</h1>
</div>
);
}
return (
<div className="max-w-4xl mx-auto py-6">
<div className="mb-8">
<h1 className="text-3xl font-bold">Edit Correspondence</h1>
<p className="text-muted-foreground mt-1">
{correspondence.correspondenceNumber}
</p>
</div>
<div className="bg-card border rounded-lg p-6 shadow-sm">
<CorrespondenceForm initialData={correspondence} id={id} />
</div>
</div>
);
}
@@ -3,27 +3,22 @@
import { CorrespondenceDetail } from "@/components/correspondences/detail";
import { useCorrespondence } from "@/hooks/use-correspondence";
import { Loader2 } from "lucide-react";
import { notFound, useParams } from "next/navigation";
import { useParams } from "next/navigation";
export default function CorrespondenceDetailPage() {
const params = useParams();
const id = Number(params?.id); // useParams returns string | string[]
const uuid = (params?.uuid as string) ?? '';
if (isNaN(id)) {
// We can't use notFound() directly in client component render without breaking sometimes,
// but typically it works. Better to handle gracefully or redirect.
// For now, let's keep it or return 404 UI.
// Actually notFound() is for server components mostly.
// Let's just return our error UI if ID is invalid.
const { data: correspondence, isLoading, isError } = useCorrespondence(uuid);
if (!uuid) {
return (
<div className="flex flex-col items-center justify-center min-h-screen">
<h1 className="text-xl font-bold text-red-500">Invalid Correspondence ID</h1>
<h1 className="text-xl font-bold text-red-500">Invalid Correspondence UUID</h1>
</div>
);
}
const { data: correspondence, isLoading, isError } = useCorrespondence(id);
if (isLoading) {
return (
<div className="flex bg-muted/20 min-h-screen justify-center items-center">
@@ -33,11 +28,10 @@ export default function CorrespondenceDetailPage() {
}
if (isError || !correspondence) {
// Optionally handle 404 vs other errors differently, but for now simple handling
return (
<div className="flex flex-col items-center justify-center min-h-screen">
<h1 className="text-xl font-bold text-red-500">Failed to load correspondence</h1>
<p>Please try again later or verify the ID.</p>
<p>Please try again later or verify the UUID.</p>
</div>
);
}