diff --git a/src/pages/workorders/api.js b/src/pages/workorders/api.js
index 48bdcb98..be7d2d6e 100644
--- a/src/pages/workorders/api.js
+++ b/src/pages/workorders/api.js
@@ -30,6 +30,7 @@ export const getWorkOrderById = async (id) => {
po: wo.po ?? "",
tt: wo.tt ?? "",
comments: wo.comments ?? [],
+ auditLog: wo.auditLog ?? [],
};
} catch (error) {
console.error("Error fetching work order:", error);
diff --git a/src/pages/workorders/view/WorkOrderViewPage.css b/src/pages/workorders/view/WorkOrderViewPage.css
index 4b6e0b74..31c02787 100644
--- a/src/pages/workorders/view/WorkOrderViewPage.css
+++ b/src/pages/workorders/view/WorkOrderViewPage.css
@@ -161,6 +161,32 @@
text-align: center;
}
+.woAuditItem {
+ border-left-color: #6c757d;
+}
+
+.woAuditField {
+ font-weight: 600;
+ color: #333;
+ margin-right: 8px;
+}
+
+.woAuditOld {
+ color: #dc3545;
+ text-decoration: line-through;
+ margin-right: 4px;
+}
+
+.woAuditArrow {
+ color: #999;
+ margin: 0 4px;
+}
+
+.woAuditNew {
+ color: #28a745;
+ font-weight: 500;
+}
+
.loading {
padding: 40px;
text-align: center;
diff --git a/src/pages/workorders/view/WorkOrderViewPage.js b/src/pages/workorders/view/WorkOrderViewPage.js
index 2fe298ff..5608d308 100644
--- a/src/pages/workorders/view/WorkOrderViewPage.js
+++ b/src/pages/workorders/view/WorkOrderViewPage.js
@@ -35,12 +35,39 @@ function CommentTimeline({ comments }) {
);
}
+function AuditTimeline({ entries }) {
+ if (!entries || entries.length === 0) {
+ return
No changes recorded.
;
+ }
+
+ return (
+
+ {entries.map((e) => (
+
+
+ {e.userName || "System"}
+
+ {e.createdAt ? formatDateTime(e.createdAt) : ""}
+
+
+
+ {e.fieldName}
+ {e.oldValue && {e.oldValue}}
+ →
+ {e.newValue}
+
+
+ ))}
+
+ );
+}
+
export default function WorkOrderViewPage() {
const { id } = useParams();
const navigate = useNavigate();
const [wo, setWo] = useState(null);
const [loading, setLoading] = useState(true);
- const [commentTab, setCommentTab] = useState("customer");
+ const [activeTab, setActiveTab] = useState("customer");
useEffect(() => {
const load = async () => {
@@ -61,12 +88,18 @@ export default function WorkOrderViewPage() {
const statusClass = (wo.status || "").toLowerCase().replace(/\s+/g, "-");
- const customerComments = (wo.comments || []).filter(
- (c) => c.recordType || c.commenter
- );
- const vendorComments = (wo.comments || []).filter(
- (c) => !c.recordType && !c.commenter && c.userName
- );
+ const allComments = wo.comments || [];
+ const customerComments = allComments.filter((c) => c.commentType === "customer");
+ const vendorComments = allComments.filter((c) => c.commentType === "vendor");
+ const internalComments = allComments.filter((c) => c.commentType === "internal");
+ const auditLog = wo.auditLog || [];
+
+ const tabs = [
+ { key: "customer", label: "Customer", count: customerComments.length },
+ { key: "vendor", label: "Vendor", count: vendorComments.length },
+ { key: "internal", label: "Internal", count: internalComments.length },
+ { key: "audit", label: "Audit Log", count: auditLog.length },
+ ];
return (
@@ -145,22 +178,20 @@ export default function WorkOrderViewPage() {
Activity
-
-
+ {tabs.map((tab) => (
+
+ ))}
-
+ {activeTab === "customer" &&
}
+ {activeTab === "vendor" &&
}
+ {activeTab === "internal" &&
}
+ {activeTab === "audit" &&
}