@7365admin1/layer-common 4.35.1-staging.374 → 4.35.1-staging.376
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/assets/css/primitives.css +43 -0
- package/components/AppSelect.vue +77 -3
- package/components/ClientInvitations.vue +259 -0
- package/components/HidAccessLogDashboard.vue +33 -9
- package/components/HidIntercomManagement.vue +41 -9
- package/components/ServiceProviderMain.vue +5 -2
- package/composables/useHidAmico.ts +10 -0
- package/composables/useServiceProviderInvitation.ts +39 -11
- package/package.json +1 -1
- package/utils/notification-target.ts +3 -3
- package/components/ServiceProviderInvitationPrompt.vue +0 -162
- package/components/ServiceProviderInvitationsReceived.vue +0 -113
|
@@ -775,6 +775,49 @@ select option {
|
|
|
775
775
|
box-shadow: var(--shadow-menu);
|
|
776
776
|
}
|
|
777
777
|
|
|
778
|
+
/* The filter box of a `searchable` AppSelect. Sticky rather than scrolled
|
|
779
|
+
away with the options: the list it filters is long enough to need scrolling,
|
|
780
|
+
which is the only reason the box is there. */
|
|
781
|
+
.app-select__search {
|
|
782
|
+
position: sticky;
|
|
783
|
+
top: -6px;
|
|
784
|
+
z-index: 1;
|
|
785
|
+
display: flex;
|
|
786
|
+
align-items: center;
|
|
787
|
+
gap: 6px;
|
|
788
|
+
margin: -6px -6px 4px;
|
|
789
|
+
padding: 8px 10px;
|
|
790
|
+
border-bottom: 1px solid var(--border);
|
|
791
|
+
background: var(--card);
|
|
792
|
+
color: var(--muted);
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
.app-select__search-input {
|
|
796
|
+
flex: 1;
|
|
797
|
+
min-width: 0;
|
|
798
|
+
border: none;
|
|
799
|
+
outline: none;
|
|
800
|
+
background: none;
|
|
801
|
+
font-family: var(--font-sans);
|
|
802
|
+
font-size: var(--fs-cell);
|
|
803
|
+
font-weight: 500;
|
|
804
|
+
color: var(--text);
|
|
805
|
+
}
|
|
806
|
+
|
|
807
|
+
.app-select__search-input::placeholder {
|
|
808
|
+
color: var(--muted);
|
|
809
|
+
font-weight: 500;
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
.app-select__empty {
|
|
813
|
+
margin: 0;
|
|
814
|
+
padding: 10px 8px;
|
|
815
|
+
font-family: var(--font-sans);
|
|
816
|
+
font-size: var(--fs-cell);
|
|
817
|
+
color: var(--muted);
|
|
818
|
+
text-align: center;
|
|
819
|
+
}
|
|
820
|
+
|
|
778
821
|
.app-select__option {
|
|
779
822
|
display: flex;
|
|
780
823
|
align-items: center;
|
package/components/AppSelect.vue
CHANGED
|
@@ -18,7 +18,8 @@
|
|
|
18
18
|
<template>
|
|
19
19
|
<v-menu
|
|
20
20
|
v-if="!multiple"
|
|
21
|
-
|
|
21
|
+
v-model="singleOpen"
|
|
22
|
+
:close-on-content-click="!searchable"
|
|
22
23
|
:disabled="disabled"
|
|
23
24
|
location="bottom start"
|
|
24
25
|
offset="4"
|
|
@@ -53,8 +54,21 @@
|
|
|
53
54
|
</template>
|
|
54
55
|
|
|
55
56
|
<div class="app-select__menu" role="listbox">
|
|
57
|
+
<div v-if="searchable" class="app-select__search">
|
|
58
|
+
<v-icon icon="mdi-magnify" size="16" />
|
|
59
|
+
<input
|
|
60
|
+
ref="singleSearchInput"
|
|
61
|
+
v-model="search"
|
|
62
|
+
type="text"
|
|
63
|
+
class="app-select__search-input"
|
|
64
|
+
:placeholder="searchPlaceholder"
|
|
65
|
+
aria-label="Search options"
|
|
66
|
+
@keydown.enter.prevent="selectFirstMatch"
|
|
67
|
+
@keydown.esc.stop="singleOpen = false"
|
|
68
|
+
>
|
|
69
|
+
</div>
|
|
56
70
|
<button
|
|
57
|
-
v-for="opt in
|
|
71
|
+
v-for="opt in visibleOptions"
|
|
58
72
|
:key="String(opt.value)"
|
|
59
73
|
type="button"
|
|
60
74
|
class="app-select__option"
|
|
@@ -66,6 +80,9 @@
|
|
|
66
80
|
<span class="app-select__option-text">{{ opt.title }}</span>
|
|
67
81
|
<v-icon v-if="isSingleOn(opt)" icon="mdi-check" size="17" />
|
|
68
82
|
</button>
|
|
83
|
+
<p v-if="searchable && !visibleOptions.length" class="app-select__empty">
|
|
84
|
+
{{ normalized.length ? "No matches" : "Nothing to choose from" }}
|
|
85
|
+
</p>
|
|
69
86
|
</div>
|
|
70
87
|
</v-menu>
|
|
71
88
|
|
|
@@ -122,8 +139,18 @@
|
|
|
122
139
|
</template>
|
|
123
140
|
|
|
124
141
|
<div class="app-select__menu">
|
|
142
|
+
<div v-if="searchable" class="app-select__search">
|
|
143
|
+
<v-icon icon="mdi-magnify" size="16" />
|
|
144
|
+
<input
|
|
145
|
+
v-model="search"
|
|
146
|
+
type="text"
|
|
147
|
+
class="app-select__search-input"
|
|
148
|
+
:placeholder="searchPlaceholder"
|
|
149
|
+
aria-label="Search options"
|
|
150
|
+
>
|
|
151
|
+
</div>
|
|
125
152
|
<button
|
|
126
|
-
v-for="opt in
|
|
153
|
+
v-for="opt in visibleOptions"
|
|
127
154
|
:key="String(opt.value)"
|
|
128
155
|
type="button"
|
|
129
156
|
class="app-select__option"
|
|
@@ -138,6 +165,9 @@
|
|
|
138
165
|
/>
|
|
139
166
|
<span class="app-select__option-text">{{ opt.title }}</span>
|
|
140
167
|
</button>
|
|
168
|
+
<p v-if="searchable && !visibleOptions.length" class="app-select__empty">
|
|
169
|
+
{{ normalized.length ? "No matches" : "Nothing to choose from" }}
|
|
170
|
+
</p>
|
|
141
171
|
</div>
|
|
142
172
|
</v-menu>
|
|
143
173
|
</template>
|
|
@@ -168,6 +198,13 @@ const props = defineProps({
|
|
|
168
198
|
returnObject: { type: Boolean, default: false },
|
|
169
199
|
clearable: { type: Boolean, default: false },
|
|
170
200
|
placeholder: { type: String, default: "" },
|
|
201
|
+
/**
|
|
202
|
+
* A filter box at the top of the popover. Opt-in, so the 44 consumers that
|
|
203
|
+
* do not ask for it render exactly the DOM they render today - a list short
|
|
204
|
+
* enough to read does not want a search field in front of it.
|
|
205
|
+
*/
|
|
206
|
+
searchable: { type: Boolean, default: false },
|
|
207
|
+
searchPlaceholder: { type: String, default: "Search" },
|
|
171
208
|
});
|
|
172
209
|
|
|
173
210
|
const normalized = computed(() =>
|
|
@@ -178,6 +215,38 @@ const normalized = computed(() =>
|
|
|
178
215
|
)
|
|
179
216
|
);
|
|
180
217
|
|
|
218
|
+
/* ---- search ---------------------------------------------------------- */
|
|
219
|
+
|
|
220
|
+
const search = ref("");
|
|
221
|
+
const singleOpen = ref(false);
|
|
222
|
+
const singleSearchInput = ref<HTMLInputElement | null>(null);
|
|
223
|
+
|
|
224
|
+
/* Case-insensitive substring over what the option READS AS, not its value:
|
|
225
|
+
the title is the only part the user can see to type. */
|
|
226
|
+
const visibleOptions = computed(() => {
|
|
227
|
+
const term = search.value.trim().toLowerCase();
|
|
228
|
+
if (!props.searchable || !term) return normalized.value;
|
|
229
|
+
return normalized.value.filter((opt) =>
|
|
230
|
+
String(opt.title ?? "").toLowerCase().includes(term)
|
|
231
|
+
);
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
/* A stale term would hide the list the next time the popover opens, so it is
|
|
235
|
+
dropped on every open - and the caret goes into the box, since opening a
|
|
236
|
+
searchable select is almost always a prelude to typing. */
|
|
237
|
+
watch(singleOpen, async (open) => {
|
|
238
|
+
if (!props.searchable) return;
|
|
239
|
+
search.value = "";
|
|
240
|
+
if (!open) return;
|
|
241
|
+
await nextTick();
|
|
242
|
+
singleSearchInput.value?.focus();
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
function selectFirstMatch() {
|
|
246
|
+
const [first] = visibleOptions.value;
|
|
247
|
+
if (first) selectSingle(first);
|
|
248
|
+
}
|
|
249
|
+
|
|
181
250
|
/* A model entry is either the plain value or - under `return-object` - the
|
|
182
251
|
source item, so everything compares on this one key. */
|
|
183
252
|
const keyOf = (v: any) =>
|
|
@@ -205,6 +274,11 @@ const isSingleOn = (opt: any) =>
|
|
|
205
274
|
function selectSingle(opt: any) {
|
|
206
275
|
if (props.disabled) return;
|
|
207
276
|
model.value = props.returnObject ? opt.raw : String(opt.value);
|
|
277
|
+
// `close-on-content-click` has to be OFF while searching - it fires on the
|
|
278
|
+
// click that puts the caret in the search box, so the popover would shut the
|
|
279
|
+
// moment it was typed into. With it off, picking an option has to close the
|
|
280
|
+
// popover by hand.
|
|
281
|
+
if (props.searchable) singleOpen.value = false;
|
|
208
282
|
}
|
|
209
283
|
|
|
210
284
|
function clearSingle() {
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<PageHeader
|
|
4
|
+
title="Client invitations"
|
|
5
|
+
subtitle="Other organisations asking your company to provide services at their sites."
|
|
6
|
+
/>
|
|
7
|
+
|
|
8
|
+
<AppCard class="table-card">
|
|
9
|
+
<CardToolbar>
|
|
10
|
+
<template #tabs>
|
|
11
|
+
<button
|
|
12
|
+
v-for="t in tabs"
|
|
13
|
+
:key="t.value"
|
|
14
|
+
type="button"
|
|
15
|
+
role="tab"
|
|
16
|
+
class="app-tab"
|
|
17
|
+
:class="{ 'app-tab--active': tab === t.value }"
|
|
18
|
+
:aria-selected="tab === t.value"
|
|
19
|
+
@click="tab = t.value"
|
|
20
|
+
>
|
|
21
|
+
{{ t.label }}<span v-if="counts[t.value]"> ({{ counts[t.value] }})</span>
|
|
22
|
+
</button>
|
|
23
|
+
</template>
|
|
24
|
+
</CardToolbar>
|
|
25
|
+
|
|
26
|
+
<div class="pa-4 d-flex flex-column ga-3">
|
|
27
|
+
<div v-if="loading" class="screen-hint">Loading…</div>
|
|
28
|
+
<div v-else-if="loadError" class="text-error" role="alert">{{ loadError }}</div>
|
|
29
|
+
<div v-else-if="!items.length" class="screen-hint">{{ emptyLine }}</div>
|
|
30
|
+
|
|
31
|
+
<AppCard
|
|
32
|
+
v-for="item in items"
|
|
33
|
+
:key="item._id"
|
|
34
|
+
class="client-invite"
|
|
35
|
+
:class="{ 'client-invite--linked': item._id === linked }"
|
|
36
|
+
>
|
|
37
|
+
<div class="d-flex align-start ga-3 pa-4">
|
|
38
|
+
<v-avatar color="primary" variant="tonal" size="44">
|
|
39
|
+
<v-icon>mdi-office-building-marker-outline</v-icon>
|
|
40
|
+
</v-avatar>
|
|
41
|
+
<div class="flex-grow-1">
|
|
42
|
+
<div class="screen-card-title">
|
|
43
|
+
{{ item.orgName }} has invited your company to {{ item.siteName }}
|
|
44
|
+
</div>
|
|
45
|
+
<div class="screen-hint client-invite__meta">
|
|
46
|
+
<span v-if="item.service">Services: {{ serviceLabel(item.service) }} · </span>
|
|
47
|
+
<span v-if="item.invitedByName">Invited by {{ item.invitedByName }} · </span>
|
|
48
|
+
<span>Sent {{ day(item.createdAt) }}</span>
|
|
49
|
+
</div>
|
|
50
|
+
</div>
|
|
51
|
+
<StatusChip :status="item.status" :label="item.statusLabel" />
|
|
52
|
+
</div>
|
|
53
|
+
|
|
54
|
+
<div class="px-4 pb-4 client-invite__body">
|
|
55
|
+
{{ stateLine(item) }}
|
|
56
|
+
</div>
|
|
57
|
+
|
|
58
|
+
<!-- Buttons only while the invitation is waiting for an answer. -->
|
|
59
|
+
<div v-if="item.status === 'pending'" class="d-flex align-center ga-2 px-4 pb-4">
|
|
60
|
+
<v-btn
|
|
61
|
+
variant="flat"
|
|
62
|
+
class="screen-btn-primary"
|
|
63
|
+
:loading="working[item._id] === 'accept'"
|
|
64
|
+
:disabled="Boolean(working[item._id])"
|
|
65
|
+
@click="answer(item, 'accept')"
|
|
66
|
+
>
|
|
67
|
+
Accept
|
|
68
|
+
</v-btn>
|
|
69
|
+
<v-btn
|
|
70
|
+
variant="outlined"
|
|
71
|
+
class="screen-btn-ghost"
|
|
72
|
+
:loading="working[item._id] === 'decline'"
|
|
73
|
+
:disabled="Boolean(working[item._id])"
|
|
74
|
+
@click="answer(item, 'decline')"
|
|
75
|
+
>
|
|
76
|
+
Decline
|
|
77
|
+
</v-btn>
|
|
78
|
+
</div>
|
|
79
|
+
|
|
80
|
+
<div v-else-if="item.status === 'complete'" class="px-4 pb-4">
|
|
81
|
+
<NuxtLink v-if="item.onThisOrg" :to="`/org/${org}/sites`">Open Sites</NuxtLink>
|
|
82
|
+
<NuxtLink
|
|
83
|
+
v-else-if="item.providerOrgId && item.providerOrgId !== org"
|
|
84
|
+
:to="`/org/${item.providerOrgId}/sites`"
|
|
85
|
+
>
|
|
86
|
+
Open {{ item.providerOrgName || "that company" }}'s Sites
|
|
87
|
+
</NuxtLink>
|
|
88
|
+
</div>
|
|
89
|
+
|
|
90
|
+
<div v-if="errors[item._id]" class="px-4 pb-4 text-error client-invite__body" role="alert">
|
|
91
|
+
{{ errors[item._id] }}
|
|
92
|
+
</div>
|
|
93
|
+
</AppCard>
|
|
94
|
+
</div>
|
|
95
|
+
</AppCard>
|
|
96
|
+
</div>
|
|
97
|
+
</template>
|
|
98
|
+
|
|
99
|
+
<script setup lang="ts">
|
|
100
|
+
/**
|
|
101
|
+
* "Client invitations" (owner request 2026-09-24): where a service-provider
|
|
102
|
+
* company answers invitations from its clients, in four tabs, with one plain
|
|
103
|
+
* sentence per card saying what happened. Accept / Decline appear only while
|
|
104
|
+
* an invitation is waiting - an answered one has no buttons at all.
|
|
105
|
+
*
|
|
106
|
+
* Accepting adds the site to the company ON SCREEN (`org`), which is what makes
|
|
107
|
+
* it appear on this company's Sites list and in the service app's site
|
|
108
|
+
* switcher. The server refuses a company the person is not a member of.
|
|
109
|
+
*/
|
|
110
|
+
import type { TReceivedServiceProviderInvitation } from "../composables/useServiceProviderInvitation";
|
|
111
|
+
|
|
112
|
+
const props = defineProps({
|
|
113
|
+
/** The organisation on screen - the company that accepts. */
|
|
114
|
+
org: { type: String, required: true },
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
type Tab = "pending" | "accepted" | "declined" | "expired";
|
|
118
|
+
|
|
119
|
+
const tabs: Array<{ value: Tab; label: string }> = [
|
|
120
|
+
{ value: "pending", label: "Pending" },
|
|
121
|
+
{ value: "accepted", label: "Accepted" },
|
|
122
|
+
{ value: "declined", label: "Declined" },
|
|
123
|
+
{ value: "expired", label: "Expired" },
|
|
124
|
+
];
|
|
125
|
+
|
|
126
|
+
const route = useRoute();
|
|
127
|
+
const { getReceivedInvitations, getInvitation, acceptInvitation, declineInvitation } =
|
|
128
|
+
useServiceProviderInvitation();
|
|
129
|
+
|
|
130
|
+
const tab = ref<Tab>("pending");
|
|
131
|
+
const items = ref<TReceivedServiceProviderInvitation[]>([]);
|
|
132
|
+
const counts = ref<Record<string, number>>({});
|
|
133
|
+
const loading = ref(false);
|
|
134
|
+
const loadError = ref("");
|
|
135
|
+
const working = reactive<Record<string, string>>({});
|
|
136
|
+
const errors = reactive<Record<string, string>>({});
|
|
137
|
+
|
|
138
|
+
/** The invitation the bell linked to (`?invite=<id>`), outlined. */
|
|
139
|
+
const linked = computed(() => {
|
|
140
|
+
const value = String(route.query?.invite ?? "").trim();
|
|
141
|
+
return /^[a-f0-9]{24}$/i.test(value) ? value : "";
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
const emptyLine = computed(
|
|
145
|
+
() =>
|
|
146
|
+
({
|
|
147
|
+
pending: "Nothing is waiting for your answer.",
|
|
148
|
+
accepted: "You have not accepted any invitations yet.",
|
|
149
|
+
declined: "You have not declined any invitations.",
|
|
150
|
+
expired: "No expired or withdrawn invitations.",
|
|
151
|
+
})[tab.value],
|
|
152
|
+
);
|
|
153
|
+
|
|
154
|
+
function day(value?: string | null) {
|
|
155
|
+
if (!value) return "";
|
|
156
|
+
const d = new Date(value);
|
|
157
|
+
return Number.isNaN(d.getTime())
|
|
158
|
+
? ""
|
|
159
|
+
: d.toLocaleDateString("en-GB", { day: "numeric", month: "short", year: "numeric" });
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/** " on 24 Sep 2026", or nothing when the date is unknown. */
|
|
163
|
+
function on(value?: string | null) {
|
|
164
|
+
const text = day(value);
|
|
165
|
+
return text ? ` on ${text}` : "";
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
function serviceLabel(value: string) {
|
|
169
|
+
return value.replace(/[-_]/g, " ").replace(/^\w/, (c) => c.toUpperCase());
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/** One sentence: where the invitation stands and what, if anything, to do. */
|
|
173
|
+
function stateLine(item: TReceivedServiceProviderInvitation) {
|
|
174
|
+
switch (item.status) {
|
|
175
|
+
case "pending":
|
|
176
|
+
return `Waiting for you. Accepting adds ${item.siteName} to this company's Sites list${
|
|
177
|
+
item.expireAt ? ` — please answer by ${day(item.expireAt)}` : ""
|
|
178
|
+
}.`;
|
|
179
|
+
case "complete":
|
|
180
|
+
if (item.onThisOrg) {
|
|
181
|
+
return `Accepted${on(item.answeredAt)} — ${item.siteName} is on your Sites list as a site you serve for ${item.orgName}.`;
|
|
182
|
+
}
|
|
183
|
+
if (!item.providerOrgId || item.providerOrgId === props.org) {
|
|
184
|
+
return `Accepted${on(item.answeredAt)}, but ${item.siteName} is not on this company's Sites list. Please contact Seven365 support so we can add it.`;
|
|
185
|
+
}
|
|
186
|
+
return `Accepted${on(item.answeredAt)} for ${
|
|
187
|
+
item.providerOrgName || "another of your companies"
|
|
188
|
+
} — the site is on that company's Sites list, not this one's.`;
|
|
189
|
+
case "declined":
|
|
190
|
+
return `Declined${on(item.answeredAt)}. ${item.orgName} has been told.`;
|
|
191
|
+
case "cancelled":
|
|
192
|
+
return `${item.orgName} withdrew this invitation${on(item.answeredAt)}.`;
|
|
193
|
+
default:
|
|
194
|
+
return `This invitation expired${on(item.expireAt)} without an answer. Ask ${item.orgName} to send a new one if you still want this site.`;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
async function load() {
|
|
199
|
+
loading.value = true;
|
|
200
|
+
loadError.value = "";
|
|
201
|
+
try {
|
|
202
|
+
const res = await getReceivedInvitations({ org: props.org, status: tab.value });
|
|
203
|
+
items.value = Array.isArray(res?.items) ? res.items : [];
|
|
204
|
+
counts.value = res?.counts ?? {};
|
|
205
|
+
} catch (err: any) {
|
|
206
|
+
items.value = [];
|
|
207
|
+
loadError.value = err?.data?.message || "Could not load your client invitations. Please try again.";
|
|
208
|
+
} finally {
|
|
209
|
+
loading.value = false;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
async function answer(item: TReceivedServiceProviderInvitation, action: "accept" | "decline") {
|
|
214
|
+
errors[item._id] = "";
|
|
215
|
+
working[item._id] = action;
|
|
216
|
+
try {
|
|
217
|
+
if (action === "accept") await acceptInvitation(item._id, props.org);
|
|
218
|
+
else await declineInvitation(item._id);
|
|
219
|
+
// Follow the invitation to the tab it now belongs to (the tab watcher
|
|
220
|
+
// reloads the list).
|
|
221
|
+
tab.value = action === "accept" ? "accepted" : "declined";
|
|
222
|
+
} catch (err: any) {
|
|
223
|
+
errors[item._id] =
|
|
224
|
+
err?.data?.message ||
|
|
225
|
+
(action === "accept" ? "Could not accept this invitation." : "Could not decline this invitation.");
|
|
226
|
+
} finally {
|
|
227
|
+
working[item._id] = "";
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
// Opened from the bell: start on the tab the linked invitation is in.
|
|
232
|
+
if (linked.value) {
|
|
233
|
+
try {
|
|
234
|
+
const one: any = await getInvitation(linked.value, props.org);
|
|
235
|
+
if (one?.tab && tabs.some((t) => t.value === one.tab)) tab.value = one.tab;
|
|
236
|
+
} catch {
|
|
237
|
+
// Not ours or gone: the page still lists the rest.
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
await load();
|
|
241
|
+
watch(tab, load);
|
|
242
|
+
</script>
|
|
243
|
+
|
|
244
|
+
<style scoped>
|
|
245
|
+
.client-invite--linked {
|
|
246
|
+
outline: 2px solid rgb(var(--v-theme-primary));
|
|
247
|
+
outline-offset: 2px;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
.client-invite :deep(.screen-card-title) {
|
|
251
|
+
display: block;
|
|
252
|
+
line-height: 1.35;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
.client-invite__meta,
|
|
256
|
+
.client-invite__body {
|
|
257
|
+
font-size: var(--fs-cell);
|
|
258
|
+
}
|
|
259
|
+
</style>
|
|
@@ -860,11 +860,36 @@ function getAccessMethod(identity: HidAccessRecord, log?: HidAccessRecord) {
|
|
|
860
860
|
return identity.metadata?.facialData || identity.metadata?.imageTimestamp ? "Facial" : "N/A";
|
|
861
861
|
}
|
|
862
862
|
|
|
863
|
+
/**
|
|
864
|
+
* One shape for the whole Access Date and Time column: `15:18:43 23/9/2026`.
|
|
865
|
+
*
|
|
866
|
+
* Reader rows arrive as a number and went through `formatHidEpochDate`; an
|
|
867
|
+
* intercom door open never touches the reader, so the API writes it as an ISO
|
|
868
|
+
* string and this branch took `toLocaleString` instead - which put
|
|
869
|
+
* "9/23/2026, 2:15:29 PM" in the same column, one row below "15:18:43
|
|
870
|
+
* 23/9/2026". Both branches now build the same string.
|
|
871
|
+
*
|
|
872
|
+
* Local parts here, UTC parts there, on purpose: the reader encodes its own
|
|
873
|
+
* wall clock as if it were UTC, while an ISO string is a real instant. Reading
|
|
874
|
+
* each the way it was written is what makes both columns show the time that was
|
|
875
|
+
* on the clock at the door.
|
|
876
|
+
*/
|
|
863
877
|
function formatDate(value?: string | number) {
|
|
864
878
|
if (!value) return "N/A";
|
|
865
879
|
if (typeof value === "number") return formatHidEpochDate(value);
|
|
866
|
-
const date =
|
|
867
|
-
|
|
880
|
+
const date = new Date(value);
|
|
881
|
+
if (Number.isNaN(date.getTime())) return "N/A";
|
|
882
|
+
return formatClock(
|
|
883
|
+
[date.getHours(), date.getMinutes(), date.getSeconds()],
|
|
884
|
+
date.getDate(),
|
|
885
|
+
date.getMonth() + 1,
|
|
886
|
+
date.getFullYear(),
|
|
887
|
+
);
|
|
888
|
+
}
|
|
889
|
+
|
|
890
|
+
function formatClock(time: number[], day: number, month: number, year: number) {
|
|
891
|
+
const clock = time.map((part) => String(part).padStart(2, "0")).join(":");
|
|
892
|
+
return `${clock} ${day}/${month}/${year}`;
|
|
868
893
|
}
|
|
869
894
|
|
|
870
895
|
function parseDate(value?: string | number) {
|
|
@@ -894,13 +919,12 @@ function formatHidEpochDate(value: number) {
|
|
|
894
919
|
const date = new Date(value * 1000);
|
|
895
920
|
if (Number.isNaN(date.getTime())) return "N/A";
|
|
896
921
|
|
|
897
|
-
|
|
898
|
-
date.getUTCHours(),
|
|
899
|
-
date.
|
|
900
|
-
date.
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
return `${time} ${date.getUTCDate()}/${date.getUTCMonth() + 1}/${date.getUTCFullYear()}`;
|
|
922
|
+
return formatClock(
|
|
923
|
+
[date.getUTCHours(), date.getUTCMinutes(), date.getUTCSeconds()],
|
|
924
|
+
date.getUTCDate(),
|
|
925
|
+
date.getUTCMonth() + 1,
|
|
926
|
+
date.getUTCFullYear(),
|
|
927
|
+
);
|
|
904
928
|
}
|
|
905
929
|
|
|
906
930
|
function openHistoryDialog(row: AccessRow) {
|
|
@@ -591,11 +591,16 @@
|
|
|
591
591
|
extension. The model stays the plain name string the reader stores,
|
|
592
592
|
so `saveContact` is unchanged; an existing contact whose name is not
|
|
593
593
|
in the list still displays it (AppSelect falls back to the raw value). -->
|
|
594
|
+
<!-- Searchable: this is the one list on the screen that grows with
|
|
595
|
+
the estate, and the unit is part of every option's text, so the
|
|
596
|
+
box finds a person by name or by where they live. -->
|
|
594
597
|
<AppSelect
|
|
595
598
|
v-model="contactForm.name"
|
|
596
599
|
:items="sipAccountOptions"
|
|
597
600
|
:disabled="sipAccountsLoading"
|
|
598
601
|
:placeholder="sipAccountsLoading ? 'Loading SIP accounts…' : 'Name shown on calls'"
|
|
602
|
+
searchable
|
|
603
|
+
search-placeholder="Search name or unit"
|
|
599
604
|
class="my-3"
|
|
600
605
|
@update:model-value="applySipAccountToContact"
|
|
601
606
|
/>
|
|
@@ -893,8 +898,22 @@ const readerOptions = computed(() => readers.value.map((reader) => ({
|
|
|
893
898
|
})));
|
|
894
899
|
|
|
895
900
|
/**
|
|
896
|
-
*
|
|
897
|
-
*
|
|
901
|
+
* "Harris - Blk 1/Level 1/Unit 1" - the name a contact is stored under.
|
|
902
|
+
*
|
|
903
|
+
* The unit belongs in the name itself, not only in the picker's label: the
|
|
904
|
+
* reader's contact list is what a visitor reads off the door panel, and
|
|
905
|
+
* "Harris" alone does not say which home it rings. An account whose owner has
|
|
906
|
+
* no address, and every account until the API ships the `unitLabel` field,
|
|
907
|
+
* falls back to the bare name rather than trailing a separator.
|
|
908
|
+
*/
|
|
909
|
+
function buildContactName(account: HidSipAccountListItem) {
|
|
910
|
+
const unit = String(account.unitLabel ?? "").trim();
|
|
911
|
+
return unit ? `${account.name} - ${unit}` : account.name;
|
|
912
|
+
}
|
|
913
|
+
|
|
914
|
+
/**
|
|
915
|
+
* The contact name picker. `value` is the composed name because that is what
|
|
916
|
+
* the reader stores and what `saveContact` sends; the extension goes into the
|
|
898
917
|
* Address field, not the label. A name that already sits on the contact being
|
|
899
918
|
* edited but is no longer in the SIP list is kept as an option so the picker
|
|
900
919
|
* does not silently drop it.
|
|
@@ -902,7 +921,10 @@ const readerOptions = computed(() => readers.value.map((reader) => ({
|
|
|
902
921
|
const sipAccountOptions = computed(() => {
|
|
903
922
|
const options: Array<{ title: string; value: string }> = sipAccounts.value
|
|
904
923
|
.filter((account: HidSipAccountListItem) => account.name)
|
|
905
|
-
.map((account: HidSipAccountListItem) =>
|
|
924
|
+
.map((account: HidSipAccountListItem) => {
|
|
925
|
+
const name = buildContactName(account);
|
|
926
|
+
return { title: name, value: name };
|
|
927
|
+
});
|
|
906
928
|
const current = contactForm.name.trim();
|
|
907
929
|
if (current && !options.some((option) => option.value === current)) {
|
|
908
930
|
options.unshift({ title: current, value: current });
|
|
@@ -910,12 +932,22 @@ const sipAccountOptions = computed(() => {
|
|
|
910
932
|
return options;
|
|
911
933
|
});
|
|
912
934
|
|
|
913
|
-
/**
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
935
|
+
/**
|
|
936
|
+
* The SIP account behind a stored contact name, or null when the name is not
|
|
937
|
+
* one. The bare name is matched as well as the composed one, so a contact
|
|
938
|
+
* created before the unit was part of the name still resolves to its account
|
|
939
|
+
* on edit instead of looking unrecognised.
|
|
940
|
+
*/
|
|
941
|
+
function findSipAccount(name: string) {
|
|
942
|
+
const value = name.trim();
|
|
943
|
+
if (!value) return null;
|
|
944
|
+
const match = sipAccounts.value.find((account: HidSipAccountListItem) => buildContactName(account) === value)
|
|
945
|
+
?? sipAccounts.value.find((account: HidSipAccountListItem) => account.name === value);
|
|
917
946
|
return (match ?? null) as HidSipAccountListItem | null;
|
|
918
|
-
}
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
/** The SIP account behind the picked name, or null for a legacy / unpicked name. */
|
|
950
|
+
const selectedSipAccount = computed(() => findSipAccount(contactForm.name));
|
|
919
951
|
|
|
920
952
|
const visibleRows = computed(() => activeTab.value === "intercom" ? filteredIntercomRows.value : filteredContacts.value);
|
|
921
953
|
const pages = computed(() => Math.max(1, Math.ceil(visibleRows.value.length / limit)));
|
|
@@ -1475,7 +1507,7 @@ async function loadSipAccounts() {
|
|
|
1475
1507
|
* not an account (a legacy contact) leaves whatever address it already had.
|
|
1476
1508
|
*/
|
|
1477
1509
|
function applySipAccountToContact(name: string) {
|
|
1478
|
-
const account =
|
|
1510
|
+
const account = findSipAccount(name);
|
|
1479
1511
|
if (!account) return;
|
|
1480
1512
|
contactForm.serverAddress = account.extension;
|
|
1481
1513
|
}
|
|
@@ -827,7 +827,10 @@ const listTab = ref<ListTab>("active");
|
|
|
827
827
|
/** The same three tabs, in the same order, with the same labels. */
|
|
828
828
|
const listTabs: Array<{ value: ListTab; label: string }> = [
|
|
829
829
|
{ value: "active", label: "Service Providers" },
|
|
830
|
-
|
|
830
|
+
// Every invitation this site sent, whatever became of it - including the
|
|
831
|
+
// accepted ones, so the client can see "Accepted" and not just a row that
|
|
832
|
+
// vanished (owner request 2026-09-24).
|
|
833
|
+
{ value: "pending", label: "Invitations" },
|
|
831
834
|
{ value: "inactive", label: "In-Active" },
|
|
832
835
|
];
|
|
833
836
|
const page = ref(1);
|
|
@@ -1292,7 +1295,7 @@ async function loadList() {
|
|
|
1292
1295
|
const data = await getInvitations({
|
|
1293
1296
|
org: props.orgId,
|
|
1294
1297
|
status:
|
|
1295
|
-
"awaiting-approval,pending,rejected,declined,cancelled,expired",
|
|
1298
|
+
"awaiting-approval,pending,complete,rejected,declined,cancelled,expired",
|
|
1296
1299
|
page: page.value,
|
|
1297
1300
|
search: searchText.value?.trim() || "",
|
|
1298
1301
|
limit: pageSize,
|
|
@@ -161,6 +161,16 @@ export type HidSipAccountListItem = {
|
|
|
161
161
|
userId: string;
|
|
162
162
|
name: string;
|
|
163
163
|
email: string;
|
|
164
|
+
/**
|
|
165
|
+
* What the owner is called after their name on the contact list: their
|
|
166
|
+
* "Blk 1/Level 1/Unit 1" when they live here, and their membership type -
|
|
167
|
+
* "Security Agency" - when they do not. "" only when the site knows neither.
|
|
168
|
+
*
|
|
169
|
+
* Optional because an API still on the `@7365admin1/core` release that
|
|
170
|
+
* predates it answers without the field; the contact picker falls back to the
|
|
171
|
+
* bare name rather than showing a dangling separator.
|
|
172
|
+
*/
|
|
173
|
+
unitLabel?: string;
|
|
164
174
|
extension: string;
|
|
165
175
|
username: string;
|
|
166
176
|
status: string;
|
|
@@ -26,17 +26,28 @@ export type TServiceProviderInvitation = {
|
|
|
26
26
|
}>;
|
|
27
27
|
};
|
|
28
28
|
|
|
29
|
-
/** One
|
|
29
|
+
/** One card of "Client invitations" (the service provider's side). */
|
|
30
30
|
export type TReceivedServiceProviderInvitation = {
|
|
31
31
|
_id: string;
|
|
32
|
+
/** The client organisation that sent it. */
|
|
32
33
|
orgName: string;
|
|
33
34
|
siteName: string;
|
|
35
|
+
siteId?: string;
|
|
36
|
+
/** The service asked for, when the sender recorded one (e.g. "security"). */
|
|
37
|
+
service?: string;
|
|
38
|
+
invitedByName?: string;
|
|
39
|
+
createdAt?: string;
|
|
40
|
+
expireAt?: string;
|
|
41
|
+
/** When it was accepted, declined or withdrawn. */
|
|
42
|
+
answeredAt?: string | null;
|
|
43
|
+
/** pending | complete | declined | expired | cancelled */
|
|
34
44
|
status: string;
|
|
35
45
|
statusLabel: string;
|
|
36
|
-
|
|
37
|
-
/** The invited company's own organisation (the one whose list gains the site). */
|
|
46
|
+
/** The company that accepted it (whose Sites list gained the site). */
|
|
38
47
|
providerOrgId?: string;
|
|
39
48
|
providerOrgName?: string;
|
|
49
|
+
/** Accepted AND on the Sites list of the company on screen. */
|
|
50
|
+
onThisOrg?: boolean;
|
|
40
51
|
};
|
|
41
52
|
|
|
42
53
|
/** The words on screen. Kept beside the server's own list on purpose — a
|
|
@@ -133,8 +144,14 @@ export default function useServiceProviderInvitation() {
|
|
|
133
144
|
|
|
134
145
|
// ---- the invited service provider ----------------------------------------
|
|
135
146
|
|
|
136
|
-
function getInvitation(
|
|
137
|
-
|
|
147
|
+
function getInvitation(
|
|
148
|
+
id: string,
|
|
149
|
+
org?: string,
|
|
150
|
+
): Promise<TReceivedServiceProviderInvitation & { tab?: string | null }> {
|
|
151
|
+
return useNuxtApp().$api(`${base}/${id}`, {
|
|
152
|
+
method: "GET",
|
|
153
|
+
query: org ? { org } : {},
|
|
154
|
+
});
|
|
138
155
|
}
|
|
139
156
|
|
|
140
157
|
function declineInvitation(id: string) {
|
|
@@ -143,21 +160,32 @@ export default function useServiceProviderInvitation() {
|
|
|
143
160
|
});
|
|
144
161
|
}
|
|
145
162
|
|
|
146
|
-
/**
|
|
147
|
-
|
|
163
|
+
/**
|
|
164
|
+
* Adds the site to `org`'s Sites list - the company on screen, which the
|
|
165
|
+
* server checks the invited account belongs to.
|
|
166
|
+
*/
|
|
167
|
+
function acceptInvitation(id: string, org?: string) {
|
|
148
168
|
return useNuxtApp().$api<{ message: string }>(`${base}/${id}/accept`, {
|
|
149
169
|
method: "PUT",
|
|
170
|
+
body: org ? { org } : {},
|
|
150
171
|
});
|
|
151
172
|
}
|
|
152
173
|
|
|
153
174
|
/**
|
|
154
|
-
*
|
|
155
|
-
* account
|
|
175
|
+
* "Client invitations": one tab of the invitations sent to the signed-in
|
|
176
|
+
* account, plus the count in every tab. `org` is the company on screen.
|
|
156
177
|
*/
|
|
157
|
-
function getReceivedInvitations(
|
|
178
|
+
function getReceivedInvitations({
|
|
179
|
+
org,
|
|
180
|
+
status = "pending",
|
|
181
|
+
}: { org?: string; status?: string } = {}): Promise<{
|
|
158
182
|
items: TReceivedServiceProviderInvitation[];
|
|
183
|
+
counts?: Record<string, number>;
|
|
159
184
|
}> {
|
|
160
|
-
return useNuxtApp().$api(`${base}/received`, {
|
|
185
|
+
return useNuxtApp().$api(`${base}/received`, {
|
|
186
|
+
method: "GET",
|
|
187
|
+
query: { status, ...(org ? { org } : {}) },
|
|
188
|
+
});
|
|
161
189
|
}
|
|
162
190
|
|
|
163
191
|
return {
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@7365admin1/layer-common",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "4.35.1-staging.
|
|
5
|
+
"version": "4.35.1-staging.376",
|
|
6
6
|
"author": "7365admin1",
|
|
7
7
|
"main": "./nuxt.config.ts",
|
|
8
8
|
"//files": "What a consumer extending this layer actually loads. Without this npm ships the whole working tree - the changesets, the CI workflows, the render harness in tools/ and any scratch directory that happened to exist at publish time. Nuxt resolves a layer by directory, so every runtime directory below has to stay listed; adding a new top-level runtime directory means adding it here too.",
|
|
@@ -71,7 +71,7 @@ export const VENDOR_ORDER_MODULE = "marketplace-vendor-order";
|
|
|
71
71
|
* app has that page; every other app sends the click there by URL.
|
|
72
72
|
*/
|
|
73
73
|
export const SP_INVITATION_SCREEN = "/service-provider-invitation";
|
|
74
|
-
export const INVITATIONS_ROUTE = "org-organization-invitations
|
|
74
|
+
export const INVITATIONS_ROUTE = "org-organization-client-invitations";
|
|
75
75
|
|
|
76
76
|
export function notificationTarget(
|
|
77
77
|
item: TTargetRow | null | undefined,
|
|
@@ -89,10 +89,10 @@ export function notificationTarget(
|
|
|
89
89
|
const query: Record<string, string> = id ? { invite: id } : {};
|
|
90
90
|
return {
|
|
91
91
|
name: INVITATIONS_ROUTE,
|
|
92
|
-
params: { organization: org
|
|
92
|
+
params: { organization: org },
|
|
93
93
|
query,
|
|
94
94
|
app: "org",
|
|
95
|
-
path: `/org/${encodeURIComponent(org)}/invitations
|
|
95
|
+
path: `/org/${encodeURIComponent(org)}/client-invitations`,
|
|
96
96
|
};
|
|
97
97
|
}
|
|
98
98
|
|
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<!-- `AppCard` is the design's card - 14px radius, a 1px `--border` rule and
|
|
3
|
-
the one-pixel shadow on `--card`. The `v-card rounded="lg"
|
|
4
|
-
variant="outlined"` it replaced was Vuetify's own card at its own
|
|
5
|
-
radius and border weight. -->
|
|
6
|
-
<AppCard v-if="invitation" class="sp-invite-prompt">
|
|
7
|
-
<div class="d-flex align-start ga-3 pa-4">
|
|
8
|
-
<v-avatar color="primary" variant="tonal" size="44">
|
|
9
|
-
<v-icon>mdi-office-building-marker-outline</v-icon>
|
|
10
|
-
</v-avatar>
|
|
11
|
-
<div class="flex-grow-1">
|
|
12
|
-
<div class="screen-card-title">
|
|
13
|
-
{{ invitation.orgName }} has invited you to {{ invitation.siteName }}
|
|
14
|
-
</div>
|
|
15
|
-
<div class="screen-hint sp-invite-prompt__sub">
|
|
16
|
-
Approved by Seven365 · {{ expiryLine }}
|
|
17
|
-
</div>
|
|
18
|
-
</div>
|
|
19
|
-
</div>
|
|
20
|
-
|
|
21
|
-
<div class="px-4 sp-invite-prompt__body">
|
|
22
|
-
{{ invitation.orgName }} would like your company to provide services at
|
|
23
|
-
<strong>{{ invitation.siteName }}</strong
|
|
24
|
-
>. If you accept, this site will be added to your list of sites.
|
|
25
|
-
</div>
|
|
26
|
-
|
|
27
|
-
<div class="d-flex align-center ga-2 px-4 py-4">
|
|
28
|
-
<!-- Both stay `v-btn`s: `loading` is the only signal that an accept or a
|
|
29
|
-
decline is in flight, and `AppButton` has no equivalent. They take
|
|
30
|
-
the design's two button classes instead. -->
|
|
31
|
-
<v-btn
|
|
32
|
-
variant="flat"
|
|
33
|
-
class="screen-btn-primary"
|
|
34
|
-
:loading="working === 'accept'"
|
|
35
|
-
:disabled="Boolean(working) || !open"
|
|
36
|
-
@click="accept"
|
|
37
|
-
>
|
|
38
|
-
Accept
|
|
39
|
-
</v-btn>
|
|
40
|
-
<v-btn
|
|
41
|
-
variant="outlined"
|
|
42
|
-
class="screen-btn-ghost"
|
|
43
|
-
:loading="working === 'decline'"
|
|
44
|
-
:disabled="Boolean(working) || !open"
|
|
45
|
-
@click="decline"
|
|
46
|
-
>
|
|
47
|
-
Decline
|
|
48
|
-
</v-btn>
|
|
49
|
-
<v-spacer />
|
|
50
|
-
<!-- Was a raw `v-chip` on Vuetify's fixed `success` green, or no colour
|
|
51
|
-
at all for every other outcome. `StatusChip` maps the status WORD
|
|
52
|
-
through the shared `utils/status.ts` tones, so "complete" and
|
|
53
|
-
"declined" come out the same colours they do everywhere else. -->
|
|
54
|
-
<StatusChip
|
|
55
|
-
v-if="!open"
|
|
56
|
-
:status="invitation.status"
|
|
57
|
-
:label="invitation.statusLabel"
|
|
58
|
-
/>
|
|
59
|
-
</div>
|
|
60
|
-
|
|
61
|
-
<!-- An accept or decline that failed: said on the card, not swallowed. -->
|
|
62
|
-
<div v-if="error" class="px-4 pb-4 text-error sp-invite-prompt__body" role="alert">
|
|
63
|
-
{{ error }}
|
|
64
|
-
</div>
|
|
65
|
-
</AppCard>
|
|
66
|
-
|
|
67
|
-
<AppCard v-else-if="error">
|
|
68
|
-
<div class="pa-4 sp-invite-prompt__body">{{ error }}</div>
|
|
69
|
-
</AppCard>
|
|
70
|
-
</template>
|
|
71
|
-
|
|
72
|
-
<script setup lang="ts">
|
|
73
|
-
/**
|
|
74
|
-
* The invitation as the service provider sees it — inside the app they already
|
|
75
|
-
* use, from the session they already have.
|
|
76
|
-
*
|
|
77
|
-
* There is deliberately no sign-up and no one-time code anywhere on this
|
|
78
|
-
* screen: a company that already exists on iService365 never creates a second
|
|
79
|
-
* account. The email they receive only carries them here.
|
|
80
|
-
*
|
|
81
|
-
* An invitation that has not been approved by Seven365 is not readable at all —
|
|
82
|
-
* the server answers "not found" — so this component cannot show one.
|
|
83
|
-
*/
|
|
84
|
-
const props = defineProps({
|
|
85
|
-
invitationId: { type: String, required: true },
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
const emit = defineEmits<{ (e: "answered", status: string): void }>();
|
|
89
|
-
|
|
90
|
-
const { getInvitation, declineInvitation, acceptInvitation } =
|
|
91
|
-
useServiceProviderInvitation();
|
|
92
|
-
|
|
93
|
-
const invitation = ref<any>(null);
|
|
94
|
-
const error = ref("");
|
|
95
|
-
const working = ref("");
|
|
96
|
-
|
|
97
|
-
const open = computed(() => invitation.value?.status === "pending");
|
|
98
|
-
|
|
99
|
-
const expiryLine = computed(() => {
|
|
100
|
-
const expires = invitation.value?.expireAt;
|
|
101
|
-
if (!expires) return "";
|
|
102
|
-
const days = Math.max(
|
|
103
|
-
0,
|
|
104
|
-
Math.ceil((new Date(expires).getTime() - Date.now()) / 86400000),
|
|
105
|
-
);
|
|
106
|
-
if (!open.value) return "no longer waiting for an answer";
|
|
107
|
-
return days <= 1 ? "expires within a day" : `expires in ${days} days`;
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
async function load() {
|
|
111
|
-
try {
|
|
112
|
-
invitation.value = await getInvitation(props.invitationId);
|
|
113
|
-
} catch (err: any) {
|
|
114
|
-
error.value =
|
|
115
|
-
err?.data?.message || "This invitation is no longer available.";
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
async function accept() {
|
|
120
|
-
error.value = "";
|
|
121
|
-
working.value = "accept";
|
|
122
|
-
try {
|
|
123
|
-
await acceptInvitation(props.invitationId);
|
|
124
|
-
await load();
|
|
125
|
-
emit("answered", "complete");
|
|
126
|
-
} catch (err: any) {
|
|
127
|
-
error.value = err?.data?.message || "Could not accept this invitation.";
|
|
128
|
-
} finally {
|
|
129
|
-
working.value = "";
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
async function decline() {
|
|
134
|
-
error.value = "";
|
|
135
|
-
working.value = "decline";
|
|
136
|
-
try {
|
|
137
|
-
await declineInvitation(props.invitationId);
|
|
138
|
-
await load();
|
|
139
|
-
emit("answered", "declined");
|
|
140
|
-
} catch (err: any) {
|
|
141
|
-
error.value = err?.data?.message || "Could not decline this invitation.";
|
|
142
|
-
} finally {
|
|
143
|
-
working.value = "";
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
await load();
|
|
148
|
-
</script>
|
|
149
|
-
|
|
150
|
-
<style scoped>
|
|
151
|
-
/* The title was a hand-set 1.05rem/600; `.screen-card-title` is the design's
|
|
152
|
-
15.5px/800, so only the wrap and the leading are left here. */
|
|
153
|
-
.sp-invite-prompt :deep(.screen-card-title) {
|
|
154
|
-
display: block;
|
|
155
|
-
line-height: 1.35;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
.sp-invite-prompt__sub,
|
|
159
|
-
.sp-invite-prompt__body {
|
|
160
|
-
font-size: var(--fs-cell);
|
|
161
|
-
}
|
|
162
|
-
</style>
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<!-- Nothing to answer and nothing linked: the section stays out of the way. -->
|
|
3
|
-
<section v-if="ids.length" class="sp-received mb-4" aria-labelledby="sp-received-title">
|
|
4
|
-
<div class="mb-2">
|
|
5
|
-
<div id="sp-received-title" class="screen-card-title">
|
|
6
|
-
Invitations from other organisations
|
|
7
|
-
</div>
|
|
8
|
-
<div class="screen-hint">
|
|
9
|
-
Another organisation has asked your company to provide services at one
|
|
10
|
-
of its sites. Accept to add the site to your Sites list, or decline.
|
|
11
|
-
</div>
|
|
12
|
-
</div>
|
|
13
|
-
|
|
14
|
-
<div class="d-flex flex-column ga-3">
|
|
15
|
-
<div
|
|
16
|
-
v-for="id in ids"
|
|
17
|
-
:key="id"
|
|
18
|
-
:class="{ 'sp-received__linked': id === linked }"
|
|
19
|
-
>
|
|
20
|
-
<Suspense>
|
|
21
|
-
<ServiceProviderInvitationPrompt
|
|
22
|
-
:invitation-id="id"
|
|
23
|
-
@answered="(status: string) => onAnswered(id, status)"
|
|
24
|
-
/>
|
|
25
|
-
</Suspense>
|
|
26
|
-
|
|
27
|
-
<div v-if="answered[id] === 'complete'" class="sp-received__done mt-2">
|
|
28
|
-
{{ doneLine(id) }}
|
|
29
|
-
<NuxtLink v-if="sitesLink(id)" :to="sitesLink(id)">Open Sites</NuxtLink>
|
|
30
|
-
</div>
|
|
31
|
-
</div>
|
|
32
|
-
</div>
|
|
33
|
-
</section>
|
|
34
|
-
</template>
|
|
35
|
-
|
|
36
|
-
<script setup lang="ts">
|
|
37
|
-
/**
|
|
38
|
-
* "Invitations from other organisations" — where a service provider answers an
|
|
39
|
-
* invitation another organisation sent it (owner report 2026-09-24: the bell
|
|
40
|
-
* said "Open the invitation to accept or decline" and there was nowhere to do
|
|
41
|
-
* either).
|
|
42
|
-
*
|
|
43
|
-
* The list comes from the server keyed on the signed-in account, so it is the
|
|
44
|
-
* same whichever organisation is on screen. The row the bell linked to
|
|
45
|
-
* (`?invite=<id>`) is always shown — even once answered or expired, so the
|
|
46
|
-
* person sees what happened to it — and is outlined.
|
|
47
|
-
*/
|
|
48
|
-
import type { TReceivedServiceProviderInvitation } from "../composables/useServiceProviderInvitation";
|
|
49
|
-
|
|
50
|
-
const route = useRoute();
|
|
51
|
-
const { getReceivedInvitations } = useServiceProviderInvitation();
|
|
52
|
-
|
|
53
|
-
const items = ref<TReceivedServiceProviderInvitation[]>([]);
|
|
54
|
-
const answered = reactive<Record<string, string>>({});
|
|
55
|
-
|
|
56
|
-
const linked = computed(() => {
|
|
57
|
-
const value = String(route.query?.invite ?? "").trim();
|
|
58
|
-
return /^[a-f0-9]{24}$/i.test(value) ? value : "";
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
const ids = computed(() => {
|
|
62
|
-
const listed = items.value.map((i) => String(i._id));
|
|
63
|
-
return linked.value && !listed.includes(linked.value)
|
|
64
|
-
? [linked.value, ...listed]
|
|
65
|
-
: listed;
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
function itemFor(id: string) {
|
|
69
|
-
return items.value.find((i) => String(i._id) === id);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function doneLine(id: string) {
|
|
73
|
-
const item = itemFor(id);
|
|
74
|
-
const whose = item?.providerOrgName ? `${item.providerOrgName}'s` : "your";
|
|
75
|
-
return item?.siteName
|
|
76
|
-
? `${item.siteName} is now on ${whose} Sites list.`
|
|
77
|
-
: `The site is now on ${whose} Sites list.`;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
function sitesLink(id: string) {
|
|
81
|
-
const org = itemFor(id)?.providerOrgId || String(route.params?.organization ?? "");
|
|
82
|
-
return org ? `/org/${org}/sites` : "";
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
function onAnswered(id: string, status: string) {
|
|
86
|
-
answered[id] = status;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
async function load() {
|
|
90
|
-
try {
|
|
91
|
-
const res = await getReceivedInvitations();
|
|
92
|
-
items.value = Array.isArray(res?.items) ? res.items : [];
|
|
93
|
-
} catch {
|
|
94
|
-
// The section is an addition to the Invitations page; if it cannot load,
|
|
95
|
-
// the rest of the page must still work. A linked row still renders and
|
|
96
|
-
// reports its own error.
|
|
97
|
-
items.value = [];
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
await load();
|
|
102
|
-
</script>
|
|
103
|
-
|
|
104
|
-
<style scoped>
|
|
105
|
-
.sp-received__linked :deep(.app-card) {
|
|
106
|
-
outline: 2px solid rgb(var(--v-theme-primary));
|
|
107
|
-
outline-offset: 2px;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
.sp-received__done {
|
|
111
|
-
font-size: var(--fs-cell);
|
|
112
|
-
}
|
|
113
|
-
</style>
|