@7365admin1/layer-common 4.90.2-staging.491 → 4.90.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -4
- package/assets/css/primitives.css +0 -57
- package/assets/css/screens.css +4 -8
- package/components/AccessCardDetailsDialog.vue +6 -59
- package/components/AccessCardPreviewDialog.vue +53 -371
- package/components/AppSelect.vue +4 -143
- package/components/BuildingUnitFormEdit.vue +0 -6
- package/components/Dialog/UpdateMoreAction.vue +1 -11
- package/components/DocumentForm.vue +112 -407
- package/components/DocumentManagement.vue +12 -213
- package/components/Facility/BookingSetup.vue +0 -63
- package/components/HidAccessLogDashboard.vue +17 -74
- package/components/HidIntercomManagement.vue +14 -183
- package/components/HidQrCodeConfiguration.vue +195 -17
- package/components/HidReaderManagement.vue +0 -398
- package/components/HidReaderUserRoster.vue +3 -44
- package/components/HidUserEnrollment.vue +292 -2255
- package/components/InventoryItemDetail.vue +1 -2
- package/components/InventoryLinesDialog.vue +13 -91
- package/components/InventoryPhotoInput.vue +6 -44
- package/components/InventoryReportsTab.vue +3 -23
- package/components/InventoryRequestsTab.vue +4 -27
- package/components/InventoryStockTab.vue +0 -3
- package/components/InvitationClientForm.vue +1 -19
- package/components/InvitationForm.vue +4 -31
- package/components/InvitationMain.vue +22 -124
- package/components/MemberInformation.vue +4 -4
- package/components/PassInformation.vue +2 -2
- package/components/SiteSettings.vue +0 -48
- package/components/TableMain.vue +7 -22
- package/components/VehicleManagement.vue +5 -80
- package/components/VisitorForm.vue +19 -65
- package/components/VisitorManagement.vue +5 -267
- package/composables/useAccessManagement.ts +1 -17
- package/composables/useDocument.ts +0 -7
- package/composables/useFacility.ts +0 -11
- package/composables/useHidAmico.ts +0 -165
- package/composables/useHidNavigation.ts +1 -25
- package/composables/useInventory.ts +1 -4
- package/composables/useMember.ts +0 -12
- package/composables/useNFCPatrolReportFilters.ts +3 -21
- package/composables/useNFCPatrolRoute.ts +1 -8
- package/composables/usePeople.ts +0 -19
- package/composables/useServiceProvider.ts +2 -45
- package/composables/useSettingsPermission.ts +0 -14
- package/composables/useUser.ts +2 -6
- package/composables/useVehicle.ts +1 -40
- package/composables/useVerification.ts +0 -3
- package/middleware/01.auth.ts +7 -3
- package/package.json +1 -1
- package/pages/[org]/[site]/access-mgmt/administrator/index.vue +1 -1
- package/pages/[org]/[site]/access-mgmt/hid-cards/index.vue +1 -1
- package/pages/[org]/[site]/access-mgmt/hid-readers/index.vue +1 -1
- package/types/document.d.ts +0 -14
- package/types/facility.d.ts +0 -4
- package/types/inventory.d.ts +0 -27
- package/types/member.d.ts +0 -4
- package/types/people.d.ts +1 -28
- package/types/service-provider.d.ts +0 -5
- package/types/site.d.ts +1 -7
- package/components/BuildingUnitManagement.vue +0 -298
- package/components/HidAccessPermissions.vue +0 -424
- package/components/HidProfileQrCode.vue +0 -332
- package/components/InventoryPoDialog.vue +0 -111
- package/components/VehicleQrStickerDialog.vue +0 -249
- package/composables/useHidReaderSelection.ts +0 -50
- package/composables/useSiteCategory.ts +0 -45
- package/pages/[org]/[site]/access-mgmt/hid-qr-code/index.vue +0 -23
- package/utils/hid-enrolment-subject.ts +0 -344
- package/utils/hid-permission-assignments.ts +0 -198
- package/utils/hid-reader-selection.ts +0 -52
- package/utils/inventory-receiving.ts +0 -90
- package/utils/invite-group.ts +0 -61
- package/utils/invite-sites.ts +0 -25
- package/utils/occupancy-role.ts +0 -109
- package/utils/service-type.ts +0 -30
- package/utils/vehicle-qr-sticker.ts +0 -184
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WHICH HID READER THE OPERATOR IS WORKING ON — the one rule behind it.
|
|
3
|
-
*
|
|
4
|
-
* Every HID screen used to hold its own `ref("")` and default it to
|
|
5
|
-
* `readers[0]`, so picking HID 2 on HID Reader Users and clicking through to
|
|
6
|
-
* HID Cards put you back on HID 1. They are separate PAGES, so the component
|
|
7
|
-
* unmounted and the ref was rebuilt from scratch every time — there was no way
|
|
8
|
-
* to make a choice stick. "I am working on HID 2" is a mode, not a per-screen
|
|
9
|
-
* preference.
|
|
10
|
-
*
|
|
11
|
-
* Navigation between those pages is a route change rather than a page load
|
|
12
|
-
* (`NavigationItem.vue` renders the menu's `route` through `:to`), so the
|
|
13
|
-
* module-scoped ref in `useHidReaderSelection` survives it. This file holds the
|
|
14
|
-
* part worth testing: deciding whether a remembered choice may still be used.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
export type HidReaderChoice = { siteId: string; readerId: string };
|
|
18
|
-
|
|
19
|
-
/** Anything with an id — the four screens all carry a different reader shape. */
|
|
20
|
-
type ReaderLike = { _id?: unknown };
|
|
21
|
-
|
|
22
|
-
export const EMPTY_HID_READER_CHOICE: HidReaderChoice = { siteId: "", readerId: "" };
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* The reader a screen should show, given what this site actually has.
|
|
26
|
-
*
|
|
27
|
-
* A remembered id is honoured ONLY when it belongs to this site and is still in
|
|
28
|
-
* the list. That single condition covers every way it goes stale:
|
|
29
|
-
*
|
|
30
|
-
* - the operator switched site, so the id belongs to a site they have left
|
|
31
|
-
* - the reader was deleted or deactivated since they chose it
|
|
32
|
-
* - nothing has been chosen yet
|
|
33
|
-
*
|
|
34
|
-
* In all three the first reader is returned instead. The alternative — using
|
|
35
|
-
* the id anyway — sends requests for a reader the site does not own, which come
|
|
36
|
-
* back empty and read on screen as a reader with no users, no cards and no
|
|
37
|
-
* logs, rather than as the mistake it is.
|
|
38
|
-
*/
|
|
39
|
-
export function resolveHidReaderId(
|
|
40
|
-
siteId: string,
|
|
41
|
-
readers: readonly ReaderLike[] | null | undefined,
|
|
42
|
-
choice: HidReaderChoice = EMPTY_HID_READER_CHOICE,
|
|
43
|
-
): string {
|
|
44
|
-
const ids = (Array.isArray(readers) ? readers : [])
|
|
45
|
-
.map((reader) => String(reader?._id ?? ""))
|
|
46
|
-
.filter(Boolean);
|
|
47
|
-
|
|
48
|
-
if (choice.siteId === String(siteId ?? "") && ids.includes(choice.readerId)) {
|
|
49
|
-
return choice.readerId;
|
|
50
|
-
}
|
|
51
|
-
return ids[0] ?? "";
|
|
52
|
-
}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Receiving (client meeting 2026-10-02): how a delivery came in, and the limits on its photos.
|
|
3
|
-
* The server (API-core `receiveSchema`) is the gate; these keep the form from sending what it refuses.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
export type TReceivingType = "PO" | "DO" | "CASH";
|
|
7
|
-
|
|
8
|
-
export const RECEIVING_TYPES: { value: TReceivingType; title: string; help: string }[] = [
|
|
9
|
-
{ value: "PO", title: "Purchase order (PO)", help: "Goods ordered with a PO. Enter the PO number so you can track what has arrived against what was ordered." },
|
|
10
|
-
{ value: "DO", title: "Delivery order (DO)", help: "Goods came with a supplier's delivery order. The DO number and DO date are needed; add the PO number too if there is one." },
|
|
11
|
-
{ value: "CASH", title: "Cash purchase", help: "Bought and paid on the spot. Enter the shop receipt number if there is one." },
|
|
12
|
-
];
|
|
13
|
-
|
|
14
|
-
/** Old rows carry no type: they were PO receipts. */
|
|
15
|
-
export const receivingLabel = (t?: string | null) => ({ PO: "PO", DO: "DO", CASH: "Cash" })[String(t || "PO").toUpperCase() as TReceivingType] ?? "PO";
|
|
16
|
-
|
|
17
|
-
/** "PO PO-0412 · DO D-77 (1 Oct)" — the paperwork a delivery came with, for history lines. */
|
|
18
|
-
export function receiptRefText(
|
|
19
|
-
t: { receivingType?: string | null; reference?: string; doNumber?: string; receiptNumber?: string },
|
|
20
|
-
) {
|
|
21
|
-
return [
|
|
22
|
-
t.reference ? `PO ${t.reference}` : "",
|
|
23
|
-
t.doNumber ? `DO ${t.doNumber}` : "",
|
|
24
|
-
t.receiptNumber ? `Receipt ${t.receiptNumber}` : "",
|
|
25
|
-
String(t.receivingType || "").toUpperCase() === "CASH" && !t.receiptNumber ? "Cash purchase" : "",
|
|
26
|
-
]
|
|
27
|
-
.filter(Boolean)
|
|
28
|
-
.join(" · ");
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/** "60 of 100 received · 40 still to come" / "60 received (ordered quantity not recorded)". */
|
|
32
|
-
export function poLineText(l: { ordered: number | null; received: number; outstanding: number | null; unit?: string }) {
|
|
33
|
-
const u = l.unit ? ` ${l.unit}` : "";
|
|
34
|
-
if (l.ordered === null || l.ordered === undefined) return `${l.received}${u} received (ordered quantity not recorded)`;
|
|
35
|
-
const rest = l.outstanding ? `${l.outstanding}${u} still to come` : l.received > l.ordered ? `${l.received - l.ordered}${u} more than ordered` : "all received";
|
|
36
|
-
return `${l.received} of ${l.ordered}${u} received · ${rest}`;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/** What the form must still have before a receipt of this type can be sent ("" = ready). */
|
|
40
|
-
export function receivingProblem(f: { type: TReceivingType; poNumber: string; doNumber: string; doDate: string; anyOrdered: boolean }) {
|
|
41
|
-
if (f.type === "PO" && !f.poNumber.trim()) return "Enter the PO number.";
|
|
42
|
-
if (f.type === "DO" && !f.doNumber.trim()) return "Enter the DO number for a delivery order (DO) receipt.";
|
|
43
|
-
if (f.type === "DO" && !f.doDate) return "Enter the DO date.";
|
|
44
|
-
if (f.anyOrdered && !f.poNumber.trim()) return "Enter the PO number to record the quantity ordered.";
|
|
45
|
-
return "";
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/** The type-specific part of the receive body: only the fields that belong to the chosen type. */
|
|
49
|
-
export function receivingFields(f: { type: TReceivingType; poNumber: string; doNumber: string; doDateIso?: string; receiptNumber: string }) {
|
|
50
|
-
return {
|
|
51
|
-
receivingType: f.type,
|
|
52
|
-
reference: f.type === "CASH" ? "" : f.poNumber.trim(),
|
|
53
|
-
...(f.type === "DO" ? { doNumber: f.doNumber.trim(), ...(f.doDateIso ? { doDate: f.doDateIso } : {}) } : {}),
|
|
54
|
-
...(f.type === "CASH" && f.receiptNumber.trim() ? { receiptNumber: f.receiptNumber.trim() } : {}),
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/** Photos: what the server accepts (JPEG / PNG / WebP / iPhone HEIC), 5 MB each. */
|
|
59
|
-
export const PHOTO_MAX_BYTES = 5 * 1024 * 1024;
|
|
60
|
-
export const PHOTO_ACCEPT = "image/jpeg,image/png,image/webp,image/heic,image/heif,.jpg,.jpeg,.png,.webp,.heic,.heif";
|
|
61
|
-
const PHOTO_EXT = /\.(jpe?g|png|webp|heic|heif)$/i;
|
|
62
|
-
/** Types a browser canvas can redraw smaller (not HEIC). */
|
|
63
|
-
const SHRINKABLE = ["image/jpeg", "image/png", "image/webp"];
|
|
64
|
-
|
|
65
|
-
const mb = (bytes: number) => (bytes / 1024 / 1024).toFixed(1);
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* What to do with a picked file: "ok", "shrink" (too big but the browser can make it smaller),
|
|
69
|
-
* or a sentence telling the person why it cannot be used.
|
|
70
|
-
*/
|
|
71
|
-
export function photoCheck(file: { name: string; type: string; size: number }): "ok" | "shrink" | string {
|
|
72
|
-
const typeOk = /^image\/(jpeg|png|webp|heic|heif)$/i.test(file.type) || (!file.type && PHOTO_EXT.test(file.name));
|
|
73
|
-
if (!typeOk) return `"${file.name}" is not a photo we can use. Please pick a JPG, PNG or WebP picture.`;
|
|
74
|
-
if (file.size <= PHOTO_MAX_BYTES) return "ok";
|
|
75
|
-
if (SHRINKABLE.includes(file.type.toLowerCase())) return "shrink";
|
|
76
|
-
return `"${file.name}" is ${mb(file.size)} MB. Each photo must be 5 MB or smaller — please take it at a lower size or pick another.`;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/** Long side of a shrunk photo, and JPEG qualities to try in turn until it fits. */
|
|
80
|
-
export const SHRINK_STEPS = [
|
|
81
|
-
{ side: 2560, quality: 0.85 },
|
|
82
|
-
{ side: 1920, quality: 0.8 },
|
|
83
|
-
{ side: 1600, quality: 0.7 },
|
|
84
|
-
];
|
|
85
|
-
|
|
86
|
-
/** Size of a photo scaled so its longer side is at most `side` (never enlarged). */
|
|
87
|
-
export function scaledSize(width: number, height: number, side: number) {
|
|
88
|
-
const k = Math.min(1, side / Math.max(width, height));
|
|
89
|
-
return { width: Math.round(width * k), height: Math.round(height * k) };
|
|
90
|
-
}
|
package/utils/invite-group.ts
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Invitations list, multi-site invitations (owner request 2026-10-02): the
|
|
3
|
-
* server (`GET /api/verifications?group=true`) returns ONE entry per invitation
|
|
4
|
-
* group with its `sites`; an old single-site invitation is a group of one.
|
|
5
|
-
*/
|
|
6
|
-
export type InviteSiteRow = {
|
|
7
|
-
_id: string;
|
|
8
|
-
siteId?: string;
|
|
9
|
-
siteName?: string;
|
|
10
|
-
status?: string;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export type InviteEntry = {
|
|
14
|
-
_id?: string;
|
|
15
|
-
email?: string;
|
|
16
|
-
metadata?: Record<string, any>;
|
|
17
|
-
sites?: InviteSiteRow[];
|
|
18
|
-
siteCount?: number;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export function siteCountOf(item: InviteEntry): number {
|
|
22
|
-
return item.siteCount ?? item.sites?.length ?? 1;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/** "LakeGarden" for one site, "21 sites" for a group (details list them all). */
|
|
26
|
-
export function siteLabel(item: InviteEntry): string {
|
|
27
|
-
const n = siteCountOf(item);
|
|
28
|
-
if (n > 1) return `${n} sites`;
|
|
29
|
-
return item.sites?.[0]?.siteName || item.metadata?.siteName || "";
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/** Every verification id the entry stands for (Cancel all). */
|
|
33
|
-
export function groupIds(item: InviteEntry): string[] {
|
|
34
|
-
const ids = item.sites?.length
|
|
35
|
-
? item.sites.map((s) => s._id)
|
|
36
|
-
: [item._id ?? ""];
|
|
37
|
-
return ids.filter(Boolean).map(String);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Arguments of `inviteMemberClient` that re-send the invitation: ONE request,
|
|
42
|
-
* so ONE e-mail for the whole group. `null` when it cannot be rebuilt (no org).
|
|
43
|
-
*/
|
|
44
|
-
export function resendArgs(item: InviteEntry) {
|
|
45
|
-
const m = item.metadata ?? {};
|
|
46
|
-
if (!item.email || !m.org) return null;
|
|
47
|
-
const sites = (item.sites ?? [])
|
|
48
|
-
.map((s) => s.siteId)
|
|
49
|
-
.filter(Boolean)
|
|
50
|
-
.map(String);
|
|
51
|
-
return {
|
|
52
|
-
email: item.email,
|
|
53
|
-
app: m.app ?? "",
|
|
54
|
-
role: m.role ? String(m.role) : "",
|
|
55
|
-
name: m.name ?? "",
|
|
56
|
-
org: String(m.org),
|
|
57
|
-
sites: sites.length > 1 ? sites : [],
|
|
58
|
-
site: sites.length === 1 ? sites[0] : m.siteId ? String(m.siteId) : "",
|
|
59
|
-
siteName: item.sites?.[0]?.siteName || m.siteName || "",
|
|
60
|
-
};
|
|
61
|
-
}
|
package/utils/invite-sites.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Which sites an "Invite member" request names (owner request 2026-10-02:
|
|
3
|
-
* invite one person to several sites). One site keeps the old `siteId` shape;
|
|
4
|
-
* 2 or more send `siteIds` (the server writes one invitation per site and
|
|
5
|
-
* names every site in one e-mail).
|
|
6
|
-
*/
|
|
7
|
-
export function inviteSitePayload(
|
|
8
|
-
sites: string[],
|
|
9
|
-
siteName = "",
|
|
10
|
-
): Record<string, unknown> {
|
|
11
|
-
if (!sites.length) return {};
|
|
12
|
-
if (sites.length === 1) {
|
|
13
|
-
return { siteId: sites[0], ...(siteName && { siteName }) };
|
|
14
|
-
}
|
|
15
|
-
return { siteIds: sites };
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* The one site a role is looked up for: the single chosen site, or "" for 2+
|
|
20
|
-
* (a site role is valid at its own site only, so several sites offer
|
|
21
|
-
* organisation roles only).
|
|
22
|
-
*/
|
|
23
|
-
export function roleSiteFor(sites: string[]): string {
|
|
24
|
-
return sites.length === 1 ? sites[0] : "";
|
|
25
|
-
}
|
package/utils/occupancy-role.ts
DELETED
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* OWNER / OCCUPANT / PERSON IN CHARGE - the three standings a business
|
|
3
|
-
* tenancy has, and everything the product says about them.
|
|
4
|
-
*
|
|
5
|
-
* One list, because three screens read it: the form that asks the question
|
|
6
|
-
* (`PeopleFormMgmt`), the list and preview that print the answer back, and
|
|
7
|
-
* the row menu that reassigns it (`people-mgmt`). The values are the ones the
|
|
8
|
-
* server stores and validates - `OccupancyRoles` in core's `person.model.ts`
|
|
9
|
-
* - so a value added on one side has to be added on the other.
|
|
10
|
-
*/
|
|
11
|
-
export const OCCUPANCY_ROLE_OPTIONS: TOccupancyRoleOption[] = [
|
|
12
|
-
{
|
|
13
|
-
value: "owner",
|
|
14
|
-
title: "Owner",
|
|
15
|
-
action: "Assign Owner",
|
|
16
|
-
prompt: "Assign Owner",
|
|
17
|
-
description:
|
|
18
|
-
"The legal titleholder or primary deed owner of the property.",
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
value: "occupant",
|
|
22
|
-
title: "Occupant",
|
|
23
|
-
action: "Assign Occupant",
|
|
24
|
-
prompt: "Assign Occupant",
|
|
25
|
-
description:
|
|
26
|
-
"The person currently living in, renting, or utilizing the physical unit.",
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
value: "person-in-charge",
|
|
30
|
-
title: "Person in Charge",
|
|
31
|
-
action: "Assign Person in Charge",
|
|
32
|
-
prompt: "Assign Person in Charge (PIC)",
|
|
33
|
-
description:
|
|
34
|
-
"The designated manager responsible for maintenance, emergencies, and daily operations.",
|
|
35
|
-
},
|
|
36
|
-
];
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* The same three, in the order the ROW MENU draws them, which is not the
|
|
40
|
-
* order the form's radio does. Derived rather than re-typed so the wording
|
|
41
|
-
* cannot drift between the two.
|
|
42
|
-
*/
|
|
43
|
-
export const OCCUPANCY_ROLE_ACTIONS: TOccupancyRoleOption[] = (
|
|
44
|
-
["person-in-charge", "owner", "occupant"] as TOccupancyRole[]
|
|
45
|
-
).map(
|
|
46
|
-
(value) =>
|
|
47
|
-
OCCUPANCY_ROLE_OPTIONS.find(
|
|
48
|
-
(option) => option.value === value,
|
|
49
|
-
) as TOccupancyRoleOption,
|
|
50
|
-
);
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* The label for a stored role, or "" for a person who was never asked - which
|
|
54
|
-
* is everyone on a residential site and everyone saved before the question
|
|
55
|
-
* existed. Callers decide what to print instead; nobody should print a raw
|
|
56
|
-
* `person-in-charge` at a user.
|
|
57
|
-
*/
|
|
58
|
-
export function occupancyRoleLabel(role?: string | null): string {
|
|
59
|
-
return (
|
|
60
|
-
OCCUPANCY_ROLE_OPTIONS.find((option) => option.value === role)?.title ?? ""
|
|
61
|
-
);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Does this person hold OWNER at their unit?
|
|
66
|
-
*
|
|
67
|
-
* The role when there is one, `isOwner` when there is not - the same test the
|
|
68
|
-
* server applies (`holdsUnitOwner` in core's `unit-owner.util.ts`). A person
|
|
69
|
-
* recorded before the role existed carries only the flag, and the people list
|
|
70
|
-
* already prints them as "Owner".
|
|
71
|
-
*/
|
|
72
|
-
export function holdsUnitOwner(person?: {
|
|
73
|
-
occupancyRole?: string | null;
|
|
74
|
-
isOwner?: boolean;
|
|
75
|
-
}): boolean {
|
|
76
|
-
if (!person) return false;
|
|
77
|
-
|
|
78
|
-
if (person.occupancyRole) return person.occupancyRole === "owner";
|
|
79
|
-
|
|
80
|
-
return person.isOwner === true;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* MUST THIS PERSON HAND THE UNIT OVER BEFORE THEY CAN BE DEACTIVATED?
|
|
85
|
-
*
|
|
86
|
-
* The owner of a unit does not leave while they still own it - the standing
|
|
87
|
-
* moves to another tenant at the same block, level and unit first.
|
|
88
|
-
*
|
|
89
|
-
* Keyed to the ROLE and never to `isOwner`, exactly as the server keys it
|
|
90
|
-
* (`mustHandOverBeforeDeactivating` in core): the flag is on every resident in
|
|
91
|
-
* the estate, and no residential screen can change it, so a rule keyed to it
|
|
92
|
-
* would trap records that can never satisfy it.
|
|
93
|
-
*/
|
|
94
|
-
export function mustHandOverBeforeDeactivating(person?: {
|
|
95
|
-
occupancyRole?: string | null;
|
|
96
|
-
}): boolean {
|
|
97
|
-
return person?.occupancyRole === "owner";
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* Why a deactivation was held back. The SERVER carries the enforcing copy of
|
|
102
|
-
* this rule and of these words (core `unit-owner.util.ts`); this one exists so
|
|
103
|
-
* the console can say it before the round trip rather than after.
|
|
104
|
-
*/
|
|
105
|
-
export function ownerHandoverRequiredMessage(name?: string): string {
|
|
106
|
-
const who = name?.trim() ? `"${name.trim()}"` : "This person";
|
|
107
|
-
|
|
108
|
-
return `${who} is the owner of this unit. Assign the owner role to another tenant at the same block, level and unit before deactivating them.`;
|
|
109
|
-
}
|
package/utils/service-type.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A SERVICE PROVIDER'S LINE OF BUSINESS, AS PEOPLE NAME IT.
|
|
3
|
-
*
|
|
4
|
-
* `/api/service-providers` returns the service CODE (`mechanical_electrical_services`),
|
|
5
|
-
* which is a database value, not something to show an operator. This is the same
|
|
6
|
-
* mapping `API-core src/utils/converter.ts spmServiceNewToOld` applies — copied
|
|
7
|
-
* rather than imported, because that is a server package this layer does not
|
|
8
|
-
* depend on.
|
|
9
|
-
*
|
|
10
|
-
* NOT the same labels as `utils/module-applications.ts APPLICATIONS`. Those name
|
|
11
|
-
* the seven role-permission applications ("Mechanical & electrical", "Pest
|
|
12
|
-
* control") and are keyed `mechanical-electrical`, not `*_services`. These are
|
|
13
|
-
* the shorter names the service-provider screens use ("M&E", "Pest Control").
|
|
14
|
-
*
|
|
15
|
-
* An unknown code is returned untouched: a new service type shows as its raw
|
|
16
|
-
* code, which is visibly odd, rather than vanishing from the row.
|
|
17
|
-
*/
|
|
18
|
-
const SERVICE_TYPE_LABELS: Readonly<Record<string, string>> = Object.freeze({
|
|
19
|
-
security_agency: "Security",
|
|
20
|
-
cleaning_services: "Cleaning",
|
|
21
|
-
pool_maintenance_services: "Pool Maintenance",
|
|
22
|
-
pest_control_services: "Pest Control",
|
|
23
|
-
landscaping_services: "Landscape",
|
|
24
|
-
mechanical_electrical_services: "Mechanical & Electrical",
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
export function serviceTypeLabel(service: string | null | undefined): string {
|
|
28
|
-
const code = String(service ?? "");
|
|
29
|
-
return SERVICE_TYPE_LABELS[code] ?? code;
|
|
30
|
-
}
|
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Vehicle QR stickers - the pure parts (labels, selection, paging, print page).
|
|
3
|
-
*
|
|
4
|
-
* Kept free of Vue and of the QR library so `node --test` can run it. The
|
|
5
|
-
* sticker itself carries NO resident detail: just the QR, the plate and the
|
|
6
|
-
* Seven365 line. Block / level / unit / owner appear ONLY on the installer
|
|
7
|
-
* strip under the dashed cut line, which is cut off before the sticker is
|
|
8
|
-
* pasted on the car.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
/** The server's most vehicles per request (POST /api/vehicles/qr/stickers). */
|
|
12
|
-
export const STICKER_MAX_PER_REQUEST = 500;
|
|
13
|
-
|
|
14
|
-
/** A4 sheet: 4 columns x 4 rows of 47 mm cells. */
|
|
15
|
-
export const STICKER_COLUMNS = 4;
|
|
16
|
-
export const STICKER_ROWS = 4;
|
|
17
|
-
export const STICKERS_PER_PAGE = STICKER_COLUMNS * STICKER_ROWS;
|
|
18
|
-
|
|
19
|
-
export type StickerItem = {
|
|
20
|
-
vehicleId: string;
|
|
21
|
-
qr: string;
|
|
22
|
-
token?: string;
|
|
23
|
-
block?: string;
|
|
24
|
-
level?: string;
|
|
25
|
-
unit?: string;
|
|
26
|
-
plateNumber?: string;
|
|
27
|
-
ownerName?: string;
|
|
28
|
-
status?: string;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
export type StickerPlateRow = {
|
|
32
|
-
id: string;
|
|
33
|
-
plateNumber: string;
|
|
34
|
-
status: string;
|
|
35
|
-
ownerName: string;
|
|
36
|
-
unitLabel: string;
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
const text = (v: unknown) => (v == null ? "" : String(v).trim());
|
|
40
|
-
|
|
41
|
-
/** "Blk 4 #02-01". Tolerates a unit that already carries its level ("02-01"). */
|
|
42
|
-
export function stickerUnitLabel(parts: { block?: unknown; level?: unknown; unit?: unknown }): string {
|
|
43
|
-
const block = text(parts.block).replace(/^(blk|block)\.?\s*/i, "");
|
|
44
|
-
const level = text(parts.level).replace(/^(level|lvl|floor)\.?\s*/i, "");
|
|
45
|
-
const unit = text(parts.unit).replace(/^(unit)\.?\s*/i, "").replace(/^#/, "");
|
|
46
|
-
const home = unit.includes("-") || !level ? unit : `${level}-${unit}`;
|
|
47
|
-
return [block ? `Blk ${block}` : "", home ? `#${home}` : ""].filter(Boolean).join(" ");
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/** The installer strip under the cut line: where it goes and whose car. */
|
|
51
|
-
export function installerLine(item: Pick<StickerItem, "block" | "level" | "unit" | "ownerName">): {
|
|
52
|
-
place: string;
|
|
53
|
-
owner: string;
|
|
54
|
-
} {
|
|
55
|
-
return { place: stickerUnitLabel(item), owner: text(item.ownerName) };
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export type StickerWarning = { level: "error" | "warning"; text: string };
|
|
59
|
-
|
|
60
|
-
/** What the preview says about a status. Null = nothing to warn about. */
|
|
61
|
-
export function stickerWarning(status: unknown): StickerWarning | null {
|
|
62
|
-
switch (text(status).toLowerCase()) {
|
|
63
|
-
case "expired":
|
|
64
|
-
return { level: "error", text: "Season pass expired" };
|
|
65
|
-
case "blocklisted":
|
|
66
|
-
return { level: "error", text: "On the blocklist" };
|
|
67
|
-
case "inactive":
|
|
68
|
-
return { level: "warning", text: "Vehicle is inactive" };
|
|
69
|
-
case "pending":
|
|
70
|
-
return { level: "warning", text: "Waiting for approval" };
|
|
71
|
-
default:
|
|
72
|
-
return null;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/** Stickers that should NOT be ticked for printing until someone chooses to. */
|
|
77
|
-
export function stickerStartsUnticked(status: unknown): boolean {
|
|
78
|
-
return stickerWarning(status)?.level === "error" || text(status).toLowerCase() === "inactive";
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/** The ids ticked by default in the preview. */
|
|
82
|
-
export function defaultStickerIds(items: Pick<StickerItem, "vehicleId" | "status">[]): string[] {
|
|
83
|
-
return items.filter((i) => !stickerStartsUnticked(i.status)).map((i) => i.vehicleId);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/** One selectable row per plate, from the list's grouped rows. */
|
|
87
|
-
export function stickerPlateRows(rows: Array<Record<string, any>>): StickerPlateRow[] {
|
|
88
|
-
const out: StickerPlateRow[] = [];
|
|
89
|
-
for (const row of rows ?? []) {
|
|
90
|
-
const plates: any[] = Array.isArray(row?.plates) && row.plates.length ? row.plates : [row];
|
|
91
|
-
for (const plate of plates) {
|
|
92
|
-
if (!plate?._id) continue;
|
|
93
|
-
out.push({
|
|
94
|
-
id: String(plate._id),
|
|
95
|
-
plateNumber: text(plate.plateNumber),
|
|
96
|
-
status: text(plate.status).toLowerCase(),
|
|
97
|
-
ownerName: text(row?.name ?? plate.name),
|
|
98
|
-
unitLabel: stickerUnitLabel({
|
|
99
|
-
block: row?.block?.name ?? row?.block,
|
|
100
|
-
level: row?.level?.name ?? row?.level,
|
|
101
|
-
unit: row?.unit?.name ?? row?.unit,
|
|
102
|
-
}),
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
return out;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/** Plates ticked on first open: live ones only (active / season pass). */
|
|
110
|
-
export function defaultPlateIds(plates: StickerPlateRow[]): string[] {
|
|
111
|
-
return plates.filter((p) => p.status === "active" || p.status === "temporary").map((p) => p.id);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/** Tick or untick a group of ids (e.g. "select all on this page"). */
|
|
115
|
-
export function setIds(selected: string[], ids: string[], on: boolean): string[] {
|
|
116
|
-
const rest = selected.filter((id) => !ids.includes(id));
|
|
117
|
-
return on ? [...rest, ...ids] : rest;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
/** The ids to send: unique, in order, at most what the server accepts. */
|
|
121
|
-
export function idsForRequest(ids: string[]): { ids: string[]; dropped: number } {
|
|
122
|
-
const unique = [...new Set(ids)];
|
|
123
|
-
return { ids: unique.slice(0, STICKER_MAX_PER_REQUEST), dropped: Math.max(0, unique.length - STICKER_MAX_PER_REQUEST) };
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
/** Split into sheets. */
|
|
127
|
-
export function stickerPages<T>(items: T[], perPage: number = STICKERS_PER_PAGE): T[][] {
|
|
128
|
-
const pages: T[][] = [];
|
|
129
|
-
for (let i = 0; i < items.length; i += perPage) pages.push(items.slice(i, i + perPage));
|
|
130
|
-
return pages;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
export function escapeHtml(value: unknown): string {
|
|
134
|
-
return text(value)
|
|
135
|
-
.replace(/&/g, "&")
|
|
136
|
-
.replace(/</g, "<")
|
|
137
|
-
.replace(/>/g, ">")
|
|
138
|
-
.replace(/"/g, """)
|
|
139
|
-
.replace(/'/g, "'");
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
const PRINT_CSS = `
|
|
143
|
-
@page { size: A4; margin: 6mm; }
|
|
144
|
-
* { box-sizing: border-box; }
|
|
145
|
-
html, body { margin: 0; padding: 0; background: #fff; color: #111; font-family: Arial, Helvetica, sans-serif; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
|
|
146
|
-
.page { display: grid; grid-template-columns: repeat(${STICKER_COLUMNS}, 47mm); gap: 2mm; justify-content: center; align-content: start; width: 198mm; height: 285mm; margin: 0 auto; break-after: page; }
|
|
147
|
-
.page:last-child { break-after: auto; }
|
|
148
|
-
.cell { width: 47mm; break-inside: avoid; }
|
|
149
|
-
.card { width: 47mm; height: 58mm; border: 0.3mm solid #1a1a1a; border-radius: 3mm; padding: 2mm 2mm 1.6mm; display: flex; flex-direction: column; align-items: center; justify-content: space-between; text-align: center; }
|
|
150
|
-
.qr { width: 32mm; height: 32mm; display: block; }
|
|
151
|
-
.qr svg { width: 100%; height: 100%; display: block; }
|
|
152
|
-
.plate { font-size: 13pt; font-weight: 800; letter-spacing: 0.3mm; line-height: 1.1; }
|
|
153
|
-
.hint { font-size: 5.8pt; color: #333; line-height: 1.2; }
|
|
154
|
-
.brand { display: flex; align-items: center; justify-content: center; gap: 1mm; font-size: 6pt; color: #222; border-top: 0.2mm solid #ccc; width: 100%; padding-top: 1mm; }
|
|
155
|
-
.mark { width: 3.2mm; height: 3.2mm; border-radius: 0.8mm; background: #111; color: #fff; font-weight: 800; font-size: 5pt; line-height: 3.2mm; text-align: center; }
|
|
156
|
-
.cut { margin-top: 1.2mm; border-top: 0.3mm dashed #666; padding-top: 1mm; font-size: 6.5pt; line-height: 1.25; color: #111; min-height: 8mm; }
|
|
157
|
-
.cut .owner { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
158
|
-
.cut .note { color: #666; font-size: 5.5pt; }
|
|
159
|
-
@media screen { body { background: #e9e9e9; zoom: 0.75; padding: 4mm 0; } .page { background: #fff; margin-bottom: 4mm; height: auto; min-height: 285mm; box-shadow: 0 0 2mm rgba(0,0,0,.25); } }
|
|
160
|
-
`;
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
* One full HTML document: A4 sheets of stickers. `qrSvgs` is parallel to
|
|
164
|
-
* `items` (the QR for each, already drawn). Every value is HTML-escaped - an
|
|
165
|
-
* owner name is typed by a person.
|
|
166
|
-
*/
|
|
167
|
-
export function buildStickerDocument(items: StickerItem[], qrSvgs: string[]): string {
|
|
168
|
-
const cells = items.map((item, i) => {
|
|
169
|
-
const { place, owner } = installerLine(item);
|
|
170
|
-
return (
|
|
171
|
-
`<div class="cell"><div class="card">` +
|
|
172
|
-
`<div class="qr">${qrSvgs[i] ?? ""}</div>` +
|
|
173
|
-
`<div class="plate">${escapeHtml(item.plateNumber)}</div>` +
|
|
174
|
-
`<div class="hint">Scan with iSecure365 / iMA365</div>` +
|
|
175
|
-
`<div class="brand"><span class="mark">7</span>Powered by Seven365</div>` +
|
|
176
|
-
`</div>` +
|
|
177
|
-
`<div class="cut"><div><b>${escapeHtml(place || "-")}</b></div>` +
|
|
178
|
-
`<div class="owner">Owner: ${escapeHtml(owner || "-")}</div>` +
|
|
179
|
-
`<div class="note">Installer: cut here, then paste on this car</div></div></div>`
|
|
180
|
-
);
|
|
181
|
-
});
|
|
182
|
-
const pages = stickerPages(cells).map((p) => `<div class="page">${p.join("")}</div>`);
|
|
183
|
-
return `<!doctype html><html><head><meta charset="utf-8"><title>Vehicle QR stickers</title><style>${PRINT_CSS}</style></head><body>${pages.join("")}</body></html>`;
|
|
184
|
-
}
|