mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-10-02 10:53:13 +00:00
Update audit log immediately after status change
- Append audit entry to local state after successful status update - No page refresh needed to see the change in the Audit Log tab
This commit is contained in:
parent
24c83c6535
commit
287839d089
1 changed files with 17 additions and 1 deletions
|
|
@ -190,7 +190,23 @@ export default function WorkOrderViewPage() {
|
|||
setStatusUpdating(true);
|
||||
try {
|
||||
await changeWorkOrderStatus(id, newStatus);
|
||||
setWo((prev) => ({ ...prev, status: newStatus }));
|
||||
const oldStatus = wo.status;
|
||||
setWo((prev) => ({
|
||||
...prev,
|
||||
status: newStatus,
|
||||
auditLog: [
|
||||
{
|
||||
id: Date.now(),
|
||||
fieldName: "Status",
|
||||
oldValue: oldStatus,
|
||||
newValue: newStatus,
|
||||
action: "status_change",
|
||||
createdAt: new Date().toISOString(),
|
||||
userName: "You",
|
||||
},
|
||||
...(prev.auditLog || []),
|
||||
],
|
||||
}));
|
||||
toast.success(`Status changed to ${newStatus}`);
|
||||
} catch (err) {
|
||||
toast.error("Failed to update status");
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue