"use client"; import { CorrespondenceDetail } from "@/components/correspondences/detail"; import { useCorrespondence } from "@/hooks/use-correspondence"; import { Loader2 } from "lucide-react"; import { notFound, useParams } from "next/navigation"; export default function CorrespondenceDetailPage() { const params = useParams(); const id = Number(params?.id); // useParams returns string | 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. return (

Invalid Correspondence ID

); } const { data: correspondence, isLoading, isError } = useCorrespondence(id); if (isLoading) { return (
); } if (isError || !correspondence) { // Optionally handle 404 vs other errors differently, but for now simple handling return (

Failed to load correspondence

Please try again later or verify the ID.

); } return ; }