shoc-frontend-new/src/domain/vendors/utils/build-technician-create-payload.ts
Arthur Bassi a30ac73d29
Some checks are pending
CI / ci (push) Waiting to run
CI / governance (push) Waiting to run
CI / vendor-visual-regression (push) Waiting to run
Deploy / deploy (push) Waiting to run
feat(work-orders): draft technician until vendor dialog save (SH-193) (#89)
* docs(work-orders): add pending BE contract checklist for design parity gaps

* feat(work-orders): add technician affordance in wo vendor dialog

* fix(work-orders): defer technician create until vendor dialog save

* docs(work-orders): align pr description with jira and qa residuals

* fix(vendors): harden draft technician optional field typing

* refactor(workorders): extract vendor dialog body footer and save hook

* fix(work-orders): coerce null company vendor for add-technician prop

* fix(work-orders): preserve draft technician staging on save [SH-193]

* fix(work-orders): select technicians by stable id [SH-193]

Keep selectedKey as explicit dialog state (SiteDialog pattern) so same-name drafts do not collide with existing vendors, and cover the regression with interaction tests.

Co-authored-by: Cursor <cursoragent@cursor.com>

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Alexandre Brandizzi <alex_brandizzi@hotmail.com>
2026-08-11 14:01:31 -03:00

36 lines
1.1 KiB
TypeScript

import type { VendorDropdownItem } from "@/domain/work-orders/types/work-order";
import type { VendorFormValues } from "@/domain/vendors/schemas/vendor-schema";
type BuildTechnicianCreatePayloadInput = {
companyVendor: Pick<VendorDropdownItem, "companyName" | "email" | "address" | "tradeSpecialties">;
contactName: string;
phone?: string;
companyId?: string | number | null;
};
/** Builds a vendor create payload for a new technician under an existing company. */
export function buildTechnicianCreatePayload({
companyVendor,
contactName,
phone = "",
companyId = null,
}: BuildTechnicianCreatePayloadInput): VendorFormValues {
return {
companyName: companyVendor.companyName,
contactName: contactName.trim(),
email: companyVendor.email ?? "",
phone: phone.trim(),
companyPhone: "",
googleMapsUrl: "",
notes: "",
totalJobs: 0,
address: companyVendor.address ?? "",
city: "",
state: "",
zip: "",
tradeSpecialties: companyVendor.tradeSpecialties ?? "",
isActive: true,
companyId,
preferredContact: "Phone",
};
}