diff --git a/src/app/(protected)/workorders/_components/list/table/build-inline-draft-create-input.ts b/src/app/(protected)/workorders/_components/list/table/build-inline-draft-create-input.ts index 53c2f381..0edec077 100644 --- a/src/app/(protected)/workorders/_components/list/table/build-inline-draft-create-input.ts +++ b/src/app/(protected)/workorders/_components/list/table/build-inline-draft-create-input.ts @@ -12,12 +12,15 @@ export function buildInlineDraftCreateInput( const location = sites.find((s) => String(s.id) === String(draft.locationId)); const locationName = draft.location || draft.site || location?.name || ""; + const hasWeekTarget = Boolean(draft.targetWeek?.trim()); + const scheduleWeekOnly = draft.scheduleWeekOnly && (hasWeekTarget || Boolean(draft.scheduledOn)); + return { locationId: String(draft.locationId || ""), locationName, siteCode: location ? resolveSiteCode(location) : resolveSiteCode({ name: locationName }), woNumber: draft.woNumber, - type: draft.type, + type: draft.type || "PM", assigneeId: draft.dispatcherId, assigneeName: assignee?.name ?? "", scheduledOn: draft.scheduledOn, @@ -35,7 +38,7 @@ export function buildInlineDraftCreateInput( pocName: draft.pocName, pocPhone: draft.pocPhone, pocNotes: draft.pocNotes, - scheduleWeekOnly: draft.scheduleWeekOnly, + scheduleWeekOnly, targetWeek: draft.targetWeek || "", }; } diff --git a/src/app/(protected)/workorders/_components/list/table/cells/date-cell.tsx b/src/app/(protected)/workorders/_components/list/table/cells/date-cell.tsx index 417ffe22..6d78143e 100644 --- a/src/app/(protected)/workorders/_components/list/table/cells/date-cell.tsx +++ b/src/app/(protected)/workorders/_components/list/table/cells/date-cell.tsx @@ -15,6 +15,8 @@ type DateCellProps = { targetWeek?: string; onSaveWeek?: (weekStart: string) => void; defaultMode?: "week" | "date"; + /** When set, shows Clear in the popover so schedule can be removed (e.g. day-group → Unscheduled). */ + onClear?: () => void; }; export function DateCell({ @@ -26,6 +28,7 @@ export function DateCell({ targetWeek = "", onSaveWeek, defaultMode, + onClear, }: DateCellProps) { const [anchorEl, setAnchorEl] = useState(null); const [cellMode, setCellMode] = useState<"week" | "date">( @@ -132,6 +135,21 @@ export function DateCell({ }} /> )} + {Boolean(onClear) && ( +
+ +
+ )} ); diff --git a/src/app/(protected)/workorders/_components/list/table/cells/site-cell.tsx b/src/app/(protected)/workorders/_components/list/table/cells/site-cell.tsx index 939b4ce4..89a703f6 100644 --- a/src/app/(protected)/workorders/_components/list/table/cells/site-cell.tsx +++ b/src/app/(protected)/workorders/_components/list/table/cells/site-cell.tsx @@ -17,6 +17,8 @@ type SiteCellProps = { pocNotes?: string; sites: LocationOption[]; q?: string; + /** Inline create: editable POC + Site/POC required to confirm the modal. */ + createMode?: boolean; onSave: (patch: SitePatch) => void; }; @@ -31,6 +33,7 @@ export function SiteCell({ pocNotes, sites, q, + createMode = false, onSave, }: SiteCellProps) { const [open, setOpen] = useState(false); @@ -70,7 +73,15 @@ export function SiteCell({ )} ) : ( - — + + {createMode ? ( + <> + Site * + + ) : ( + "—" + )} + )} @@ -83,6 +94,7 @@ export function SiteCell({ pocPhone={pocPhone} pocNotes={pocNotes} sites={sites} + createMode={createMode} onSave={onSave} /> diff --git a/src/app/(protected)/workorders/_components/list/table/cells/site-dialog-poc-fields.tsx b/src/app/(protected)/workorders/_components/list/table/cells/site-dialog-poc-fields.tsx index 145250c2..61ca8f78 100644 --- a/src/app/(protected)/workorders/_components/list/table/cells/site-dialog-poc-fields.tsx +++ b/src/app/(protected)/workorders/_components/list/table/cells/site-dialog-poc-fields.tsx @@ -9,37 +9,77 @@ type SiteDialogPocFieldsProps = { pocName: string; pocPhone: string; pocNotes: string; + editable?: boolean; + showErrors?: boolean; + onPocNameChange?: (value: string) => void; + onPocPhoneChange?: (value: string) => void; + onPocNotesChange?: (value: string) => void; }; -export function SiteDialogPocFields({ pocName, pocPhone, pocNotes }: SiteDialogPocFieldsProps) { +export function SiteDialogPocFields({ + pocName, + pocPhone, + pocNotes, + editable = false, + showErrors = false, + onPocNameChange, + onPocPhoneChange, + onPocNotesChange, +}: SiteDialogPocFieldsProps) { + const nameMissing = showErrors && !pocName.trim(); + const phoneMissing = showErrors && !pocPhone.trim(); + return (
Point of Contact - Shown from site/work order records. Board edit saves site code only. + {editable + ? "Auto-filled from records — edit if outdated" + : "Shown from site/work order records. Board edit saves site code only."}
- - +
+ onPocNameChange?.(e.target.value)} + /> + + Contact name is required + +
+
+ onPocPhoneChange?.(e.target.value)} + /> + + Contact phone is required + +