This commit is contained in:
@@ -39,7 +39,7 @@ export function CorrespondenceDetail({ data }: CorrespondenceDetailProps) {
|
||||
const handleSubmit = () => {
|
||||
if (confirm("Are you sure you want to submit this correspondence?")) {
|
||||
submitMutation.mutate({
|
||||
id: data.id,
|
||||
uuid: data.uuid,
|
||||
data: {}
|
||||
});
|
||||
}
|
||||
@@ -50,7 +50,7 @@ export function CorrespondenceDetail({ data }: CorrespondenceDetailProps) {
|
||||
|
||||
const action = actionState === "approve" ? "APPROVE" : "REJECT";
|
||||
processMutation.mutate({
|
||||
id: data.id,
|
||||
uuid: data.uuid,
|
||||
data: {
|
||||
action,
|
||||
comments
|
||||
@@ -83,7 +83,7 @@ export function CorrespondenceDetail({ data }: CorrespondenceDetailProps) {
|
||||
<div className="flex gap-2">
|
||||
{/* EDIT BUTTON LOGIC: Show if DRAFT */}
|
||||
{status === "DRAFT" && (
|
||||
<Link href={`/correspondences/${data.id}/edit`}>
|
||||
<Link href={`/correspondences/${data.uuid}/edit`}>
|
||||
<Button variant="outline">
|
||||
<Edit className="mr-2 h-4 w-4" />
|
||||
Edit
|
||||
|
||||
@@ -42,7 +42,7 @@ const correspondenceSchema = z.object({
|
||||
|
||||
type FormData = z.infer<typeof correspondenceSchema>;
|
||||
|
||||
export function CorrespondenceForm({ initialData, id }: { initialData?: any, id?: number }) {
|
||||
export function CorrespondenceForm({ initialData, uuid }: { initialData?: any, uuid?: string }) {
|
||||
const router = useRouter();
|
||||
const createMutation = useCreateCorrespondence();
|
||||
const updateMutation = useUpdateCorrespondence();
|
||||
@@ -107,10 +107,10 @@ export function CorrespondenceForm({ initialData, id }: { initialData?: any, id?
|
||||
},
|
||||
};
|
||||
|
||||
if (id && initialData) {
|
||||
if (uuid && initialData) {
|
||||
// UPDATE Mode
|
||||
updateMutation.mutate({ id, data: payload }, {
|
||||
onSuccess: () => router.push(`/correspondences/${id}`)
|
||||
updateMutation.mutate({ uuid, data: payload }, {
|
||||
onSuccess: () => router.push(`/correspondences/${uuid}`)
|
||||
});
|
||||
} else {
|
||||
// CREATE Mode
|
||||
@@ -420,7 +420,7 @@ export function CorrespondenceForm({ initialData, id }: { initialData?: any, id?
|
||||
</Button>
|
||||
<Button type="submit" disabled={isPending}>
|
||||
{isPending && <Loader2 className="mr-2 h-4 w-4 animate-spin" />}
|
||||
{id ? "Update Correspondence" : "Create Correspondence"}
|
||||
{uuid ? "Update Correspondence" : "Create Correspondence"}
|
||||
</Button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
@@ -59,15 +59,15 @@ export function CorrespondenceList({ data }: CorrespondenceListProps) {
|
||||
id: "actions",
|
||||
cell: ({ row }) => {
|
||||
const item = row.original;
|
||||
// Edit/View link goes to the DOCUMENT detail (correspondence.id)
|
||||
// Ideally we might pass ?revId=item.id to view specific revision, but detail page defaults to latest.
|
||||
// Edit/View link goes to the DOCUMENT detail (correspondence.uuid)
|
||||
// Ideally we might pass ?revId=item.uuid to view specific revision, but detail page defaults to latest.
|
||||
// For editing, we edit the document.
|
||||
const docId = item.correspondence.id;
|
||||
const docUuid = item.correspondence.uuid;
|
||||
const statusCode = item.status?.statusCode;
|
||||
|
||||
return (
|
||||
<div className="flex gap-2">
|
||||
<Link href={`/correspondences/${docId}`}>
|
||||
<Link href={`/correspondences/${docUuid}`}>
|
||||
<Button variant="ghost" size="icon" title="View Details">
|
||||
<Eye className="h-4 w-4" />
|
||||
</Button>
|
||||
@@ -89,7 +89,7 @@ export function CorrespondenceList({ data }: CorrespondenceListProps) {
|
||||
<FileText className="h-4 w-4" />
|
||||
</Button>
|
||||
{statusCode === "DRAFT" && (
|
||||
<Link href={`/correspondences/${docId}/edit`}>
|
||||
<Link href={`/correspondences/${docUuid}/edit`}>
|
||||
<Button variant="ghost" size="icon" title="Edit">
|
||||
<Edit className="h-4 w-4" />
|
||||
</Button>
|
||||
|
||||
Reference in New Issue
Block a user