mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-10-03 23:43:13 +00:00
fix(work-orders): restore wizard mock modules for base consumers
This commit is contained in:
parent
8ae54a6173
commit
6c4197dba7
2 changed files with 168 additions and 0 deletions
10
src/domain/work-orders/mocks/is-wo-wizard-mock-enabled.ts
Normal file
10
src/domain/work-orders/mocks/is-wo-wizard-mock-enabled.ts
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
import { env } from "@/lib/env";
|
||||
import { isAuthBypassEnabled } from "@/lib/auth/auth-bypass";
|
||||
|
||||
export function isWoWizardMockEnabled(): boolean {
|
||||
return env.isDev;
|
||||
}
|
||||
|
||||
export function shouldUseMockWoWizardCreate(locationId: string): boolean {
|
||||
return isAuthBypassEnabled() || locationId.startsWith("mock-");
|
||||
}
|
||||
158
src/domain/work-orders/mocks/wo-wizard-mock-data.ts
Normal file
158
src/domain/work-orders/mocks/wo-wizard-mock-data.ts
Normal file
|
|
@ -0,0 +1,158 @@
|
|||
import type { Location } from "@/domain/locations/types/location";
|
||||
import type { DropdownOption } from "@/domain/settings/dropdown-options/types/dropdown-option";
|
||||
import type {
|
||||
LocationOption,
|
||||
VendorDropdownItem,
|
||||
WorkOrderDetail,
|
||||
WorkOrderFormValues,
|
||||
WorkOrderUser,
|
||||
} from "@/domain/work-orders/types/work-order";
|
||||
|
||||
export const MOCK_WO_WIZARD_USERS: WorkOrderUser[] = [
|
||||
{ id: "mock-user-1", name: "Alex Rivera" },
|
||||
{ id: "mock-user-2", name: "Jordan Kim" },
|
||||
{ id: "mock-user-3", name: "Sam Patel" },
|
||||
];
|
||||
|
||||
export const MOCK_WO_WIZARD_LOCATIONS: LocationOption[] = [
|
||||
{ id: "mock-loc-1", name: "CHI-1042 — Chicago Loop" },
|
||||
{ id: "mock-loc-2", name: "IND-2208 — Indianapolis North" },
|
||||
{ id: "mock-loc-3", name: "MIL-3315 — Milwaukee West" },
|
||||
];
|
||||
|
||||
const MOCK_LOCATION_DETAILS: Record<string, Location> = {
|
||||
"mock-loc-1": {
|
||||
id: "mock-loc-1",
|
||||
name: "CHI-1042 — Chicago Loop",
|
||||
address: "233 S Wacker Dr",
|
||||
city: "Chicago",
|
||||
state: "IL",
|
||||
zipCode: "60606",
|
||||
phone: "(312) 555-0142",
|
||||
contact: "Maria Gonzalez",
|
||||
contactEmail: "maria.gonzalez@example.com",
|
||||
status: "Active",
|
||||
},
|
||||
"mock-loc-2": {
|
||||
id: "mock-loc-2",
|
||||
name: "IND-2208 — Indianapolis North",
|
||||
address: "8702 Keystone Crossing",
|
||||
city: "Indianapolis",
|
||||
state: "IN",
|
||||
zipCode: "46240",
|
||||
phone: "(317) 555-2208",
|
||||
contact: "Chris Bennett",
|
||||
contactEmail: "chris.bennett@example.com",
|
||||
status: "Active",
|
||||
},
|
||||
"mock-loc-3": {
|
||||
id: "mock-loc-3",
|
||||
name: "MIL-3315 — Milwaukee West",
|
||||
address: "411 E Wisconsin Ave",
|
||||
city: "Milwaukee",
|
||||
state: "WI",
|
||||
zipCode: "53202",
|
||||
phone: "(414) 555-3315",
|
||||
contact: "Taylor Brooks",
|
||||
contactEmail: "taylor.brooks@example.com",
|
||||
status: "Active",
|
||||
},
|
||||
};
|
||||
|
||||
export const MOCK_WO_WIZARD_SERVICES: DropdownOption[] = [
|
||||
{
|
||||
id: "mock-svc-1",
|
||||
category: "Problem",
|
||||
value: "HVAC — Quarterly PM",
|
||||
parentValue: null,
|
||||
sortOrder: 1,
|
||||
isActive: true,
|
||||
},
|
||||
{
|
||||
id: "mock-svc-2",
|
||||
category: "Problem",
|
||||
value: "Plumbing — Leak repair",
|
||||
parentValue: null,
|
||||
sortOrder: 2,
|
||||
isActive: true,
|
||||
},
|
||||
{
|
||||
id: "mock-svc-3",
|
||||
category: "Problem",
|
||||
value: "Electrical — Panel inspection",
|
||||
parentValue: null,
|
||||
sortOrder: 3,
|
||||
isActive: true,
|
||||
},
|
||||
{
|
||||
id: "mock-svc-4",
|
||||
category: "Problem",
|
||||
value: "Roof — Membrane patch",
|
||||
parentValue: null,
|
||||
sortOrder: 4,
|
||||
isActive: true,
|
||||
},
|
||||
];
|
||||
|
||||
export const MOCK_WO_WIZARD_VENDORS: VendorDropdownItem[] = [
|
||||
{
|
||||
id: "mock-vendor-1",
|
||||
companyName: "Midwest HVAC Co.",
|
||||
tradeSpecialties: "HVAC",
|
||||
address: "1200 Industrial Pkwy, Chicago, IL 60632",
|
||||
distanceMiles: 4.2,
|
||||
},
|
||||
{
|
||||
id: "mock-vendor-2",
|
||||
companyName: "Great Lakes Plumbing",
|
||||
tradeSpecialties: "Plumbing",
|
||||
address: "455 Water St, Milwaukee, WI 53202",
|
||||
distanceMiles: 8.7,
|
||||
},
|
||||
{
|
||||
id: "mock-vendor-3",
|
||||
companyName: "SparkLine Electric",
|
||||
tradeSpecialties: "Electrical",
|
||||
address: "88 Volt Ave, Indianapolis, IN 46225",
|
||||
distanceMiles: 12.1,
|
||||
},
|
||||
];
|
||||
|
||||
export function getMockWoWizardLocationDetail(locationId: string): Location | undefined {
|
||||
return MOCK_LOCATION_DETAILS[locationId];
|
||||
}
|
||||
|
||||
export function buildMockWorkOrderDetail(values: WorkOrderFormValues): WorkOrderDetail {
|
||||
const id = `mock-wo-${Date.now()}`;
|
||||
const now = new Date().toISOString();
|
||||
|
||||
return {
|
||||
id,
|
||||
internalWONumber: values.internalWONumber || id,
|
||||
workOrderNumber: values.workOrderNumber || "MOCK-0001",
|
||||
title: values.title || "Mock Work Order",
|
||||
location:
|
||||
MOCK_WO_WIZARD_LOCATIONS.find((l) => String(l.id) === values.locationId)?.name ?? "Mock Site",
|
||||
locationId: values.locationId,
|
||||
locationZip: getMockWoWizardLocationDetail(values.locationId)?.zipCode ?? "",
|
||||
assignedTo: values.assignedTo,
|
||||
dueDate: values.dueDate,
|
||||
createdDate: values.createdDate,
|
||||
createdDateFull: now,
|
||||
description: values.description,
|
||||
priority: values.priority,
|
||||
status: values.status,
|
||||
po: values.po,
|
||||
tt: values.tt,
|
||||
problem: values.problem,
|
||||
trade: values.trade,
|
||||
subTrade: values.subTrade,
|
||||
vendorNTE: values.vendorNTE,
|
||||
scheduledDate: values.scheduledDate,
|
||||
completedDate: values.completedDate,
|
||||
source: values.source,
|
||||
comments: [],
|
||||
auditLog: [],
|
||||
dispatches: [],
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue