mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-10-06 03:02:03 +00:00
Merge remote-tracking branch 'origin/feat/ab/sh-331-sites-panel' into feat/ab/sh-334-site-delete
This commit is contained in:
commit
3ab9c9a65b
2 changed files with 17 additions and 1 deletions
|
|
@ -236,7 +236,8 @@ export function mapLocationToBackend(location: unknown): Record<string, unknown>
|
||||||
state: item.state ?? "",
|
state: item.state ?? "",
|
||||||
zipCode: item.zipCode ?? "",
|
zipCode: item.zipCode ?? "",
|
||||||
phone: typeof item.sitePhone === "string" ? item.sitePhone.trim() : "",
|
phone: typeof item.sitePhone === "string" ? item.sitePhone.trim() : "",
|
||||||
contact: mainContact ? mainContact.name : "",
|
// A caller without a contacts list (e.g. address-only sync) keeps the stored legacy name.
|
||||||
|
contact: mainContact ? mainContact.name : readString(item, "contact").trim(),
|
||||||
contactEmail: typeof item.contactEmail === "string" ? item.contactEmail.trim() : "",
|
contactEmail: typeof item.contactEmail === "string" ? item.contactEmail.trim() : "",
|
||||||
accountId: item.accountId ?? "",
|
accountId: item.accountId ?? "",
|
||||||
contacts,
|
contacts,
|
||||||
|
|
|
||||||
|
|
@ -108,6 +108,21 @@ describe("mapLocationToBackend site payload", () => {
|
||||||
expect(bare).not.toHaveProperty("notes");
|
expect(bare).not.toHaveProperty("notes");
|
||||||
expect(full).toMatchObject({ status: "Active", title: "Dallas DC", notes: "Gate code 1234" });
|
expect(full).toMatchObject({ status: "Active", title: "Dallas DC", notes: "Gate code 1234" });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("keeps the legacy contact name when the caller sends no contacts list", () => {
|
||||||
|
const addressOnly = mapLocationToBackend({
|
||||||
|
name: "DAL1",
|
||||||
|
address: "3811 Distribution Dr",
|
||||||
|
contact: "Jane Doe",
|
||||||
|
});
|
||||||
|
const withContacts = mapLocationToBackend({
|
||||||
|
contact: "Jane Doe",
|
||||||
|
contacts: [{ name: "Bob", phone: "(421) 433-0033" }],
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(addressOnly.contact).toBe("Jane Doe");
|
||||||
|
expect(withContacts.contact).toBe("Bob");
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("mapLocation site fields", () => {
|
describe("mapLocation site fields", () => {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue