You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The "Maintenance" tab on the asset detail page shows service history and lets users log new maintenance events. Maintenance records track what was done, by whom, at what cost, and the outcome.
Context
Frontend API: frontend/lib/api/assets.ts — createMaintenanceRecord(assetId, data), getMaintenanceRecords(assetId), update status via PATCH /assets/:id/maintenance/:maintId
Frontend types in frontend/lib/query/types/asset.ts: MaintenanceRecord with type (PREVENTIVE, CORRECTIVE, SCHEDULED), status (SCHEDULED, IN_PROGRESS, COMPLETED, CANCELLED), scheduledDate, completedDate, cost, notes, technician
Status changes set asset status to MAINTENANCE when IN_PROGRESS, and back to ACTIVE when COMPLETED
Acceptance Criteria
Create MaintenanceRecord entity: id, assetId, type (MaintenanceType enum), status (MaintenanceStatus enum), title, description, scheduledDate, completedDate, cost (decimal), technicianName, providerId (nullable FK to Vendor), notes, createdBy, createdAt, updatedAt
POST /assets/:id/maintenance — creates record, if status: IN_PROGRESS sets asset status to MAINTENANCE, logs MAINTENANCE history entry
GET /assets/:id/maintenance — paginated list of maintenance records, most recent first, with total cost sum
PATCH /assets/:id/maintenance/:maintId — update status, completedDate, cost, notes. If status becomes COMPLETED, set asset status back to ACTIVE
Return 404 if maintenance record does not belong to the specified asset
Overview
The "Maintenance" tab on the asset detail page shows service history and lets users log new maintenance events. Maintenance records track what was done, by whom, at what cost, and the outcome.
Context
frontend/lib/api/assets.ts—createMaintenanceRecord(assetId, data),getMaintenanceRecords(assetId), update status viaPATCH /assets/:id/maintenance/:maintIdfrontend/lib/query/types/asset.ts:MaintenanceRecordwithtype(PREVENTIVE, CORRECTIVE, SCHEDULED),status(SCHEDULED, IN_PROGRESS, COMPLETED, CANCELLED),scheduledDate,completedDate,cost,notes,technicianAcceptance Criteria
MaintenanceRecordentity:id,assetId,type(MaintenanceTypeenum),status(MaintenanceStatusenum),title,description,scheduledDate,completedDate,cost(decimal),technicianName,providerId(nullable FK to Vendor),notes,createdBy,createdAt,updatedAtPOST /assets/:id/maintenance— creates record, ifstatus: IN_PROGRESSsets asset status toMAINTENANCE, logsMAINTENANCEhistory entryGET /assets/:id/maintenance— paginated list of maintenance records, most recent first, with total cost sumPATCH /assets/:id/maintenance/:maintId— updatestatus,completedDate,cost,notes. If status becomesCOMPLETED, set asset status back toACTIVE404if maintenance record does not belong to the specified asset