setFormData({ ...formData, custom_room_number: val })}
+ disabled={isFieldDisabled('custom_room_number')}
+ placeholder="Select Room"
+ />
{/*
>
)}
+
+
+ setFormData({ ...formData, custom_building: val })}
+ disabled={!isEditing}
+ placeholder="Select Building"
+ />
+
+
+
+ setFormData({ ...formData, custom_room_no: val })}
+ disabled={!isEditing}
+ placeholder="Select Room"
+ />
+
+
+
+ setFormData({ ...formData, custom_location: val })}
+ disabled={!isEditing}
+ placeholder="Select Location"
+ />
+
@@ -1495,7 +1576,19 @@ const canEditBasedOnWorkflow =
+
+
+
+
+
+
+ Updated by workflow (e.g. Open → Work In Progress → Completed → Closed)
+
@@ -1538,6 +1634,11 @@ const canEditBasedOnWorkflow =
Need Procurement
+ {currentWorkflowState === 'Repair InProgress' && (
+
+ Check and save to enable Material Request → Pending Purchase
+
+ )}
@@ -1698,6 +1799,11 @@ const canEditBasedOnWorkflow =
rows={4}
className="w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white resize-none"
/>
+ {currentWorkflowState === 'Repair InProgress' && (
+
+ Required for Work Done (with Assigned Technician set)
+
+ )}
@@ -1747,6 +1853,11 @@ const canEditBasedOnWorkflow =
filters={assignedTechnicianFilters}
placeholder={formData.company ? 'Select Technician' : 'Select Hospital first'}
/>
+ {['Sent to Team Leader', 'Repair InProgress', 'Completed'].includes(currentWorkflowState) && (
+
+ Required for Send For Repair, Work Done, and Approve & Close workflow actions
+
+ )}
@@ -2289,12 +2400,25 @@ const canEditBasedOnWorkflow =
{/* No Actions Available */}
{!workflowLoading && transitions.length === 0 && (
-
+
- No workflow actions available
+ No workflow actions available for your role or current document state
-
- (Conditions may not be met for available transitions)
+ {workflowHints.length > 0 && (
+
+ {workflowHints.map((hint) => (
+ - {hint}
+ ))}
+
+ )}
+
+ )}
+
+ {/* Hints while actions are visible (save reminder when editing) */}
+ {!workflowLoading && transitions.length > 0 && isEditing && (
+
+
+ Save after editing so workflow conditions match the server before applying an action.
)}
@@ -2303,7 +2427,7 @@ const canEditBasedOnWorkflow =
{/* WO Feedback — read-only summary when submitted (submit via public link only) */}
{!isNewWorkOrder &&
- ['Approved', 'Closed'].includes(currentWorkflowState) &&
+ ['Completed', 'Closed'].includes(currentWorkflowState) &&
workOrderName &&
}
{/* Status Summary Card */}
diff --git a/asm_app/src/services/assetService.ts b/asm_app/src/services/assetService.ts
index cf33e70..0a66f03 100644
--- a/asm_app/src/services/assetService.ts
+++ b/asm_app/src/services/assetService.ts
@@ -18,6 +18,8 @@ export interface Asset {
asset_category?: string;
custom_moh_id?: string;
custom_floor?: string;
+ custom_building?: string;
+ custom_room_number?: string;
custom_moh_engg?: string;
custom_smeh_engg?: string;
custom_manufacturing_year?: string;
@@ -127,6 +129,8 @@ export interface CreateAssetData {
asset_category?: string;
custom_moh_id?: string;
custom_floor?: string;
+ custom_building?: string;
+ custom_room_number?: string;
custom_moh_engg?: string;
custom_smeh_engg?: string;
custom_manufacturing_year?: string;
diff --git a/asm_app/src/services/workOrderService.ts b/asm_app/src/services/workOrderService.ts
index 9200cdf..1a2bab9 100644
--- a/asm_app/src/services/workOrderService.ts
+++ b/asm_app/src/services/workOrderService.ts
@@ -68,6 +68,9 @@ export interface WorkOrder {
stock_items?: StockItem[];
site_name?: string;
custom_assign_to_contractor?: string;
+ custom_building?: string;
+ custom_room_no?: string;
+ custom_location?: string;
}
export interface StockItem {
diff --git a/asm_app/src/utils/workOrderWorkflowUtils.ts b/asm_app/src/utils/workOrderWorkflowUtils.ts
new file mode 100644
index 0000000..1175ebb
--- /dev/null
+++ b/asm_app/src/utils/workOrderWorkflowUtils.ts
@@ -0,0 +1,96 @@
+/**
+ * Helpers for the Work Order workflow (backend: Workflow "Work Order").
+ * Transitions and allow_edit rules are loaded from Frappe; these hints mirror
+ * the conditions configured on the workflow.
+ */
+
+export interface WorkOrderWorkflowDoc {
+ workflow_state?: string;
+ asset_type?: string;
+ site_name?: string;
+ custom_assign_to_contractor?: string;
+ actions_performed?: string;
+ need_procurement?: number;
+}
+
+/** Actions that should prompt for confirmation before applying. */
+export const WORK_ORDER_CONFIRM_ACTIONS = [
+ 'Approve & Close',
+ 'Re-Open',
+ 'Reject',
+ 'Cancel',
+ 'Close',
+] as const;
+
+/** repair_status values set by workflow state update_field (backend). */
+export const WORK_ORDER_REPAIR_STATUS_BY_STATE: Record
= {
+ Draft: 'Open',
+ 'Sent to Team Leader': 'Open',
+ 'Sent To Site Manager': 'Open',
+ 'Repair InProgress': 'Work In Progress',
+ 'Pending Approval': 'Pending Review',
+ Completed: 'Completed',
+ Cancelled: 'Cancelled',
+ Closed: 'Closed',
+};
+
+/**
+ * Human-readable hints when no workflow actions are shown (conditions / save).
+ */
+export function getWorkOrderWorkflowHints(
+ state: string,
+ doc: WorkOrderWorkflowDoc,
+ options?: { isEditing?: boolean }
+): string[] {
+ const hints: string[] = [];
+ const isEditing = options?.isEditing ?? false;
+
+ if (isEditing) {
+ hints.push('Save the work order after changing fields so workflow actions refresh.');
+ }
+
+ switch (state) {
+ case 'Draft':
+ if (doc.asset_type === 'Biomedical' && !doc.site_name) {
+ hints.push('PHCC End User: set Site Name (Biomedical asset) to enable Apply.');
+ }
+ break;
+
+ case 'Sent to Team Leader':
+ if (!doc.custom_assign_to_contractor) {
+ hints.push(
+ 'Maintenance Manager: set Assigned Technician, save, then use Send For Repair.'
+ );
+ }
+ break;
+
+ case 'Repair InProgress':
+ if (!doc.custom_assign_to_contractor) {
+ hints.push('Set Assigned Technician and save to enable Work Done.');
+ } else if (!doc.actions_performed?.trim()) {
+ hints.push('Fill Actions Performed and save to enable Work Done.');
+ }
+ if (doc.need_procurement !== 1) {
+ hints.push('Check Need Procurement and save to enable Material Request.');
+ }
+ break;
+
+ case 'Pending Purchase':
+ hints.push('Finance Manager: use Send For Repair when procurement is complete.');
+ break;
+
+ case 'Completed':
+ if (!doc.custom_assign_to_contractor) {
+ hints.push(
+ 'Set Assigned Technician and save to enable Approve & Close (End user / Manager roles).'
+ );
+ }
+ hints.push('Maintenance Manager can Re-Open without a contractor assigned.');
+ break;
+
+ default:
+ break;
+ }
+
+ return hints;
+}