@feedmepos/mf-hrm-portal 2.1.1-dev.2 → 2.1.1-dev.4

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.
Files changed (50) hide show
  1. package/dist/ApprovalCodeList-B0PLZwav.js +758 -0
  2. package/dist/{AuditLogList-DHiqs9G0.js → AuditLogList-CRXwPImZ.js} +5 -5
  3. package/dist/{ConditionFormHost.vue_vue_type_script_setup_true_lang-CWqNWNdD.js → ConditionFormHost.vue_vue_type_script_setup_true_lang-zJwkM_Xb.js} +2 -2
  4. package/dist/{EmployeeList-CUd3VH5h.js → EmployeeList-DN2pnXcS.js} +7 -7
  5. package/dist/GrantUserList-DoyxknJZ.js +464 -0
  6. package/dist/{Main-DgemO-iy.js → Main-B5BKGpLg.js} +13 -11
  7. package/dist/Main-BGONIxo8.js +122 -0
  8. package/dist/{Main-B_L5flWT.js → Main-DQj4xtkB.js} +10 -8
  9. package/dist/{PermissionSetList-BaC4lKV5.js → PermissionSetList-4uIU9FvN.js} +13 -12
  10. package/dist/PortalPermissionEditor.vue_vue_type_script_setup_true_lang-D0luaKDb.js +4122 -0
  11. package/dist/{PortalUserSearcher.vue_vue_type_style_index_0_scoped_79737e32_lang-DbPzVpnG.js → PortalUserSearcher.vue_vue_type_style_index_0_scoped_827dfd60_lang-DVVSBIx2.js} +1 -1
  12. package/dist/{RoleList-CThb6VEd.js → RoleList-Bj5Y5jd_.js} +12 -11
  13. package/dist/TableEmptyState.vue_vue_type_script_setup_true_lang-IfAZmWr0.js +37 -0
  14. package/dist/TeamMemberList-Byjlca2Y.js +1216 -0
  15. package/dist/{TimesheetList-C_IMtsTH.js → TimesheetList-DwIcsOM-.js} +47 -46
  16. package/dist/{TimesheetList.vue_vue_type_style_index_0_scoped_2c7a177a_lang-DGwteHIL.js → TimesheetList.vue_vue_type_style_index_0_scoped_2c7a177a_lang-B9qlQ6KG.js} +14 -13
  17. package/dist/{app-BW91YDke.js → app-BZwE2coe.js} +2512 -2035
  18. package/dist/app.js +1 -1
  19. package/dist/approval-code-Q4666xp5.js +58 -0
  20. package/dist/{dayjs.min-DwQTpnVK.js → dayjs.min-BXBPls4m.js} +1 -1
  21. package/dist/{employee-yM0kdY70.js → employee-CJTbs1f7.js} +27 -26
  22. package/dist/grant-user-CQZaTzVt.js +67 -0
  23. package/dist/{TableEmptyState.vue_vue_type_script_setup_true_lang-Ci_MVqGK.js → index.vue_vue_type_script_setup_true_lang-BVVwfd7B.js} +19 -50
  24. package/dist/iteration-BCbIbdHR.js +7682 -0
  25. package/dist/{lodash-DLReQyP0.js → lodash-CUIS1iIz.js} +1 -1
  26. package/dist/restaurant-YOVMuuFY.js +1876 -0
  27. package/dist/role-CzXchcSS.js +82 -0
  28. package/dist/{rule-BJ-o-PKi.js → rule-BO6xj2Xa.js} +37 -36
  29. package/dist/src/api/approval-code/index.d.ts +7 -0
  30. package/dist/src/router/shared.d.ts +3 -1
  31. package/dist/src/stores/approval-code.d.ts +140 -0
  32. package/dist/src/types/approval-code.d.ts +114 -0
  33. package/dist/src/views/approval-code/ApprovalCodeList.vue.d.ts +26 -0
  34. package/dist/src/views/approval-code/components/ApprovalCodeCreatedDialog.vue.d.ts +9 -0
  35. package/dist/src/views/approval-code/components/ApprovalCodeForm.vue.d.ts +22 -0
  36. package/dist/src/views/approval-code/locales/index.d.ts +360 -0
  37. package/dist/src/views/pos-access/locales/index.d.ts +48 -0
  38. package/dist/src/views/team/locales/index.d.ts +8 -0
  39. package/dist/style.css +1 -1
  40. package/dist/tsconfig.app.tsbuildinfo +1 -1
  41. package/dist/useAppStore-DNTlIeMv.js +93 -0
  42. package/dist/{useLoading-B89K5XKO.js → useLoading-BH02lYns.js} +1 -1
  43. package/dist/{useReportPermissions-Bjfhr6FD.js → useReportPermissions-Q-xLwz5N.js} +3 -3
  44. package/package.json +1 -1
  45. package/dist/Main-DUbLeLlK.js +0 -577
  46. package/dist/PortalPermissionEditor.vue_vue_type_script_setup_true_lang-DddOxcG_.js +0 -4121
  47. package/dist/TeamMemberList-CAw4jr1b.js +0 -1186
  48. package/dist/iteration-Dj50K6I7.js +0 -9556
  49. package/dist/useAppStore-CHkGWiai.js +0 -169
  50. /package/dist/src/views/{grant → pos-access}/Main.vue.d.ts +0 -0
