mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-10-04 17:12:06 +00:00
- Sites page: Add Site modal with Site Code, Client, address, State/Area, optional Site Phone and Email, points of contact - Duplicate Site Code shows inline under the field and keeps the modal open - Row opens a non-modal detail panel; Street Address links to Google Maps; key-less map preview - Edit switches the panel in place with Site Code read-only; Save needs a valid change, Cancel makes no call - Site Phone is sent independently of the contacts; zip and title are carried through edits - Retire the separate new/edit location pages
24 lines
959 B
TypeScript
24 lines
959 B
TypeScript
import { normalizeStateCode } from "@/data/areas";
|
|
import type { LocationFormValues } from "@/domain/locations/schemas/location-schema";
|
|
import type { Location } from "@/domain/locations/types/location";
|
|
|
|
/** Edit-mode defaults from a site; zip and title are carried so a save keeps them. */
|
|
export function toSiteFormValues(location: Location): LocationFormValues {
|
|
const contacts =
|
|
location.contacts && location.contacts.length > 0
|
|
? location.contacts
|
|
: [{ name: location.contact ?? "", phone: location.phone ?? "" }];
|
|
|
|
return {
|
|
name: location.name ?? "",
|
|
accountId: location.accountId != null ? String(location.accountId) : "",
|
|
address: location.address ?? "",
|
|
city: location.city ?? "",
|
|
state: normalizeStateCode(location.state) ?? "",
|
|
sitePhone: location.sitePhone ?? "",
|
|
contactEmail: location.contactEmail ?? "",
|
|
contacts,
|
|
zipCode: location.zipCode ?? "",
|
|
title: location.title ?? "",
|
|
};
|
|
}
|