"use client"; import { useState } from "react"; import { useRouter } from "next/navigation"; import { FileUploader } from "@/components/po/file-uploader"; import { uploadPoDocuments } from "@/app/actions/upload-po-documents"; /** * Feature-flagged uploader shown on a PO's detail page so its submitter (or * Accounts / Manager / SuperUser) can add documents after the fact — in any state * except rejected/cancelled. Gating is decided server-side in po-detail.tsx; the * server action re-checks the permission, so this component is only the UI. */ export function PoAttachmentUploader({ poId }: { poId: string }) { const router = useRouter(); const [files, setFiles] = useState([]); const [busy, setBusy] = useState(false); const [error, setError] = useState(""); async function handleUpload() { if (files.length === 0) return; setBusy(true); setError(""); const err = await uploadPoDocuments(poId, files); if (err) { setError(err.error); setBusy(false); return; } setFiles([]); setBusy(false); router.refresh(); } return (

Add attachments

Attach any documents that are missing from this purchase order.

{error &&

{error}

}
); }