@@ -0,0 +1,1216 @@
1
+ import { defineComponent as Ie, resolveComponent as F, createElementBlock as N, openBlock as y, createElementVNode as u, createVNode as d, toDisplayString as k, unref as r, computed as I, ref as b, createCommentVNode as K, withCtx as ue, createBlock as z, watch as fe, Fragment as Ne, renderList as us, withKeys as qe, withModifiers as Ve, nextTick as ms, onUnmounted as ds, h as cs, createTextVNode as ps } from "vue";
2
+ import { useI18n as Pe, useCoreStore as Ae, baseClientInstance as Ke } from "@feedmepos/mf-common";
3
+ import { useSnackbar as He, useDialog as es, useBreakpoints as ss, components as je } from "@feedmepos/ui-library";
4
+ import { u as fs } from "./useDebounce-B8ZPVS5C.js";
5
+ import { _ as vs, S as ye } from "./SelectFilter-ATOm0hdn.js";
6
+ import { v as ze, m as bs, b as hs, _ as ys, a as _s } from "./app-BZwE2coe.js";
7
+ import { u as gs, _ as xs } from "./useDiscardConfirm-DPhEV6v0.js";
8
+ import { _ as Us } from "./TableEmptyState.vue_vue_type_script_setup_true_lang-IfAZmWr0.js";
9
+ import { _ as Ss } from "./Skeleton.vue_vue_type_script_setup_true_lang-B4PxNMwq.js";
10
+ import { u as Fs } from "./useLoading-BH02lYns.js";
11
+ import { l as Se } from "./lodash-CUIS1iIz.js";
12
+ import { c as he } from "./iteration-BCbIbdHR.js";
13
+ import { u as ts, c as Le, d as Ge, m as Me, i as as, p as We, j as Vs, k as Je, l as Xe, s as ws, n as Is, o as Ps, q as ks, v as Rs, t as Fe } from "./rule-BO6xj2Xa.js";
14
+ import { u as ls } from "./role-CzXchcSS.js";
15
+ import { u as os, i as $s } from "./PortalUserSearcher.vue_vue_type_style_index_0_scoped_827dfd60_lang-DVVSBIx2.js";
16
+ import { g as Ze, u as rs } from "./restaurant-YOVMuuFY.js";
17
+ import { _ as Cs } from "./PortalPermissionEditor.vue_vue_type_script_setup_true_lang-D0luaKDb.js";
18
+ var ge = /* @__PURE__ */ ((i) => (i.Update = "Update", i.Remove = "Remove", i))(ge || {});
19
+ const we = "__unassigned__";
20
+ function Qe(i) {
21
+ if (!(i != null && i.length) || i[0] === we) return i;
22
+ const R = i.filter((n) => n !== we);
23
+ return R.length === i.length ? i : [we, ...R];
24
+ }
25
+ const Ms = { class: "w-full flex flex-col gap-16" }, Ns = { class: "flex items-center gap-16" }, As = { class: "space-y-4 min-w-0 flex-1" }, Es = { class: "text-fm-color-typo-secondary fm-typo-en-body-lg-400" }, Ds = { class: "fm-typo-en-body-lg-600 truncate" }, Os = { class: "w-full flex gap-16 items-center" }, Bs = { class: "flex-1 flex flex-col gap-4 min-w-0" }, js = { class: "text-fm-color-typo-secondary fm-typo-en-body-lg-400" }, Ls = { class: "fm-typo-en-body-lg-600 truncate" }, Ts = { class: "flex-1 flex flex-col gap-4 min-w-0" }, qs = { class: "text-fm-color-typo-secondary fm-typo-en-body-lg-400" }, Ks = { class: "fm-typo-en-body-lg-600 truncate" }, zs = /* @__PURE__ */ Ie({
26
+ __name: "MemberInfo",
27
+ props: {
28
+ data: {}
29
+ },
30
+ setup(i) {
31
+ const { t: R } = Pe();
32
+ return (n, a) => {
33
+ const f = F("FmAvatar");
34
+ return y(), N("div", Ms, [
35
+ u("div", Ns, [
36
+ d(f, {
37
+ size: "xl",
38
+ name: i.data.name
39
+ }, null, 8, ["name"]),
40
+ u("div", As, [
41
+ u("p", Es, k(r(R)("team.memberForm.memberInfo.memberName")), 1),
42
+ u("p", Ds, k(i.data.name || "--"), 1)
43
+ ])
44
+ ]),
45
+ u("div", Os, [
46
+ u("div", Bs, [
47
+ u("p", js, k(r(R)("team.memberForm.memberInfo.mobileNumber")), 1),
48
+ u("p", Ls, k(i.data.phoneNumber || "--"), 1)
49
+ ]),
50
+ u("div", Ts, [
51
+ u("p", qs, k(r(R)("team.memberForm.memberInfo.emailAddress")), 1),
52
+ u("p", Ks, k(i.data.email || "--"), 1)
53
+ ])
54
+ ])
55
+ ]);
56
+ };
57
+ }
58
+ }), Ye = {
59
+ async readPermissionUserByPhoneNo(i) {
60
+ var n;
61
+ const { currentBusiness: R } = Ae();
62
+ return Ze(
63
+ await Ke("/").get(`/user/b/${(n = R.value) == null ? void 0 : n._id}/phone/${i}`)
64
+ );
65
+ },
66
+ async readPermissionUserByEmail(i) {
67
+ var n;
68
+ const { currentBusiness: R } = Ae();
69
+ return Ze(
70
+ await Ke("/").get(`/user/b/${(n = R.value) == null ? void 0 : n._id}/email/${i}`)
71
+ );
72
+ }
73
+ }, Gs = { class: "flex flex-col gap-24 w-full" }, Ws = {
74
+ key: 0,
75
+ class: "flex flex-col gap-8"
76
+ }, Js = { class: "user-info-icon user-info-icon--lg" }, Xs = { class: "flex-1 overflow-hidden" }, Zs = { class: "profile-displayName" }, Qs = { class: "profile-email" }, Ys = { class: "profile-phone" }, Hs = { key: 2 }, et = /* @__PURE__ */ Ie({
77
+ __name: "PortalUserSearcher",
78
+ emits: ["invite"],
79
+ setup(i, { emit: R }) {
80
+ const n = R, { t: a } = Pe(), f = He(), A = Ae(), { supportedCountries: V, ready: $ } = os(), se = I(() => {
81
+ var l;
82
+ const o = (l = A.currentCountry.value) == null ? void 0 : l.toUpperCase();
83
+ return o && $s(o) ? o : void 0;
84
+ }), g = b("phone"), S = b(""), p = b(""), h = b(), me = /^[^\s@]+@[^\s@]+\.[^\s@]+$/, j = I(() => me.test(p.value.trim()));
85
+ async function L() {
86
+ const o = g.value === "phone" ? S.value.replace(/ /g, "") : p.value.trim();
87
+ if (!o) {
88
+ f.open({
89
+ type: "error",
90
+ title: a("team.memberForm.searchUser.emptyError")
91
+ });
92
+ return;
93
+ }
94
+ if (g.value === "email" && !j.value) {
95
+ f.open({
96
+ type: "error",
97
+ title: a("team.memberForm.searchUser.invalidEmail")
98
+ });
99
+ return;
100
+ }
101
+ const l = () => {
102
+ h.value = void 0, f.open({
103
+ type: "error",
104
+ title: a("team.memberForm.searchUser.userNotFound")
105
+ });
106
+ };
107
+ try {
108
+ const v = g.value === "phone" ? await Ye.readPermissionUserByPhoneNo(o) : await Ye.readPermissionUserByEmail(o);
109
+ if (!v) {
110
+ l();
111
+ return;
112
+ }
113
+ h.value = v;
114
+ } catch {
115
+ h.value = void 0, f.open({
116
+ type: "error",
117
+ title: a("team.memberForm.searchUser.searchFailed")
118
+ });
119
+ }
120
+ }
121
+ const C = I(() => {
122
+ var x;
123
+ let o = ((x = h.value) == null ? void 0 : x.displayName) ?? "";
124
+ o || (o = "Feed Me");
125
+ const [l, v] = o.split(" ");
126
+ return v ? `${l[0]}${v[0]}` : l.slice(0, 2);
127
+ }), E = b(!1);
128
+ function W(o) {
129
+ n("invite", o), E.value = !0;
130
+ }
131
+ function te() {
132
+ E.value = !1;
133
+ }
134
+ return (o, l) => {
135
+ var B, m, _;
136
+ const v = F("FmRadio"), x = F("FmPhoneNumber"), J = F("FmCircularProgress"), X = F("FmTextField"), O = F("FmRadioGroup"), D = F("FmButton");
137
+ return y(), N("div", Gs, [
138
+ E.value ? K("", !0) : (y(), N("div", Ws, [
139
+ d(O, {
140
+ modelValue: g.value,
141
+ "onUpdate:modelValue": l[2] || (l[2] = (w) => g.value = w)
142
+ }, {
143
+ default: ue(() => [
144
+ d(v, {
145
+ value: "phone",
146
+ label: r(a)("team.memberForm.searchUser.phoneNumber")
147
+ }, null, 8, ["label"]),
148
+ g.value === "phone" && r($) ? (y(), z(x, {
149
+ key: 0,
150
+ modelValue: S.value,
151
+ "onUpdate:modelValue": l[0] || (l[0] = (w) => S.value = w),
152
+ "default-country": se.value,
153
+ "extra-country-codes": r(V),
154
+ class: "ml-8"
155
+ }, null, 8, ["modelValue", "default-country", "extra-country-codes"])) : g.value === "phone" ? (y(), z(J, {
156
+ key: 1,
157
+ class: "ml-8"
158
+ })) : K("", !0),
159
+ d(v, {
160
+ value: "email",
161
+ label: r(a)("team.memberForm.searchUser.email")
162
+ }, null, 8, ["label"]),
163
+ g.value === "email" ? (y(), z(X, {
164
+ key: 2,
165
+ modelValue: p.value,
166
+ "onUpdate:modelValue": l[1] || (l[1] = (w) => p.value = w),
167
+ placeholder: r(a)("team.memberForm.searchUser.emailPlaceholder"),
168
+ rules: [
169
+ (w) => !w || j.value || r(a)("team.memberForm.searchUser.invalidEmail")
170
+ ],
171
+ class: "ml-8"
172
+ }, null, 8, ["modelValue", "placeholder", "rules"])) : K("", !0)
173
+ ]),
174
+ _: 1
175
+ }, 8, ["modelValue"]),
176
+ d(D, {
177
+ label: r(a)("team.memberForm.searchUser.search"),
178
+ variant: "secondary",
179
+ onClick: L
180
+ }, null, 8, ["label"])
181
+ ])),
182
+ h.value ? (y(), N("div", {
183
+ key: 1,
184
+ class: "profile-menu--profile cursor-pointer hover:bg-fm-color-opacity-sm",
185
+ onClick: l[3] || (l[3] = (w) => W(h.value))
186
+ }, [
187
+ u("div", Js, k(C.value), 1),
188
+ u("div", Xs, [
189
+ u("p", Zs, k((B = h.value) == null ? void 0 : B.displayName), 1),
190
+ u("p", Qs, k((m = h.value) == null ? void 0 : m.email), 1),
191
+ u("p", Ys, k((_ = h.value) == null ? void 0 : _.phoneNumber), 1)
192
+ ])
193
+ ])) : K("", !0),
194
+ E.value ? (y(), N("div", Hs, [
195
+ d(D, {
196
+ label: r(a)("team.memberForm.searchUser.changeUser"),
197
+ variant: "secondary",
198
+ onClick: te
199
+ }, null, 8, ["label"])
200
+ ])) : K("", !0)
201
+ ]);
202
+ };
203
+ }
204
+ }), st = /* @__PURE__ */ vs(et, [["__scopeId", "data-v-827dfd60"]]), tt = { class: "flex flex-col gap-40" }, at = { class: "flex items-center" }, lt = { class: "flex-1 flex flex-col" }, ot = { class: "fm-typo-en-title-sm-600" }, rt = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, nt = { class: "flex flex-row gap-16" }, it = { class: "flex flex-col gap-8" }, ut = { class: "fm-typo-en-body-lg-400" }, mt = { class: "space-y-16 rounded-lg border border-fm-color-neutral-gray-200 p-16" }, dt = { class: "fm-typo-en-title-sm-600" }, ct = { class: "space-y-16" }, pt = { class: "grid grid-cols-[minmax(0,1fr)_minmax(0,1fr)_auto] gap-16" }, ft = { class: "text-sm font-semibold text-fm-color-typo-primary" }, vt = { class: "text-sm font-semibold text-fm-color-typo-primary" }, bt = { class: "flex justify-self-end" }, ht = ["aria-label", "onClick", "onKeydown"], Te = 4, yt = /* @__PURE__ */ Ie({
205
+ __name: "TeamMemberMasterUser",
206
+ props: {
207
+ modelValue: {
208
+ type: Object,
209
+ default: void 0
210
+ },
211
+ fallbackName: {
212
+ type: String,
213
+ required: !0
214
+ },
215
+ fallbackPasscode: {
216
+ type: String,
217
+ default: void 0
218
+ },
219
+ restaurants: {
220
+ type: Array,
221
+ required: !0
222
+ },
223
+ roles: {
224
+ type: Array,
225
+ required: !0
226
+ }
227
+ },
228
+ emits: ["update:model-value"],
229
+ setup(i, { emit: R }) {
230
+ const n = i, a = R, { t: f } = Pe(), A = b(!0), V = b([]);
231
+ function $() {
232
+ return { restaurantId: "", roleId: "" };
233
+ }
234
+ const se = I(
235
+ () => {
236
+ var o;
237
+ return ((o = n.modelValue) == null ? void 0 : o.roles.map((l) => l.restaurantId).filter(Boolean)) ?? [];
238
+ }
239
+ );
240
+ function g(o) {
241
+ o ? n.modelValue || a("update:model-value", {
242
+ code: "",
243
+ name: n.fallbackName,
244
+ roles: [$()],
245
+ passcode: n.fallbackPasscode || ""
246
+ }) : a("update:model-value", null);
247
+ }
248
+ function S(o, l) {
249
+ if (!n.modelValue || o === "passcode" && n.modelValue.passcode === l) return;
250
+ const v = he(n.modelValue);
251
+ v[o] = l, a("update:model-value", v);
252
+ }
253
+ function p(o = "") {
254
+ return n.restaurants.filter((l) => l.managable || l._id === o).map((l) => ({
255
+ label: `${l.profile.code ? `${l.profile.code} - ` : ""}${l.profile.name}`,
256
+ value: l._id,
257
+ disabled: se.value.includes(l._id) && l._id !== o
258
+ }));
259
+ }
260
+ function h(o = "") {
261
+ return n.roles.map((l) => ({
262
+ label: l.label,
263
+ value: l.value,
264
+ disabled: !!l.disabled && l.value !== o
265
+ }));
266
+ }
267
+ function me(o, l) {
268
+ var O, D, B;
269
+ if (!n.modelValue) return;
270
+ const v = n.modelValue.roles.length > 0 ? [...n.modelValue.roles] : [$()], x = ((O = v[o]) == null ? void 0 : O.roleId) ?? "", J = h(x), X = ((D = J.find((m) => m.value === x && !m.disabled)) == null ? void 0 : D.value) ?? ((B = J.find((m) => !m.disabled)) == null ? void 0 : B.value) ?? "";
271
+ v[o] = { restaurantId: l, roleId: X }, S("roles", v);
272
+ }
273
+ function j(o, l) {
274
+ var x;
275
+ if (!n.modelValue) return;
276
+ const v = n.modelValue.roles.length > 0 ? [...n.modelValue.roles] : [$()];
277
+ v[o] = {
278
+ restaurantId: ((x = v[o]) == null ? void 0 : x.restaurantId) ?? "",
279
+ roleId: l
280
+ }, S("roles", v);
281
+ }
282
+ function L() {
283
+ n.modelValue && S("roles", [...n.modelValue.roles, $()]);
284
+ }
285
+ function C(o) {
286
+ if (!n.modelValue) return;
287
+ const l = n.modelValue.roles.length > 0 ? [...n.modelValue.roles] : [$()];
288
+ S(
289
+ "roles",
290
+ l.length === 1 ? [$()] : l.filter((v, x) => x !== o)
291
+ );
292
+ }
293
+ const E = I(() => {
294
+ if (!n.modelValue) return !1;
295
+ const o = n.restaurants.some(
296
+ (v) => v.managable && !se.value.includes(v._id)
297
+ ), l = n.modelValue.roles.every(
298
+ (v) => v.restaurantId && v.roleId
299
+ );
300
+ return o && l;
301
+ });
302
+ function W() {
303
+ A.value && (A.value = !1, V.value = [], S("passcode", ""));
304
+ }
305
+ fe(
306
+ () => {
307
+ var o;
308
+ return (o = n.modelValue) == null ? void 0 : o.passcode;
309
+ },
310
+ (o) => {
311
+ o && o.length === Te ? (V.value = o.split(""), A.value = !0) : (V.value = [], A.value = !1);
312
+ },
313
+ { immediate: !0 }
314
+ ), fe(
315
+ () => {
316
+ var o;
317
+ return (o = n.modelValue) == null ? void 0 : o.roles;
318
+ },
319
+ (o) => {
320
+ n.modelValue && (!o || o.length === 0) && S("roles", [$()]);
321
+ },
322
+ { immediate: !0, deep: !0 }
323
+ );
324
+ const te = I({
325
+ get: () => {
326
+ var o;
327
+ return ((o = n.modelValue) == null ? void 0 : o.roles) ?? [];
328
+ },
329
+ set: () => {
330
+ }
331
+ });
332
+ return (o, l) => {
333
+ const v = F("FmSwitch"), x = F("FmTextField"), J = F("FmPinField"), X = F("FmFormGroup"), O = F("FmSelect"), D = F("FmIcon"), B = F("FmButton");
334
+ return y(), N("div", tt, [
335
+ u("div", at, [
336
+ u("div", lt, [
337
+ u("div", ot, k(r(f)("team.memberForm.masterUser.title")), 1),
338
+ u("div", rt, k(r(f)("team.memberForm.masterUser.sublabel")), 1)
339
+ ]),
340
+ u("div", null, [
341
+ d(v, {
342
+ "model-value": !!i.modelValue,
343
+ value: "master-user",
344
+ "onUpdate:modelValue": g
345
+ }, null, 8, ["model-value"])
346
+ ])
347
+ ]),
348
+ i.modelValue ? (y(), N(Ne, { key: 0 }, [
349
+ u("div", nt, [
350
+ d(x, {
351
+ "model-value": i.modelValue.code,
352
+ label: r(f)("team.memberForm.masterUser.code"),
353
+ "onUpdate:modelValue": l[0] || (l[0] = (m) => S("code", m))
354
+ }, null, 8, ["model-value", "label"]),
355
+ d(x, {
356
+ "model-value": i.modelValue.name,
357
+ class: "w-full",
358
+ label: r(f)("team.memberForm.masterUser.name"),
359
+ rules: [(m) => !!m || r(f)("team.memberForm.masterUser.nameEmptyError")],
360
+ "onUpdate:modelValue": l[1] || (l[1] = (m) => S("name", m))
361
+ }, null, 8, ["model-value", "label", "rules"])
362
+ ]),
363
+ u("div", it, [
364
+ u("div", ut, k(r(f)("team.memberForm.masterUser.passcode")), 1),
365
+ d(X, {
366
+ modelValue: V.value,
367
+ "onUpdate:modelValue": l[4] || (l[4] = (m) => V.value = m),
368
+ rules: [
369
+ (m) => (m == null ? void 0 : m.filter((_) => !!_).length) !== Te ? r(f)("team.memberForm.masterUser.passcodeRequired") : !0
370
+ ]
371
+ }, {
372
+ default: ue(() => [
373
+ (y(), z(J, {
374
+ key: `pin-field-${A.value}`,
375
+ modelValue: V.value,
376
+ "onUpdate:modelValue": l[2] || (l[2] = (m) => V.value = m),
377
+ length: Te,
378
+ masked: A.value,
379
+ onComplete: l[3] || (l[3] = (m) => S("passcode", m)),
380
+ onFocus: W
381
+ }, null, 8, ["modelValue", "masked"]))
382
+ ]),
383
+ _: 1
384
+ }, 8, ["modelValue", "rules"])
385
+ ]),
386
+ d(X, {
387
+ tag: "div",
388
+ modelValue: te.value,
389
+ "onUpdate:modelValue": l[5] || (l[5] = (m) => te.value = m),
390
+ rules: [
391
+ (m) => !m || m.length === 0 || m.every((_) => !_.restaurantId) ? r(f)("team.memberForm.masterUser.restaurantRequired") : m.some((_) => !_.restaurantId || !_.roleId) ? r(f)("team.memberForm.masterUser.roleRequired") : !0
392
+ ]
393
+ }, {
394
+ default: ue(() => [
395
+ u("div", mt, [
396
+ u("div", dt, k(r(f)("team.memberForm.masterUser.assignmentSection")), 1),
397
+ u("div", ct, [
398
+ u("div", pt, [
399
+ u("div", ft, k(r(f)("team.table.columns.restaurant")), 1),
400
+ u("div", vt, k(r(f)("team.memberForm.masterUser.role")), 1),
401
+ l[6] || (l[6] = u("div", null, null, -1))
402
+ ]),
403
+ (y(!0), N(Ne, null, us(i.modelValue.roles, (m, _) => (y(), N("div", {
404
+ key: `${m.restaurantId || "new"}-${_}`,
405
+ class: "grid grid-cols-[minmax(0,1fr)_minmax(0,1fr)_auto] items-center gap-16"
406
+ }, [
407
+ d(O, {
408
+ class: "min-w-0",
409
+ "model-value": m.restaurantId,
410
+ items: p(m.restaurantId),
411
+ multiselect: !1,
412
+ placeholder: r(f)("team.table.columns.restaurant"),
413
+ "onUpdate:modelValue": (w) => me(_, w)
414
+ }, null, 8, ["model-value", "items", "placeholder", "onUpdate:modelValue"]),
415
+ d(O, {
416
+ class: "min-w-0",
417
+ "model-value": m.roleId,
418
+ items: h(m.roleId),
419
+ multiselect: !1,
420
+ placeholder: r(f)("team.memberForm.masterUser.role"),
421
+ disabled: !m.restaurantId,
422
+ "onUpdate:modelValue": (w) => j(_, w)
423
+ }, null, 8, ["model-value", "items", "placeholder", "disabled", "onUpdate:modelValue"]),
424
+ u("div", bt, [
425
+ i.modelValue.roles.length > 1 ? (y(), N("div", {
426
+ key: 0,
427
+ role: "button",
428
+ tabindex: "0",
429
+ class: "inline-flex h-40 w-40 shrink-0 cursor-pointer items-center justify-center rounded-lg text-fm-color-neutral-gray-400 transition-colors hover:bg-fm-color-neutral-gray-100 focus:outline-none focus:ring-2 focus:ring-fm-color-primary",
430
+ "aria-label": r(f)("common.remove"),
431
+ onClick: Ve((w) => C(_), ["stop"]),
432
+ onKeydown: [
433
+ qe(Ve((w) => C(_), ["prevent", "stop"]), ["enter"]),
434
+ qe(Ve((w) => C(_), ["prevent", "stop"]), ["space"])
435
+ ]
436
+ }, [
437
+ d(D, {
438
+ name: "delete",
439
+ size: "md"
440
+ })
441
+ ], 40, ht)) : K("", !0)
442
+ ])
443
+ ]))), 128))
444
+ ]),
445
+ d(B, {
446
+ type: "button",
447
+ variant: "secondary",
448
+ "text-color": "primary",
449
+ "border-color": "primary",
450
+ "prepend-icon": "add",
451
+ label: r(f)("team.memberForm.masterUser.addAnother"),
452
+ size: "md",
453
+ disabled: !E.value,
454
+ onClick: Ve(L, ["stop"])
455
+ }, null, 8, ["label", "disabled"])
456
+ ])
457
+ ]),
458
+ _: 1
459
+ }, 8, ["modelValue", "rules"])
460
+ ], 64)) : K("", !0)
461
+ ]);
462
+ };
463
+ }
464
+ }), _t = { class: "flex flex-col gap-32" }, gt = { class: "flex w-full" }, xt = {
465
+ key: 0,
466
+ class: "space-y-24"
467
+ }, Ut = { class: "space-y-16 rounded-lg border border-fm-color-neutral-gray-200 p-16" }, St = { class: "fm-typo-en-title-sm-600" }, Ft = { class: "space-y-16" }, Vt = { class: "fm-typo-en-title-sm-600" }, wt = {
468
+ key: 1,
469
+ class: "flex items-center justify-center py-64"
470
+ }, It = /* @__PURE__ */ Ie({
471
+ __name: "AddMemberForm",
472
+ props: {
473
+ initialValue: {
474
+ type: Object
475
+ },
476
+ roleErrorMessage: {
477
+ type: String,
478
+ default: ""
479
+ },
480
+ loading: {
481
+ type: Boolean,
482
+ default: !1
483
+ }
484
+ },
485
+ setup(i, { expose: R }) {
486
+ var Re, le, Z;
487
+ const n = i, { t: a } = Pe(), f = es(), { breakpoints: A } = ss(), V = b(), $ = ts(), se = I(
488
+ () => $.permissionSets.value.map((s) => ({
489
+ label: s.name,
490
+ value: s.id
491
+ }))
492
+ ), g = b(((Re = n.initialValue) == null ? void 0 : Re.permissionSetIds) || []), S = I(
493
+ () => Le(g.value, $.permissionSets.value)
494
+ ), p = b((le = n.initialValue) == null ? void 0 : le.posUser), h = b(
495
+ Ge(
496
+ Me(S.value),
497
+ ((Z = n.initialValue) == null ? void 0 : Z.permissions) || []
498
+ )
499
+ ), { customReportPermissions: me, isLoaded: j } = as(), L = new Set(
500
+ We.filter((s) => s.subject.startsWith(Vs)).map((s) => s.subject)
501
+ ), C = I(() => {
502
+ const s = new Set(L);
503
+ for (const c of me.value) s.add(c.subject);
504
+ return s;
505
+ }), E = I(() => {
506
+ const s = /* @__PURE__ */ new Set();
507
+ for (const c of We)
508
+ c.category === ze.reports && s.add(c.subject);
509
+ for (const c of me.value)
510
+ c.category === ze.reports && s.add(c.subject);
511
+ return s;
512
+ }), W = rs(), te = ls().roles, o = I(() => Je(h.value)), l = I(() => {
513
+ const s = Xe(h.value);
514
+ return s === null ? W.restaurants.value : W.restaurants.value.filter((c) => s.includes(c._id));
515
+ }), v = I(() => {
516
+ const s = o.value;
517
+ return te.value.map(
518
+ (c) => ({
519
+ label: c.name,
520
+ value: c._id,
521
+ disabled: !!s && !s.includes(c._id)
522
+ })
523
+ );
524
+ }), x = b({ permissionSetIds: [], userPermissions: [], posUser: void 0 });
525
+ function J(s) {
526
+ V.value = void 0, g.value = [...(s == null ? void 0 : s.permissionSetIds) ?? []], h.value = Ge(
527
+ Me(
528
+ Le(
529
+ g.value,
530
+ $.permissionSets.value
531
+ )
532
+ ),
533
+ (s == null ? void 0 : s.permissions) || []
534
+ ), p.value = s != null && s.posUser ? ve(he(s.posUser), h.value) : void 0, be.value = !!p.value, x.value = {
535
+ permissionSetIds: [...g.value],
536
+ userPermissions: he(h.value),
537
+ posUser: p.value ? he(p.value) : void 0
538
+ };
539
+ }
540
+ function X() {
541
+ return !n.initialValue && V.value ? !0 : !Se.isEqual(g.value, x.value.permissionSetIds) || !Se.isEqual(h.value, x.value.userPermissions) || !Se.isEqual(p.value, x.value.posUser);
542
+ }
543
+ function O(s) {
544
+ V.value = s;
545
+ }
546
+ function D(s) {
547
+ p.value = ve(p.value, s);
548
+ }
549
+ function B(s) {
550
+ return Me(
551
+ Le(s, $.permissionSets.value)
552
+ );
553
+ }
554
+ function m(s) {
555
+ h.value = B(s);
556
+ }
557
+ function _(s) {
558
+ const c = [...s ?? []];
559
+ if (Se.isEqual(c, g.value)) return;
560
+ const T = !Se.isEqual(
561
+ h.value,
562
+ B(g.value)
563
+ );
564
+ if (g.value = c, !T) {
565
+ m(c);
566
+ return;
567
+ }
568
+ f.open({
569
+ title: a("permissionSet.form.overrideInherited.title"),
570
+ message: a("permissionSet.form.overrideInherited.message"),
571
+ minWidth: A.value.lg ? 588 : 0,
572
+ primaryActions: {
573
+ text: a("permissionSet.form.overrideInherited.override"),
574
+ close: !1
575
+ },
576
+ secondaryActions: {
577
+ text: a("permissionSet.form.overrideInherited.keepCurrent"),
578
+ close: !0
579
+ }
580
+ }).onPrimary(() => {
581
+ m(c), f.close();
582
+ });
583
+ }
584
+ function w() {
585
+ const s = j.value ? C.value : L, c = Ps(h.value, s);
586
+ return ks(c, E.value);
587
+ }
588
+ function Ee() {
589
+ const s = Me(S.value), c = ws(w());
590
+ return Is(s, c);
591
+ }
592
+ function ke() {
593
+ var T, G, Q, q, ce, Y, H, oe, pe, $e;
594
+ const s = Ee(), c = w().filter((re) => !re.inverted);
595
+ return {
596
+ email: ((T = V.value) == null ? void 0 : T.email) ?? void 0,
597
+ phoneNumber: ((G = V.value) == null ? void 0 : G.phoneNumber) ?? void 0,
598
+ customPermissions: s,
599
+ permissions: c.map((re) => ({
600
+ ...re,
601
+ subject: bs(re.subject)
602
+ })),
603
+ permissionSetIds: g.value,
604
+ name: ((Q = V.value) == null ? void 0 : Q.displayName) || ((q = n.initialValue) == null ? void 0 : q.name) || "",
605
+ posUser: p.value ? {
606
+ ...p.value,
607
+ name: p.value.name || ((Y = (ce = n.initialValue) == null ? void 0 : ce.posUser) == null ? void 0 : Y.name) || ((H = n.initialValue) == null ? void 0 : H.name) || ((oe = V.value) == null ? void 0 : oe.displayName) || "",
608
+ code: p.value.code || (($e = (pe = n.initialValue) == null ? void 0 : pe.posUser) == null ? void 0 : $e.code) || "",
609
+ passcode: p.value.passcode,
610
+ roles: p.value.roles.filter((re) => !!re.roleId)
611
+ } : p.value === null ? null : void 0
612
+ };
613
+ }
614
+ const ae = b();
615
+ function ve(s, c) {
616
+ if (!s) return s;
617
+ const T = Je(c), G = Xe(c);
618
+ if (T === null && G === null) return s;
619
+ const Q = he(s);
620
+ return Q.roles = Q.roles.filter(
621
+ (q) => (T === null || T.includes(q.roleId)) && (G === null || G.includes(q.restaurantId))
622
+ ), Q;
623
+ }
624
+ const be = b(!!p.value), de = b(!1);
625
+ function De(s) {
626
+ p.value = s, de.value = !0;
627
+ }
628
+ fe(
629
+ () => !!p.value,
630
+ async (s) => {
631
+ s && !be.value && de.value && (await ms(), ae.value && ae.value.$el.scrollIntoView({ behavior: "smooth", block: "start" })), be.value = s;
632
+ }
633
+ );
634
+ const xe = b();
635
+ async function Oe() {
636
+ return (await xe.value.validateInputsWithoutSubmit()).length ? null : ke();
637
+ }
638
+ return fe(
639
+ () => n.initialValue,
640
+ (s, c) => {
641
+ if (!c || !s || c.id !== s.id) {
642
+ de.value = !1, J(s);
643
+ return;
644
+ }
645
+ s.posUser !== void 0 && !de.value && (p.value = s.posUser ? ve(he(s.posUser), h.value) : void 0, x.value = {
646
+ ...x.value,
647
+ posUser: p.value ? he(p.value) : void 0
648
+ });
649
+ },
650
+ { immediate: !0 }
651
+ ), fe(
652
+ h,
653
+ (s) => {
654
+ p.value = ve(p.value, s);
655
+ },
656
+ { deep: !0 }
657
+ ), R({
658
+ readFormData: ke,
659
+ validate: Oe,
660
+ isModified: X
661
+ }), (s, c) => {
662
+ const T = F("FmSelect"), G = F("FmCircularProgress"), Q = F("FmForm");
663
+ return y(), z(Q, {
664
+ ref_key: "formRef",
665
+ ref: xe,
666
+ class: "mx-4"
667
+ }, {
668
+ default: ue(() => {
669
+ var q, ce, Y, H, oe;
670
+ return [
671
+ u("div", _t, [
672
+ u("div", gt, [
673
+ i.initialValue ? (y(), z(zs, {
674
+ key: 1,
675
+ data: i.initialValue
676
+ }, null, 8, ["data"])) : (y(), z(st, {
677
+ key: 0,
678
+ onInvite: c[0] || (c[0] = (pe) => O(pe))
679
+ }))
680
+ ]),
681
+ V.value || i.initialValue ? (y(), N(Ne, { key: 0 }, [
682
+ (q = i.initialValue) != null && q.isOwner ? K("", !0) : (y(), N("div", xt, [
683
+ u("div", Ut, [
684
+ u("div", St, k(r(a)("team.memberForm.permissionSet.title")), 1),
685
+ d(T, {
686
+ "model-value": g.value,
687
+ multiselect: "",
688
+ searchable: "",
689
+ "search-debounce": 300,
690
+ items: se.value,
691
+ placeholder: r(a)("team.memberForm.permissionSet.selectPlaceholder"),
692
+ "onUpdate:modelValue": _
693
+ }, null, 8, ["model-value", "items", "placeholder"])
694
+ ]),
695
+ u("div", Ft, [
696
+ u("div", Vt, k(r(a)("team.memberForm.permissions.title")), 1),
697
+ d(Cs, {
698
+ modelValue: h.value,
699
+ "onUpdate:modelValue": c[1] || (c[1] = (pe) => h.value = pe),
700
+ "inherit-permissions": S.value,
701
+ onPermissionChanged: D
702
+ }, null, 8, ["modelValue", "inherit-permissions"])
703
+ ])
704
+ ])),
705
+ i.loading ? (y(), N("div", wt, [
706
+ d(G, { size: "xl" })
707
+ ])) : (y(), z(yt, {
708
+ key: 2,
709
+ ref_key: "masterUserContentRef",
710
+ ref: ae,
711
+ "model-value": p.value,
712
+ "fallback-name": ((ce = i.initialValue) == null ? void 0 : ce.name) || ((Y = V.value) == null ? void 0 : Y.displayName) || "",
713
+ "fallback-passcode": (oe = (H = i.initialValue) == null ? void 0 : H.posUser) == null ? void 0 : oe.passcode,
714
+ roles: v.value,
715
+ restaurants: l.value,
716
+ "onUpdate:modelValue": De
717
+ }, null, 8, ["model-value", "fallback-name", "fallback-passcode", "roles", "restaurants"]))
718
+ ], 64)) : K("", !0)
719
+ ])
720
+ ];
721
+ }),
722
+ _: 1
723
+ }, 512);
724
+ };
725
+ }
726
+ }), Pt = {
727
+ class: "space-y-24"
728
+ }, kt = {
729
+ class: "space-y-8"
730
+ }, Rt = {
731
+ key: 0,
732
+ class: "flex w-full items-start justify-between px-16"
733
+ }, $t = {
734
+ class: "flex items-start gap-8"
735
+ }, Ct = {
736
+ key: 1,
737
+ class: "space-y-4 px-16"
738
+ }, Mt = {
739
+ class: "flex items-start gap-8"
740
+ }, Nt = {
741
+ class: "flex h-full flex-col overflow-auto"
742
+ }, At = {
743
+ class: "flex w-full items-center justify-between"
744
+ }, Et = {
745
+ class: "fm-typo-en-title-md-600"
746
+ }, Dt = {
747
+ class: "flex items-center justify-start gap-8"
748
+ }, _e = 100;
749
+ var ee = /* @__PURE__ */ function(i) {
750
+ return i[i.ADD = 0] = "ADD", i[i.UPDATE = 1] = "UPDATE", i[i.CLOSED = 2] = "CLOSED", i;
751
+ }(ee || {});
752
+ const sa = /* @__PURE__ */ Ie({
753
+ __name: "TeamMemberList",
754
+ setup(i, {
755
+ expose: R
756
+ }) {
757
+ const {
758
+ fetchCustomReportPermissions: n
759
+ } = as();
760
+ os();
761
+ const {
762
+ t: a
763
+ } = Pe(), f = Ae(), A = rs(), V = ls(), $ = He(), se = Fs($), g = ts(), S = Rs(), p = b(!0), h = b(!1), me = I(() => A.isLoading.value), j = b([]), L = b(0), C = b(1), E = b(""), W = b("");
764
+ fe(A.restaurants, (e) => {
765
+ if (e.length > 0 && j.value.length > 0) {
766
+ const t = new Map(e.map((P) => [P._id, P.profile.name])), U = e.map((P) => P.profile.name).sort();
767
+ j.value = j.value.map((P) => ({
768
+ ...P,
769
+ restaurants: P.managableRestaurantIds === null ? U : P.managableRestaurantIds.map((ne) => t.get(ne) ?? "").filter(Boolean).sort()
770
+ }));
771
+ }
772
+ });
773
+ const te = I(() => [{
774
+ label: a("team.filter.unassigned_label"),
775
+ value: we
776
+ }, ...A.restaurants.value.map((e) => ({
777
+ label: `${e.profile.code ? `${e.profile.code} - ` : ""}${e.profile.name}`,
778
+ value: e._id
779
+ }))]), o = ({
780
+ member: e,
781
+ className: t = ""
782
+ }) => {
783
+ const U = {
784
+ label: a("team.actions.updateMember"),
785
+ onClick: () => B(ge.Update, e)
786
+ }, P = {
787
+ label: a("team.actions.removeMember"),
788
+ onClick: () => B(ge.Remove, e),
789
+ itemClass: "text-fm-color-typo-error"
790
+ }, ne = e.doc.isOwner ? [U] : [U, P];
791
+ return d(xs, {
792
+ class: t,
793
+ items: ne
794
+ }, null);
795
+ }, l = (e) => e.doc.isOwner ? a("team.labels.businessOwner") : e.restaurants.join(", "), v = [{
796
+ accessorKey: "name",
797
+ header: () => a("team.table.columns.name"),
798
+ enableSorting: !1,
799
+ cell(e) {
800
+ const t = e.row.original;
801
+ return d("div", {
802
+ class: "flex items-center gap-8"
803
+ }, [d(je.FmAvatar, {
804
+ name: t.name,
805
+ size: "sm",
806
+ class: "shrink-0"
807
+ }, null), d("span", {
808
+ class: "truncate"
809
+ }, [t.name])]);
810
+ }
811
+ }, {
812
+ accessorKey: "phoneNumber",
813
+ header: () => a("team.table.columns.phoneNumber"),
814
+ enableSorting: !1
815
+ }, {
816
+ accessorKey: "restaurant",
817
+ header: () => a("team.table.columns.restaurant"),
818
+ enableSorting: !1,
819
+ cell(e) {
820
+ if (me.value)
821
+ return cs(Ss);
822
+ const t = e.row.original;
823
+ return l(t);
824
+ }
825
+ }, {
826
+ accessorKey: "assignedRoles",
827
+ header: () => a("team.table.columns.assignedRoles"),
828
+ enableSorting: !1,
829
+ cell(e) {
830
+ const t = e.row.original, U = S.getPermissionAssignmentByUserId(t.id), P = (U == null ? void 0 : U.permissionSetIds) || t.doc.permissionSetIds || [];
831
+ return g.permissionSets.value.filter((ie) => P.includes(ie.id)).map((ie) => ie.name).join(", ");
832
+ }
833
+ }, {
834
+ accessorKey: "permission",
835
+ header: () => a("team.table.columns.permission"),
836
+ enableSorting: !1,
837
+ cell(e) {
838
+ const t = e.row.original;
839
+ return x(t);
840
+ },
841
+ meta: {
842
+ width: "200px"
843
+ }
844
+ }, {
845
+ id: "action",
846
+ meta: {
847
+ cellClass: "pl-16",
848
+ headerContentClass: "-mx-16"
849
+ },
850
+ cell(e) {
851
+ const t = e.row.original;
852
+ return o({
853
+ member: t,
854
+ className: "flex justify-end w-full"
855
+ });
856
+ },
857
+ enableSorting: !1
858
+ }];
859
+ function x(e) {
860
+ if (e.doc.isOwner)
861
+ return a("team.labels.businessOwner");
862
+ const t = d(je.FmTooltip, {
863
+ variant: "plain",
864
+ placement: "top"
865
+ }, {
866
+ default: () => d(je.FmIcon, {
867
+ name: "info",
868
+ class: "cursor-pointer text-fm-color-neutral-gray-300"
869
+ }, null),
870
+ content: () => d("div", null, [a("team.labels.permission"), e.permissionLabels.map((U) => d("div", null, [ps("- "), U]))])
871
+ });
872
+ return d("div", {
873
+ class: "flex flex-row items-center gap-8"
874
+ }, [d("span", null, [a("team.labels.allowed", {
875
+ count: e.permissionLabels.length
876
+ })]), e.permissionLabels.length > 0 && t]);
877
+ }
878
+ function J(e) {
879
+ var ne, ie, Ce, Ue;
880
+ const t = S.getPermissionAssignmentByUserId(e.id), U = (t == null ? void 0 : t.customPermissions) ?? e.permissions ?? [], P = (t == null ? void 0 : t.permissionSetIds) ?? e.doc.permissionSetIds ?? [];
881
+ return {
882
+ id: e.id,
883
+ isOwner: e.doc.isOwner,
884
+ name: e.name,
885
+ phoneNumber: e.phoneNumber,
886
+ email: e.email,
887
+ permissions: U,
888
+ permissionSetIds: P,
889
+ posUser: e.doc.posUser ? {
890
+ code: ((ne = e.doc.posUser) == null ? void 0 : ne.code) ?? "",
891
+ name: ((ie = e.doc.posUser) == null ? void 0 : ie.name) ?? e.name,
892
+ passcode: ((Ce = e.doc.posUser) == null ? void 0 : Ce.passcode) ?? "",
893
+ roles: ((Ue = e.doc.posUser) == null ? void 0 : Ue.roles) ?? []
894
+ } : void 0
895
+ };
896
+ }
897
+ function X(e) {
898
+ const t = S.getPermissionAssignmentByUserId(e.id), U = (t == null ? void 0 : t.customPermissions) ?? e.permissions ?? [], P = (t == null ? void 0 : t.permissionSetIds) ?? e.doc.permissionSetIds ?? [];
899
+ return {
900
+ id: e.id,
901
+ isOwner: e.doc.isOwner,
902
+ name: e.name,
903
+ phoneNumber: e.phoneNumber,
904
+ email: e.email,
905
+ permissions: U,
906
+ permissionSetIds: P,
907
+ posUser: void 0
908
+ };
909
+ }
910
+ const O = b(!1);
911
+ let D = 0;
912
+ const B = async (e, t) => {
913
+ if (e == ge.Update) {
914
+ const U = ++D;
915
+ ae.value = X(t), _.value = ee.UPDATE, O.value = t.doc.hasPosUser === !0;
916
+ try {
917
+ const P = await Fe.readTeamMember(t.id);
918
+ if (U !== D) return;
919
+ ae.value = J(P);
920
+ } catch {
921
+ if (U !== D) return;
922
+ $.open({
923
+ message: a("common.error"),
924
+ type: "error"
925
+ }), de();
926
+ } finally {
927
+ U === D && (O.value = !1);
928
+ }
929
+ }
930
+ e == ge.Remove && Oe(t);
931
+ }, m = es(), _ = b(ee.CLOSED), w = I(() => _.value !== ee.CLOSED), Ee = I(() => _.value === ee.ADD ? a("common.add") : a("common.update")), ke = I(() => _.value === ee.ADD ? a("team.actions.addMember") : a("team.actions.updateMember")), ae = b();
932
+ function ve() {
933
+ D++, O.value = !1, _.value = ee.CLOSED;
934
+ }
935
+ const be = gs(() => {
936
+ var e;
937
+ return ((e = Y.value) == null ? void 0 : e.isModified()) ?? !1;
938
+ }, ve);
939
+ function de() {
940
+ be();
941
+ }
942
+ function De(e) {
943
+ e || de();
944
+ }
945
+ const {
946
+ breakpoints: xe
947
+ } = ss(), Oe = (e) => {
948
+ m.open({
949
+ title: a("team.actions.removeMember"),
950
+ message: a("team.removeMember.confirmationMessage", {
951
+ memberName: e.name
952
+ }),
953
+ minWidth: xe.value.lg ? 588 : 0,
954
+ primaryActions: {
955
+ text: "Remove",
956
+ close: !1,
957
+ variant: "destructive",
958
+ isLoading: oe
959
+ },
960
+ secondaryActions: {
961
+ text: "Cancel",
962
+ close: !0
963
+ }
964
+ }).onPrimary(async () => {
965
+ oe.value || (await se.minor(async () => {
966
+ await Fe.deleteTeamMember(e.id), await ce();
967
+ }, {
968
+ isLoading: oe,
969
+ successMessage: a("team.removeMember.successMessage", {
970
+ memberName: e.name
971
+ })
972
+ }), m.close());
973
+ });
974
+ }, Re = () => {
975
+ ae.value = null, _.value = ee.ADD;
976
+ }, le = b(), Z = b(), s = b(), c = I(() => {
977
+ var e;
978
+ return JSON.stringify({
979
+ businessId: ((e = f.currentBusiness.value) == null ? void 0 : e._id) ?? "",
980
+ search: W.value.trim(),
981
+ restaurantIds: [...le.value ?? []].sort(),
982
+ permissionSubjects: [...Z.value ?? []].sort(),
983
+ permissionSetIds: [...s.value ?? []].sort()
984
+ });
985
+ }), T = I(() => Object.values(hs).map((e) => ({
986
+ label: e.label,
987
+ value: e.subject
988
+ }))), G = I(() => [{
989
+ label: a("team.filter.unassigned_label"),
990
+ value: we
991
+ }, ...g.permissionSets.value.map((e) => ({
992
+ label: e.name,
993
+ value: e.id
994
+ }))]);
995
+ async function Q() {
996
+ await V.readRoles();
997
+ }
998
+ async function q(e = C.value) {
999
+ var t;
1000
+ p.value = !0;
1001
+ try {
1002
+ const U = await Fe.readTeamMembersPage({
1003
+ limit: _e,
1004
+ offset: (e - 1) * _e,
1005
+ search: W.value.trim() || void 0,
1006
+ restaurantIds: Qe(le.value),
1007
+ permissionSubjects: (t = Z.value) != null && t.length ? Z.value : void 0,
1008
+ permissionSetIds: Qe(s.value)
1009
+ });
1010
+ j.value = U.items, L.value = U.total;
1011
+ } finally {
1012
+ p.value = !1;
1013
+ }
1014
+ }
1015
+ async function ce() {
1016
+ var t;
1017
+ if (!((t = f.currentBusiness.value) != null && t._id)) return;
1018
+ await q(C.value);
1019
+ const e = Math.max(1, Math.ceil(L.value / _e));
1020
+ C.value > e && (C.value = e, await q(C.value));
1021
+ }
1022
+ const Y = b(), H = b(!1), oe = b(!1);
1023
+ async function pe() {
1024
+ if (!Y.value) return;
1025
+ const e = await Y.value.validate();
1026
+ if (!e) return;
1027
+ const t = _.value === ee.ADD;
1028
+ await se.minor(async () => {
1029
+ await (t ? Fe.createTeamMember(e) : Fe.updateTeamMember(ae.value.id, e)), ve(), await re(), await ce();
1030
+ }, {
1031
+ successMessage: t ? a("team.addMember.successMessage", {
1032
+ memberName: e.name
1033
+ }) : a("team.updateMember.successMessage", {
1034
+ memberName: e.name
1035
+ }),
1036
+ isLoading: H
1037
+ }), _.value = ee.CLOSED;
1038
+ }
1039
+ async function $e() {
1040
+ await g.readPermissionSets();
1041
+ }
1042
+ async function re() {
1043
+ await S.readPermissionAssignments();
1044
+ }
1045
+ let Be = !1;
1046
+ async function ns({
1047
+ pageIndex: e
1048
+ }) {
1049
+ var t;
1050
+ if ((t = f.currentBusiness.value) != null && t._id && !Be && !(e === 0 && C.value === 1 && j.value.length > 0)) {
1051
+ Be = !0, C.value = e + 1;
1052
+ try {
1053
+ await q(C.value);
1054
+ } finally {
1055
+ Be = !1;
1056
+ }
1057
+ }
1058
+ }
1059
+ const is = fs(E, () => {
1060
+ W.value = E.value;
1061
+ });
1062
+ return ds(is), fe(c, async () => {
1063
+ var e;
1064
+ C.value = 1, h.value = !1, (e = f.currentBusiness.value) != null && e._id && (await q(1), h.value = !0);
1065
+ }, {
1066
+ immediate: !0
1067
+ }), fe(f.currentBusiness, async () => {
1068
+ var e;
1069
+ if ((e = f.currentBusiness.value) != null && e._id)
1070
+ try {
1071
+ await Promise.all([A.readRestaurants(), $e(), re(), n(), Q()]);
1072
+ } catch (t) {
1073
+ console.error("Failed to load team member dependencies:", t), $.open({
1074
+ message: t instanceof Error ? t.message : String(t),
1075
+ type: "error"
1076
+ });
1077
+ }
1078
+ }, {
1079
+ immediate: !0
1080
+ }), R({
1081
+ create: Re
1082
+ }), (e, t) => {
1083
+ var Ue;
1084
+ const U = F("FmSearch"), P = F("FmTable"), ne = F("FmIcon"), ie = F("FmButton"), Ce = F("FmSideSheet");
1085
+ return y(), N(Ne, null, [u("div", Pt, [u("div", kt, [r(xe).xs ? (y(), N("div", Ct, [d(U, {
1086
+ modelValue: E.value,
1087
+ "onUpdate:modelValue": t[4] || (t[4] = (M) => E.value = M),
1088
+ class: "w-[320px] xs:w-full xs:mt-8",
1089
+ placeholder: r(a)("team.search.placeholder")
1090
+ }, null, 8, ["modelValue", "placeholder"]), u("div", Mt, [d(ye, {
1091
+ modelValue: le.value,
1092
+ "onUpdate:modelValue": t[5] || (t[5] = (M) => le.value = M),
1093
+ multiple: "",
1094
+ items: te.value,
1095
+ variant: "dark",
1096
+ "selected-prefix": r(a)("team.table.columns.restaurant"),
1097
+ placeholder: r(a)("team.table.columns.restaurant"),
1098
+ class: "!w-auto"
1099
+ }, null, 8, ["modelValue", "items", "selected-prefix", "placeholder"]), d(ye, {
1100
+ modelValue: Z.value,
1101
+ "onUpdate:modelValue": t[6] || (t[6] = (M) => Z.value = M),
1102
+ multiple: "",
1103
+ variant: "dark",
1104
+ items: T.value,
1105
+ "selected-prefix": r(a)("team.filter.selected_permission_prefix"),
1106
+ placeholder: r(a)("team.filter.permission_placeholder")
1107
+ }, null, 8, ["modelValue", "items", "selected-prefix", "placeholder"]), d(ye, {
1108
+ modelValue: s.value,
1109
+ "onUpdate:modelValue": t[7] || (t[7] = (M) => s.value = M),
1110
+ multiple: "",
1111
+ variant: "dark",
1112
+ items: G.value,
1113
+ "selected-prefix": r(a)("team.filter.selected_assigned_role_prefix"),
1114
+ placeholder: r(a)("team.filter.assigned_role_placeholder")
1115
+ }, null, 8, ["modelValue", "items", "selected-prefix", "placeholder"])])])) : (y(), N("div", Rt, [u("div", $t, [d(ye, {
1116
+ modelValue: le.value,
1117
+ "onUpdate:modelValue": t[0] || (t[0] = (M) => le.value = M),
1118
+ multiple: "",
1119
+ items: te.value,
1120
+ variant: "dark",
1121
+ "selected-prefix": r(a)("team.table.columns.restaurant"),
1122
+ placeholder: r(a)("team.table.columns.restaurant"),
1123
+ class: "!w-auto"
1124
+ }, null, 8, ["modelValue", "items", "selected-prefix", "placeholder"]), d(ye, {
1125
+ modelValue: Z.value,
1126
+ "onUpdate:modelValue": t[1] || (t[1] = (M) => Z.value = M),
1127
+ multiple: "",
1128
+ variant: "dark",
1129
+ items: T.value,
1130
+ "selected-prefix": r(a)("team.filter.selected_permission_prefix"),
1131
+ placeholder: r(a)("team.filter.permission_placeholder")
1132
+ }, null, 8, ["modelValue", "items", "selected-prefix", "placeholder"]), d(ye, {
1133
+ modelValue: s.value,
1134
+ "onUpdate:modelValue": t[2] || (t[2] = (M) => s.value = M),
1135
+ multiple: "",
1136
+ variant: "dark",
1137
+ items: G.value,
1138
+ "selected-prefix": r(a)("team.filter.selected_assigned_role_prefix"),
1139
+ placeholder: r(a)("team.filter.assigned_role_placeholder")
1140
+ }, null, 8, ["modelValue", "items", "selected-prefix", "placeholder"])]), d(U, {
1141
+ modelValue: E.value,
1142
+ "onUpdate:modelValue": t[3] || (t[3] = (M) => E.value = M),
1143
+ class: "w-[320px] xs:w-full xs:mt-8",
1144
+ autofocus: "",
1145
+ placeholder: r(a)("team.search.placeholder")
1146
+ }, null, 8, ["modelValue", "placeholder"])])), (Ue = r(f).currentBusiness.value) != null && Ue._id ? (y(), z(ys, {
1147
+ key: 2
1148
+ }, {
1149
+ default: ue(() => [u("div", Nt, [h.value ? K("", !0) : (y(), z(_s, {
1150
+ key: 0
1151
+ })), h.value ? (y(), z(Us, {
1152
+ key: 1,
1153
+ "is-loading": p.value,
1154
+ "is-empty": L.value === 0,
1155
+ title: r(a)("team.emptyState.title"),
1156
+ subtitle: r(a)("team.emptyState.description")
1157
+ }, {
1158
+ default: ue(() => [(y(), z(P, {
1159
+ key: c.value,
1160
+ "column-defs": v,
1161
+ "row-data": j.value,
1162
+ "page-size": _e,
1163
+ "page-count": Math.ceil(L.value / _e),
1164
+ "row-count": L.value,
1165
+ "fetch-fn": ns,
1166
+ "hide-footer": L.value <= _e,
1167
+ loading: p.value,
1168
+ "pin-header-row": "",
1169
+ onRowClick: t[8] || (t[8] = (M) => B(r(ge).Update, M.original))
1170
+ }, null, 8, ["row-data", "page-count", "row-count", "hide-footer", "loading"]))]),
1171
+ _: 1
1172
+ }, 8, ["is-loading", "is-empty", "title", "subtitle"])) : K("", !0)])]),
1173
+ _: 1
1174
+ })) : K("", !0)])]), d(Ce, {
1175
+ "model-value": w.value,
1176
+ "max-width": 960,
1177
+ "close-button": !1,
1178
+ "onUpdate:modelValue": De,
1179
+ "onOn:clickedAway": r(be)
1180
+ }, {
1181
+ "side-sheet-header": ue(() => [u("div", At, [u("p", Et, k(ke.value), 1), d(ne, {
1182
+ name: "close",
1183
+ size: "md",
1184
+ class: "cursor-pointer",
1185
+ onClick: r(be)
1186
+ }, null, 8, ["onClick"])])]),
1187
+ "side-sheet-footer": ue(() => [u("div", Dt, [d(ie, {
1188
+ label: Ee.value,
1189
+ size: "md",
1190
+ variant: "primary",
1191
+ "is-loading": H.value,
1192
+ disabled: H.value,
1193
+ onClick: Ve(pe, ["prevent"])
1194
+ }, null, 8, ["label", "is-loading", "disabled"]), d(ie, {
1195
+ label: r(a)("common.cancel"),
1196
+ size: "md",
1197
+ variant: "secondary",
1198
+ disabled: H.value,
1199
+ onClick: de
1200
+ }, null, 8, ["label", "disabled"])])]),
1201
+ default: ue(() => [w.value ? (y(), z(It, {
1202
+ key: 0,
1203
+ ref_key: "memberForm",
1204
+ ref: Y,
1205
+ initialValue: ae.value,
1206
+ loading: O.value,
1207
+ class: "gap-8"
1208
+ }, null, 8, ["initialValue", "loading"])) : K("", !0)]),
1209
+ _: 1
1210
+ }, 8, ["model-value", "onOn:clickedAway"])], 64);
1211
+ };
1212
+ }
1213
+ });
1214
+ export {
1215
+ sa as default
1216
+ };