diff --git a/docs/work-orders/pending-be-contract.md b/docs/work-orders/pending-be-contract.md new file mode 100644 index 00000000..08aff844 --- /dev/null +++ b/docs/work-orders/pending-be-contract.md @@ -0,0 +1,30 @@ +# Work-order `additionalContacts` contract (SH-218) + +Authoritative frontend contract for additional POC 2+ contacts. Implemented on +backend PR [shoc-backend#66](https://github.com/Sea-Haven-Industries/shoc-backend/pull/66). + +## Shape + +```ts +{ name: string; phone: string; notes?: string } +``` + +- Primary POC remains `pocName` / `pocPhone` / `pocNotes`. +- `additionalContacts` holds ordered POC 2+ only. +- Notes are optional. An empty list (or omitted field) is valid. +- Retained entries require **both** `name` and `phone`. Fully blank placeholder + rows are dropped and must not fail create. Name-only or phone-only entries are + rejected on POST create and PATCH. + +## Endpoints + +| Operation | Where | +| ------------------ | ------------------------------------------------------------- | +| POST create | `additionalContacts` array on the board create body | +| GET board / search | `additionalContacts` on each board row | +| GET detail | `info.additionalContacts` (same ordered list as board) | +| PATCH | `field: "additionalContacts"`, `value` is a JSON array string | + +Until #66 is merged to the deployed API, a missing field is still mapped as `[]` +on the frontend so the UI does not throw. After merge, create → reload → +board/slide-over must round-trip the ordered list through GET detail `info`. diff --git a/src/app/(protected)/workorders/_components/detail/tabs/slide-over-info-tab-edit-view.tsx b/src/app/(protected)/workorders/_components/detail/tabs/slide-over-info-tab-edit-view.tsx index 7eaf94f3..bdfe8af9 100644 --- a/src/app/(protected)/workorders/_components/detail/tabs/slide-over-info-tab-edit-view.tsx +++ b/src/app/(protected)/workorders/_components/detail/tabs/slide-over-info-tab-edit-view.tsx @@ -59,18 +59,29 @@ export function SlideOverInfoTabEditView({ pocName={draft.pocName} pocPhone={draft.pocPhone} pocNotes={draft.pocNotes} + additionalContacts={draft.additionalContacts} sites={sites} onSave={(patch) => onDraftChange({ site: patch.site, location: patch.location, locationId: patch.locationId, + pocName: patch.pocName, + pocPhone: patch.pocPhone, + pocNotes: patch.pocNotes, + ...(patch.additionalContacts !== undefined + ? { additionalContacts: patch.additionalContacts } + : {}), }) } /> - onDraftChange({ type })} /> + onDraftChange({ type, severity })} + /> void; + onConfirm: () => void; +}; + +export function SiteDialogFooter({ onClose, onConfirm }: SiteDialogFooterProps) { + return ( +
+ + +
+ ); +} 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 61ca8f78..66874d72 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 @@ -1,87 +1 @@ -import { - DLG_INPUT_CLS, - DLG_INPUT_STYLE, -} from "@/app/(protected)/workorders/_components/wizard/wizard-input-styles"; -import { Text } from "@/components/ui/text"; -import { FieldLabel } from "@/app/(protected)/workorders/_components/list/table/cells/dialog-field-label"; - -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, - editable = false, - showErrors = false, - onPocNameChange, - onPocPhoneChange, - onPocNotesChange, -}: SiteDialogPocFieldsProps) { - const nameMissing = showErrors && !pocName.trim(); - const phoneMissing = showErrors && !pocPhone.trim(); - - return ( -
- Point of Contact - - {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 - -
-