mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-10-04 13:42:09 +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
23 lines
1 KiB
TypeScript
23 lines
1 KiB
TypeScript
import { formatLocationAddressPreview } from "@/domain/locations/mappers/location-mapper";
|
|
import type { Location } from "@/domain/locations/types/location";
|
|
|
|
type SiteAddress = Pick<Location, "address" | "city" | "state" | "zipCode">;
|
|
|
|
/** Google Maps search link for a site address; opens in a new tab. */
|
|
export function buildSiteMapsUrl(location: SiteAddress): string {
|
|
const query = formatLocationAddressPreview(location);
|
|
return `https://www.google.com/maps/search/?api=1&query=${encodeURIComponent(query)}`;
|
|
}
|
|
|
|
/** True once Street, City and State are all filled, so a map preview can render. */
|
|
export function hasCompleteSiteAddress(location: SiteAddress): boolean {
|
|
return [location.address, location.city, location.state].every(
|
|
(part) => (part?.trim() ?? "") !== "",
|
|
);
|
|
}
|
|
|
|
/** Key-less Google Maps embed URL for the read-only preview. */
|
|
export function buildSiteMapEmbedUrl(location: SiteAddress): string {
|
|
const query = formatLocationAddressPreview(location);
|
|
return `https://www.google.com/maps?q=${encodeURIComponent(query)}&output=embed`;
|
|
}
|