@feedmepos/mf-hrm-portal 2.0.25 → 2.1.0-dev

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