diff --git a/e2e/__screenshots__/work-orders/work-orders.visual.spec.ts/wo-new.png b/e2e/__screenshots__/work-orders/work-orders.visual.spec.ts/wo-new.png
index e6298c3f..e7ee92cb 100644
Binary files a/e2e/__screenshots__/work-orders/work-orders.visual.spec.ts/wo-new.png and b/e2e/__screenshots__/work-orders/work-orders.visual.spec.ts/wo-new.png differ
diff --git a/e2e/work-orders/work-orders.visual.spec.ts b/e2e/work-orders/work-orders.visual.spec.ts
index 0816018f..547723a6 100644
--- a/e2e/work-orders/work-orders.visual.spec.ts
+++ b/e2e/work-orders/work-orders.visual.spec.ts
@@ -82,6 +82,10 @@ function isBoardDetail(pathname: string) {
return /\/workorders\/\d+\/detail$/.test(pathname);
}
+function isAccountList(pathname: string) {
+ return pathname.includes("/Account/GetAccountList");
+}
+
async function mockWorkOrderApi(page: Page, mode: "default" | "empty" | "error" = "default") {
await page.clock.setFixedTime(new Date(FROZEN_NOW));
await page.addInitScript((user) => localStorage.setItem("auth", JSON.stringify(user)), TEST_USER);
@@ -161,6 +165,27 @@ async function mockWorkOrderApi(page: Page, mode: "default" | "empty" | "error"
return;
}
+ if (isAccountList(pathname)) {
+ await fulfillJson(route, {
+ items: [
+ {
+ id: 1,
+ name: "Amazon",
+ number: "AMZ-1",
+ industry: "Retail",
+ website: "",
+ primaryContact: "",
+ phoneNumber: "",
+ owner: "",
+ },
+ ],
+ totalCount: 1,
+ page: 1,
+ pageSize: 50,
+ });
+ return;
+ }
+
await fulfillJson(route, { data: [] });
});
}
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 5f911bd8..169f062e 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
@@ -19,6 +19,7 @@ export function buildInlineDraftCreateInput(
locationId: String(draft.locationId || ""),
locationName,
siteCode: location ? resolveSiteCode(location) : resolveSiteCode({ name: locationName }),
+ customer: draft.customer.trim(),
woNumber: draft.woNumber,
type: draft.type || "PM",
severity: draft.severity,
diff --git a/src/app/(protected)/workorders/_components/list/table/cells/build-site-dialog-patch.ts b/src/app/(protected)/workorders/_components/list/table/cells/build-site-dialog-patch.ts
index 3fe930cd..1b9e23c3 100644
--- a/src/app/(protected)/workorders/_components/list/table/cells/build-site-dialog-patch.ts
+++ b/src/app/(protected)/workorders/_components/list/table/cells/build-site-dialog-patch.ts
@@ -8,6 +8,7 @@ type BuildSiteDialogPatchArgs = {
code: string;
locId: string;
selected: LocationOption | undefined;
+ customer?: string;
pocName: string;
pocPhone: string;
pocNotes: string;
@@ -20,6 +21,7 @@ export function buildSiteDialogPatch({
code,
locId,
selected,
+ customer,
pocName,
pocPhone,
pocNotes,
@@ -31,6 +33,7 @@ export function buildSiteDialogPatch({
site: code || (selected ? resolveSiteCode(selected) : ""),
location: selected ? extractLocationLabel(selected) : "",
locationId: locId,
+ ...(customer !== undefined ? { customer } : {}),
pocName,
pocPhone,
pocNotes,
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 4c40ae06..04077833 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
@@ -11,6 +11,7 @@ type SiteCellProps = {
value: string;
location: string;
locationId: string | number;
+ customer?: string;
city?: string;
state?: string;
pocName?: string;
@@ -29,6 +30,7 @@ export function SiteCell({
value,
location,
locationId,
+ customer,
city,
state,
pocName,
@@ -95,6 +97,7 @@ export function SiteCell({
onOpenChange={setOpen}
value={value}
locationId={locationId}
+ customer={customer}
pocName={pocName}
pocPhone={pocPhone}
pocNotes={pocNotes}
diff --git a/src/app/(protected)/workorders/_components/list/table/cells/site-dialog-types.ts b/src/app/(protected)/workorders/_components/list/table/cells/site-dialog-types.ts
index 499af6aa..956d54ba 100644
--- a/src/app/(protected)/workorders/_components/list/table/cells/site-dialog-types.ts
+++ b/src/app/(protected)/workorders/_components/list/table/cells/site-dialog-types.ts
@@ -4,6 +4,7 @@ export type SitePatch = {
site: string;
location: string;
locationId: string | number;
+ customer?: string;
pocName: string;
pocPhone: string;
pocNotes: string;
diff --git a/src/app/(protected)/workorders/_components/list/table/cells/site-dialog.tsx b/src/app/(protected)/workorders/_components/list/table/cells/site-dialog.tsx
index 0843e331..e68dc5c7 100644
--- a/src/app/(protected)/workorders/_components/list/table/cells/site-dialog.tsx
+++ b/src/app/(protected)/workorders/_components/list/table/cells/site-dialog.tsx
@@ -1,4 +1,4 @@
-import type { MouseEvent } from "react";
+import { useContext, type MouseEvent } from "react";
import { MapPin } from "lucide-react";
import { Dialog, DialogContent, DialogTitle } from "@mui/material";
import { WizardFieldSelect } from "@/app/(protected)/workorders/_components/wizard/wizard-field-select";
@@ -9,9 +9,12 @@ import type { LocationOption } from "@/domain/work-orders/types/work-order";
import { FieldLabel } from "@/app/(protected)/workorders/_components/list/table/cells/dialog-field-label";
import { SiteDialogDetailPanel } from "@/app/(protected)/workorders/_components/list/table/cells/site-dialog-detail-panel";
import { SiteDialogFooter } from "@/app/(protected)/workorders/_components/list/table/cells/site-dialog-footer";
+import { WizardStepLocationAccountSelect } from "@/app/(protected)/workorders/_components/wizard/wizard-step-location-account-select";
import { SiteDialogPocSection } from "@/app/(protected)/workorders/_components/list/table/cells/site-dialog-poc-section";
import type { SitePatch } from "@/app/(protected)/workorders/_components/list/table/cells/site-dialog-types";
import { useSiteDialogState } from "@/app/(protected)/workorders/_components/list/table/cells/use-site-dialog-state";
+import { isOrgWideScope } from "@/lib/auth/org-scope";
+import { AuthContext } from "@/providers/auth-context";
export type { SitePatch };
@@ -20,6 +23,7 @@ type SiteDialogProps = {
onOpenChange: (open: boolean) => void;
value: string;
locationId: string | number;
+ customer?: string;
pocName?: string;
pocPhone?: string;
pocNotes?: string;
@@ -35,6 +39,7 @@ export function SiteDialog({
onOpenChange,
value,
locationId,
+ customer = "",
pocName = "",
pocPhone = "",
pocNotes = "",
@@ -44,17 +49,20 @@ export function SiteDialog({
viewOnly = false,
onSave,
}: SiteDialogProps) {
+ const requireAccount = isOrgWideScope(useContext(AuthContext)?.user);
const s = useSiteDialogState({
open,
onOpenChange,
value,
locationId,
+ customer,
pocName,
pocPhone,
pocNotes,
additionalContacts,
sites,
createMode,
+ requireAccount,
onSave,
});
@@ -81,6 +89,13 @@ export function SiteDialog({