@feedmepos/mf-hrm-portal 1.1.3-dev → 1.1.3-dev.10

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 (49) hide show
  1. package/dist/AuditLogList-BghaBoJj.js +436 -0
  2. package/dist/EmployeeList-C4knb1ZM.js +626 -0
  3. package/dist/{Main-DGymQNz9.js → Main-BGcdVWrj.js} +10 -9
  4. package/dist/{Main-BqhrqOzx.js → Main-DYuuBLTj.js} +28 -27
  5. package/dist/PermissionSetList-DPKmbnO4.js +323 -0
  6. package/dist/PortalPermissionEditor.vue_vue_type_script_setup_true_lang-nbk54pp5.js +3092 -0
  7. package/dist/RoleList-CWUkSfcS.js +494 -0
  8. package/dist/TeamMemberList-BDB9zWwa.js +965 -0
  9. package/dist/{TimesheetList-hgT9DrHd.js → TimesheetList-CqVVoydR.js} +25 -24
  10. package/dist/api/index.d.ts +5 -0
  11. package/dist/api/report-query/index.d.ts +5 -0
  12. package/dist/api/team/index.d.ts +2 -5
  13. package/dist/{app-CcbYGJ22.js → app-C04LPGZa.js} +1606 -918
  14. package/dist/app.js +4 -4
  15. package/dist/composables/useReportPermissions.d.ts +14 -0
  16. package/dist/{dayjs.min-CgN1oBQf.js → dayjs.min-CKv07Hiu.js} +1 -1
  17. package/dist/employee-DyW4lRCb.js +144 -0
  18. package/dist/helpers/permission-set.d.ts +37 -0
  19. package/dist/helpers/rule.d.ts +1 -1
  20. package/dist/index-CIz_Nsy5.js +10340 -0
  21. package/dist/index-DGq_eY85.js +827 -0
  22. package/dist/{lodash-7Am6_Zd3.js → lodash-r0Tf8VGX.js} +1 -1
  23. package/dist/stores/permission-set.d.ts +15 -0
  24. package/dist/stores/team.d.ts +4 -1
  25. package/dist/style.css +1 -1
  26. package/dist/team-CSB4_BXX.js +29 -0
  27. package/dist/{timesheet-DKhEeLe7.js → timesheet-CTS0MzUs.js} +2 -2
  28. package/dist/tsconfig.app.tsbuildinfo +1 -1
  29. package/dist/types/audit-log.d.ts +1 -19
  30. package/dist/types/permission-set.d.ts +4 -0
  31. package/dist/types/report-query.d.ts +6 -0
  32. package/dist/{useAppStore-DOSLuH24.js → useAppStore-CWtHdJdl.js} +34 -46
  33. package/dist/{useLoading-BA-GSZ3R.js → useLoading-gYEFsA3E.js} +1 -1
  34. package/dist/useReportPermissions--n283f22.js +65 -0
  35. package/dist/views/audit-log/locales/index.d.ts +84 -0
  36. package/dist/views/team/locales/index.d.ts +32 -8
  37. package/package.json +4 -2
  38. package/dist/AuditLogList-DNQh1rE9.js +0 -316
  39. package/dist/EmployeeList-zU7fmC4c.js +0 -607
  40. package/dist/PortalPermissionEditor.vue_vue_type_script_setup_true_lang-BvjXcknf.js +0 -3050
  41. package/dist/RoleList-jbZqer7A.js +0 -496
  42. package/dist/RolePermissionList-Dd8ks5i7.js +0 -285
  43. package/dist/TeamMemberList-uamoOFIV.js +0 -949
  44. package/dist/employee-khk560IC.js +0 -172
  45. package/dist/index-D5sdamN5.js +0 -8411
  46. package/dist/team-CFyc6tnm.js +0 -26
  47. package/dist/types/permission.d.ts +0 -1
  48. /package/dist/views/team/{role/RolePermissionForm.vue.d.ts → permission-set/PermissionSetForm.vue.d.ts} +0 -0
  49. /package/dist/views/team/{role/RolePermissionList.vue.d.ts → permission-set/PermissionSetList.vue.d.ts} +0 -0
@@ -0,0 +1,965 @@
1
+ import { defineComponent as le, ref as x, resolveComponent as h, createBlock as I, openBlock as f, withCtx as E, createElementVNode as i, renderSlot as ve, createCommentVNode as q, withModifiers as we, nextTick as ke, createElementBlock as L, normalizeClass as $e, createTextVNode as Pe, toDisplayString as B, computed as P, Fragment as ie, renderList as be, createVNode as u, unref as r, watch as Ie, isRef as ye, createSlots as Oe } from "vue";
2
+ import { useI18n as ue, useCoreStore as me, baseClientInstance as _e, RestaurantSelector as ge } from "@feedmepos/mf-common";
3
+ import { useBreakpoints as Re, useSnackbar as Me, useDialog as Ae, components as Ve } from "@feedmepos/ui-library";
4
+ import { _ as Ee, S as xe } from "./SelectFilter-NbXrJ4iH.js";
5
+ import { s as Le, w as je, _ as Te } from "./app-C04LPGZa.js";
6
+ import { _ as ze } from "./index.vue_vue_type_script_setup_true_lang-Vc5ARO29.js";
7
+ import { u as Ce } from "./useSearch-B6WK1LBB.js";
8
+ import { u as Ke } from "./useLoading-gYEFsA3E.js";
9
+ import { g as Fe, l as Ne, u as Be, m as qe, n as Ge, o as ce, v as Ue, w as We, x as Je, y as Qe, t as pe } from "./index-CIz_Nsy5.js";
10
+ import "./index-DGq_eY85.js";
11
+ import { u as De } from "./useAppStore-CWtHdJdl.js";
12
+ /* empty css */
13
+ import { _ as Xe, a as Ye } from "./PortalPermissionEditor.vue_vue_type_script_setup_true_lang-nbk54pp5.js";
14
+ import { u as Ze } from "./team-CSB4_BXX.js";
15
+ const He = /* @__PURE__ */ le({
16
+ __name: "BottomSheetMenu",
17
+ setup(l) {
18
+ const c = x(!1);
19
+ async function e() {
20
+ await ke(), c.value = !c.value;
21
+ }
22
+ return (b, m) => {
23
+ const D = h("FmButton"), R = h("FmBottomSheet");
24
+ return f(), I(R, {
25
+ modelValue: c.value,
26
+ "onUpdate:modelValue": m[1] || (m[1] = (y) => c.value = y),
27
+ "dismiss-away": "",
28
+ "no-header": "",
29
+ "z-index": 110
30
+ }, {
31
+ "bottom-sheet-button": E(() => [
32
+ b.$slots.button ? q("", !0) : (f(), I(D, {
33
+ key: 0,
34
+ icon: "more_vert",
35
+ variant: "tertiary",
36
+ onClick: we(e, ["stop"])
37
+ })),
38
+ ve(b.$slots, "button")
39
+ ]),
40
+ default: E(() => [
41
+ i("div", {
42
+ onClick: m[0] || (m[0] = (y) => c.value = !1)
43
+ }, [
44
+ ve(b.$slots, "default")
45
+ ])
46
+ ]),
47
+ _: 3
48
+ }, 8, ["modelValue"]);
49
+ };
50
+ }
51
+ }), et = { class: "py-8 px-12 hover:bg-fm-color-neutral-gray-100" }, tt = /* @__PURE__ */ le({
52
+ __name: "BottomSheetMenuItem",
53
+ props: {
54
+ label: {},
55
+ icon: {},
56
+ disabled: { type: Boolean },
57
+ itemClass: {}
58
+ },
59
+ setup(l) {
60
+ const c = l;
61
+ return (e, b) => {
62
+ const m = h("FmIcon");
63
+ return f(), L("div", et, [
64
+ e.$slots.content ? q("", !0) : (f(), L("div", {
65
+ key: 0,
66
+ class: $e(["flex items-center", {
67
+ "text-fm-color-typo-disabled": c.disabled,
68
+ "cursor-pointer": !c.disabled,
69
+ "cursor-not-allowed": c.disabled,
70
+ [c.itemClass || ""]: c.itemClass && !c.disabled
71
+ }])
72
+ }, [
73
+ l.icon ? (f(), I(m, {
74
+ key: 0,
75
+ name: l.icon
76
+ }, null, 8, ["name"])) : q("", !0),
77
+ Pe(" " + B(l.label), 1)
78
+ ], 2)),
79
+ ve(e.$slots, "content")
80
+ ]);
81
+ };
82
+ }
83
+ }), st = /* @__PURE__ */ le({
84
+ __name: "ResponsiveContextMenu",
85
+ props: {
86
+ items: {}
87
+ },
88
+ setup(l) {
89
+ const c = Re(), e = P(() => c.breakpoints.value.xs);
90
+ return (b, m) => {
91
+ const D = h("FmButton"), R = h("FmMenuItem"), y = h("FmMenu");
92
+ return e.value ? (f(), I(He, { key: 0 }, {
93
+ default: E(() => [
94
+ (f(!0), L(ie, null, be(l.items, ({ icon: v, label: p, disabled: g, itemClass: M, onClick: C }) => (f(), I(tt, {
95
+ key: p,
96
+ icon: v,
97
+ label: p,
98
+ disabled: g,
99
+ itemClass: M,
100
+ onClick: () => {
101
+ !g && (C == null || C());
102
+ }
103
+ }, null, 8, ["icon", "label", "disabled", "itemClass", "onClick"]))), 128))
104
+ ]),
105
+ _: 1
106
+ })) : (f(), I(y, {
107
+ key: 1,
108
+ "stop-click-propagation": "",
109
+ shift: !0
110
+ }, {
111
+ "menu-button": E(() => [
112
+ u(D, {
113
+ type: "button",
114
+ variant: "tertiary",
115
+ icon: "more_vert",
116
+ "text-color": "neutral-gray-400",
117
+ size: "md"
118
+ })
119
+ ]),
120
+ default: E(() => [
121
+ (f(!0), L(ie, null, be(l.items, ({ label: v, disabled: p, itemClass: g, onClick: M }) => (f(), I(R, {
122
+ key: v,
123
+ disabled: p,
124
+ label: v,
125
+ onClick: () => {
126
+ !p && (M == null || M());
127
+ }
128
+ }, {
129
+ label: E(() => [
130
+ i("span", {
131
+ class: $e(p ? "text-fm-color-typo-disabled" : g)
132
+ }, B(v), 3)
133
+ ]),
134
+ _: 2
135
+ }, 1032, ["disabled", "label", "onClick"]))), 128))
136
+ ]),
137
+ _: 1
138
+ }));
139
+ };
140
+ }
141
+ });
142
+ var re = /* @__PURE__ */ ((l) => (l.Update = "Update", l.Remove = "Remove", l))(re || {});
143
+ const lt = { class: "w-full flex flex-col gap-16" }, at = { class: "flex items-center gap-16" }, ot = { class: "space-y-4 min-w-0 flex-1" }, nt = { class: "text-fm-color-typo-secondary fm-typo-en-body-lg-400" }, rt = { class: "fm-typo-en-body-lg-600 truncate" }, it = { class: "w-full flex gap-16 items-center" }, mt = { class: "flex-1 flex flex-col gap-4 min-w-0" }, ut = { class: "text-fm-color-typo-secondary fm-typo-en-body-lg-400" }, dt = { class: "fm-typo-en-body-lg-600 truncate" }, ct = { class: "flex-1 flex flex-col gap-4 min-w-0" }, pt = { class: "text-fm-color-typo-secondary fm-typo-en-body-lg-400" }, ft = { class: "fm-typo-en-body-lg-600 truncate" }, vt = /* @__PURE__ */ le({
144
+ __name: "MemberInfo",
145
+ props: {
146
+ data: {}
147
+ },
148
+ setup(l) {
149
+ const { t: c } = ue();
150
+ return (e, b) => {
151
+ const m = h("FmAvatar");
152
+ return f(), L("div", lt, [
153
+ i("div", at, [
154
+ u(m, {
155
+ size: "xl",
156
+ initials: l.data.name
157
+ }, null, 8, ["initials"]),
158
+ i("div", ot, [
159
+ i("p", nt, B(r(c)("team.memberForm.memberInfo.memberName")), 1),
160
+ i("p", rt, B(l.data.name || "--"), 1)
161
+ ])
162
+ ]),
163
+ i("div", it, [
164
+ i("div", mt, [
165
+ i("p", ut, B(r(c)("team.memberForm.memberInfo.mobileNumber")), 1),
166
+ i("p", dt, B(l.data.phoneNumber || "--"), 1)
167
+ ]),
168
+ i("div", ct, [
169
+ i("p", pt, B(r(c)("team.memberForm.memberInfo.emailAddress")), 1),
170
+ i("p", ft, B(l.data.email || "--"), 1)
171
+ ])
172
+ ])
173
+ ]);
174
+ };
175
+ }
176
+ }), Se = {
177
+ async readPermissionUserByPhoneNo(l) {
178
+ var e;
179
+ const { currentBusiness: c } = me();
180
+ return Fe(
181
+ await _e("/").get(`/user/b/${(e = c.value) == null ? void 0 : e._id}/phone/${l}`)
182
+ );
183
+ },
184
+ async readPermissionUserByEmail(l) {
185
+ var e;
186
+ const { currentBusiness: c } = me();
187
+ return Fe(
188
+ await _e("/").get(`/user/b/${(e = c.value) == null ? void 0 : e._id}/email/${l}`)
189
+ );
190
+ }
191
+ }, bt = { class: "flex flex-col gap-24 w-full" }, yt = {
192
+ key: 0,
193
+ class: "flex flex-col gap-8"
194
+ }, ht = { class: "user-info-icon user-info-icon--lg" }, _t = { class: "flex-1 overflow-hidden" }, gt = { class: "profile-displayName" }, Vt = { class: "profile-email" }, xt = { class: "profile-phone" }, Ft = { key: 2 }, Ut = /* @__PURE__ */ le({
195
+ __name: "PortalUserSearcher",
196
+ emits: ["invite"],
197
+ setup(l, { emit: c }) {
198
+ const e = c, { t: b } = ue(), m = Me(), D = me(), R = x("phone"), y = x(""), v = x(""), p = x();
199
+ async function g() {
200
+ if (!y.value && !v.value) {
201
+ m.open({
202
+ type: "error",
203
+ title: b("team.memberForm.searchUser.emptyError")
204
+ });
205
+ return;
206
+ }
207
+ const V = R.value === "phone" ? await Se.readPermissionUserByPhoneNo(y.value.replace(/ /g, "")) : await Se.readPermissionUserByEmail(v.value);
208
+ V || m.open({
209
+ type: "error",
210
+ title: b("team.memberForm.searchUser.userNotFound")
211
+ }), p.value = V;
212
+ }
213
+ const M = P(() => {
214
+ var U;
215
+ let V = ((U = p.value) == null ? void 0 : U.displayName) ?? "";
216
+ V || (V = "Feed Me");
217
+ const [F, j] = V.split(" ");
218
+ return j ? `${F[0]}${j[0]}` : F.slice(0, 2);
219
+ }), C = x(!1);
220
+ function ae(V) {
221
+ e("invite", V), C.value = !0;
222
+ }
223
+ function oe() {
224
+ C.value = !1;
225
+ }
226
+ return (V, F) => {
227
+ var _, O, T;
228
+ const j = h("FmRadio"), U = h("FmPhoneNumber"), Q = h("FmTextField"), a = h("FmRadioGroup"), n = h("FmButton");
229
+ return f(), L("div", bt, [
230
+ C.value ? q("", !0) : (f(), L("div", yt, [
231
+ u(a, {
232
+ modelValue: R.value,
233
+ "onUpdate:modelValue": F[2] || (F[2] = (k) => R.value = k)
234
+ }, {
235
+ default: E(() => [
236
+ u(j, {
237
+ value: "phone",
238
+ label: r(b)("team.memberForm.searchUser.phoneNumber")
239
+ }, null, 8, ["label"]),
240
+ R.value === "phone" ? (f(), I(U, {
241
+ key: 0,
242
+ modelValue: y.value,
243
+ "onUpdate:modelValue": F[0] || (F[0] = (k) => y.value = k),
244
+ "extra-country-codes": r(D).enabledCountries.value,
245
+ class: "ml-8"
246
+ }, null, 8, ["modelValue", "extra-country-codes"])) : q("", !0),
247
+ u(j, {
248
+ value: "email",
249
+ label: r(b)("team.memberForm.searchUser.email")
250
+ }, null, 8, ["label"]),
251
+ R.value === "email" ? (f(), I(Q, {
252
+ key: 1,
253
+ modelValue: v.value,
254
+ "onUpdate:modelValue": F[1] || (F[1] = (k) => v.value = k),
255
+ placeholder: r(b)("team.memberForm.searchUser.emailPlaceholder"),
256
+ class: "ml-8"
257
+ }, null, 8, ["modelValue", "placeholder"])) : q("", !0)
258
+ ]),
259
+ _: 1
260
+ }, 8, ["modelValue"]),
261
+ u(n, {
262
+ label: r(b)("team.memberForm.searchUser.search"),
263
+ variant: "secondary",
264
+ onClick: g
265
+ }, null, 8, ["label"])
266
+ ])),
267
+ p.value ? (f(), L("div", {
268
+ key: 1,
269
+ class: "profile-menu--profile cursor-pointer hover:bg-fm-color-opacity-sm",
270
+ onClick: F[3] || (F[3] = (k) => ae(p.value))
271
+ }, [
272
+ i("div", ht, B(M.value), 1),
273
+ i("div", _t, [
274
+ i("p", gt, B((_ = p.value) == null ? void 0 : _.displayName), 1),
275
+ i("p", Vt, B((O = p.value) == null ? void 0 : O.email), 1),
276
+ i("p", xt, B((T = p.value) == null ? void 0 : T.phoneNumber), 1)
277
+ ])
278
+ ])) : q("", !0),
279
+ C.value ? (f(), L("div", Ft, [
280
+ u(n, {
281
+ label: r(b)("team.memberForm.searchUser.changeUser"),
282
+ variant: "secondary",
283
+ onClick: oe
284
+ }, null, 8, ["label"])
285
+ ])) : q("", !0)
286
+ ]);
287
+ };
288
+ }
289
+ }), St = /* @__PURE__ */ Ee(Ut, [["__scopeId", "data-v-c2c7ed35"]]), wt = { class: "flex flex-col gap-40" }, kt = { class: "flex items-center" }, $t = { class: "flex-1 flex flex-col" }, Pt = { class: "fm-typo-en-title-sm-600" }, It = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Rt = { class: "flex flex-row gap-16" }, Mt = { class: "flex flex-col gap-8" }, Ct = { class: "fm-typo-en-body-lg-400" }, Nt = { class: "p-16 fm-corner-radius-lg border border-fm-color-neutral-gray-200" }, fe = 4, Bt = /* @__PURE__ */ le({
290
+ __name: "TeamMemberMasterUser",
291
+ props: {
292
+ modelValue: {
293
+ type: Object,
294
+ default: void 0
295
+ },
296
+ fallbackName: {
297
+ type: String,
298
+ required: !0
299
+ },
300
+ fallbackPasscode: {
301
+ type: String,
302
+ default: void 0
303
+ },
304
+ restaurants: {
305
+ type: Array,
306
+ required: !0
307
+ },
308
+ roles: {
309
+ type: Array,
310
+ required: !0
311
+ }
312
+ },
313
+ emits: ["update:model-value"],
314
+ setup(l, { emit: c }) {
315
+ const e = l, b = c, { t: m } = ue(), { searchKey: D, filter: R } = Ce(""), y = x(!0), v = x([]), p = P(() => {
316
+ const a = {};
317
+ return e.roles.forEach((n) => {
318
+ a[n.value] = n.label;
319
+ }), a;
320
+ }), g = P(() => {
321
+ var n;
322
+ const a = {};
323
+ return (n = e.modelValue) == null || n.roles.forEach((_) => {
324
+ a[_.restaurantId] = _.roleId;
325
+ }), a;
326
+ }), M = P(() => e.restaurants.filter((a) => R([a.profile.name, a.profile.code, ae(a._id)])).map((a) => ({
327
+ label: `${a.profile.code ? a.profile.code + "-" : ""}${a.profile.name}`,
328
+ value: a._id,
329
+ slot: `checkbox-${a._id}-bottom`,
330
+ disable: e.roles.filter((n) => !n.disabled).length === 0,
331
+ roleOptions: e.roles
332
+ }))), C = P(() => {
333
+ const a = e.roles.find((n) => !n.disabled);
334
+ return a ? a.value : null;
335
+ });
336
+ function ae(a) {
337
+ const n = g.value[a] ?? "";
338
+ return p.value[n] || "";
339
+ }
340
+ function oe(a) {
341
+ a ? e.modelValue || b("update:model-value", {
342
+ code: "",
343
+ name: e.fallbackName,
344
+ roles: [],
345
+ passcode: e.fallbackPasscode || ""
346
+ }) : b("update:model-value", void 0);
347
+ }
348
+ function V(a, n) {
349
+ if (!e.modelValue || a === "passcode" && e.modelValue.passcode === n)
350
+ return;
351
+ const _ = Ne(e.modelValue);
352
+ _[a] = n, b("update:model-value", _);
353
+ }
354
+ function F(a) {
355
+ V(
356
+ "roles",
357
+ a.map((n) => {
358
+ var T, k, Y;
359
+ const _ = (k = (T = M.value.find((z) => z.value === n)) == null ? void 0 : T.roleOptions.find((z) => !z.disabled)) == null ? void 0 : k.value, O = (Y = e.modelValue) == null ? void 0 : Y.roles.find((z) => z.restaurantId === n);
360
+ return {
361
+ restaurantId: n,
362
+ roleId: (O == null ? void 0 : O.roleId) || _
363
+ };
364
+ })
365
+ );
366
+ }
367
+ function j(a, n) {
368
+ V("roles", [
369
+ ...e.modelValue.roles.filter(
370
+ (_) => _.restaurantId !== a
371
+ ),
372
+ {
373
+ restaurantId: a,
374
+ roleId: n
375
+ }
376
+ ]);
377
+ }
378
+ function U() {
379
+ y.value && (y.value = !1, v.value = [], V("passcode", ""));
380
+ }
381
+ Ie(
382
+ () => {
383
+ var a;
384
+ return (a = e.modelValue) == null ? void 0 : a.passcode;
385
+ },
386
+ (a) => {
387
+ a && a.length === fe ? (v.value = a.split(""), y.value = !0) : (v.value = [], y.value = !1);
388
+ },
389
+ { immediate: !0 }
390
+ );
391
+ const Q = P({
392
+ get: () => {
393
+ var a;
394
+ return ((a = e.modelValue) == null ? void 0 : a.roles) ?? [];
395
+ },
396
+ set: () => {
397
+ }
398
+ });
399
+ return (a, n) => {
400
+ const _ = h("FmSwitch"), O = h("FmTextField"), T = h("FmPinField"), k = h("FmFormGroup"), Y = h("FmSearch"), z = h("FmSelect");
401
+ return f(), L("div", wt, [
402
+ i("div", kt, [
403
+ i("div", $t, [
404
+ i("div", Pt, B(r(m)("team.memberForm.masterUser.title")), 1),
405
+ i("div", It, B(r(m)("team.memberForm.masterUser.sublabel")), 1)
406
+ ]),
407
+ i("div", null, [
408
+ u(_, {
409
+ "model-value": !!l.modelValue,
410
+ value: "master-user",
411
+ "onUpdate:modelValue": oe
412
+ }, null, 8, ["model-value"])
413
+ ])
414
+ ]),
415
+ l.modelValue ? (f(), L(ie, { key: 0 }, [
416
+ i("div", Rt, [
417
+ u(O, {
418
+ "model-value": l.modelValue.code,
419
+ label: r(m)("team.memberForm.masterUser.code"),
420
+ "onUpdate:modelValue": n[0] || (n[0] = (s) => V("code", s))
421
+ }, null, 8, ["model-value", "label"]),
422
+ u(O, {
423
+ "model-value": l.modelValue.name,
424
+ class: "w-full",
425
+ label: r(m)("team.memberForm.masterUser.name"),
426
+ rules: [(s) => !!s || r(m)("team.memberForm.masterUser.nameEmptyError")],
427
+ "onUpdate:modelValue": n[1] || (n[1] = (s) => V("name", s))
428
+ }, null, 8, ["model-value", "label", "rules"])
429
+ ]),
430
+ i("div", Mt, [
431
+ i("div", Ct, B(r(m)("team.memberForm.masterUser.passcode")), 1),
432
+ u(k, {
433
+ modelValue: v.value,
434
+ "onUpdate:modelValue": n[4] || (n[4] = (s) => v.value = s),
435
+ rules: [
436
+ (s) => (s == null ? void 0 : s.filter((d) => !!d).length) !== fe ? r(m)("team.memberForm.masterUser.passcodeRequired") : !0
437
+ ]
438
+ }, {
439
+ default: E(() => [
440
+ (f(), I(T, {
441
+ key: `pin-field-${y.value}`,
442
+ modelValue: v.value,
443
+ "onUpdate:modelValue": n[2] || (n[2] = (s) => v.value = s),
444
+ length: fe,
445
+ masked: y.value,
446
+ onComplete: n[3] || (n[3] = (s) => V("passcode", s)),
447
+ onFocus: U
448
+ }, null, 8, ["modelValue", "masked"]))
449
+ ]),
450
+ _: 1
451
+ }, 8, ["modelValue", "rules"])
452
+ ]),
453
+ u(k, {
454
+ modelValue: Q.value,
455
+ "onUpdate:modelValue": n[6] || (n[6] = (s) => Q.value = s),
456
+ rules: [
457
+ (s) => !s || s.length === 0 ? r(m)("team.memberForm.masterUser.restaurantRequired") : s.some((d) => !d.roleId) ? r(m)("team.memberForm.masterUser.roleRequired") : !0
458
+ ]
459
+ }, {
460
+ default: E(() => [
461
+ i("div", Nt, [
462
+ u(Y, {
463
+ modelValue: r(D),
464
+ "onUpdate:modelValue": n[5] || (n[5] = (s) => ye(D) ? D.value = s : null),
465
+ placeholder: r(m)("team.memberForm.posRole.placeholder"),
466
+ class: "mb-16"
467
+ }, null, 8, ["modelValue", "placeholder"]),
468
+ u(Xe, {
469
+ "model-value": l.modelValue.roles.map((s) => s.restaurantId),
470
+ options: M.value,
471
+ min: 1,
472
+ title: r(m)("team.memberForm.masterUser.role"),
473
+ "onUpdate:modelValue": F
474
+ }, Oe({ _: 2 }, [
475
+ be(M.value, (s) => ({
476
+ name: s.slot,
477
+ fn: E(() => {
478
+ var d;
479
+ return [
480
+ i("div", null, [
481
+ u(z, {
482
+ "model-value": ((d = l.modelValue.roles.find((S) => S.restaurantId === s.value)) == null ? void 0 : d.roleId) || C.value,
483
+ items: s.roleOptions,
484
+ "onUpdate:modelValue": (S) => j(s.value, S)
485
+ }, null, 8, ["model-value", "items", "onUpdate:modelValue"])
486
+ ])
487
+ ];
488
+ })
489
+ }))
490
+ ]), 1032, ["model-value", "options", "title"])
491
+ ])
492
+ ]),
493
+ _: 1
494
+ }, 8, ["modelValue", "rules"])
495
+ ], 64)) : q("", !0)
496
+ ]);
497
+ };
498
+ }
499
+ }), Dt = { class: "flex flex-col gap-32" }, Ot = { class: "flex w-full" }, At = /* @__PURE__ */ le({
500
+ __name: "AddMemberForm",
501
+ props: {
502
+ initialValue: {
503
+ type: Object
504
+ },
505
+ roleErrorMessage: {
506
+ type: String,
507
+ default: ""
508
+ }
509
+ },
510
+ setup(l, { expose: c }) {
511
+ var k, Y, z;
512
+ const e = l, { t: b } = ue(), m = x(), D = Be(), R = P(
513
+ () => D.permissionSets.value.map((s) => ({
514
+ label: s.name,
515
+ value: s.id
516
+ }))
517
+ ), y = x(((k = e.initialValue) == null ? void 0 : k.permissionSetIds) || []), v = P(
518
+ () => qe(y.value, D.permissionSets.value)
519
+ ), p = x((Y = e.initialValue) == null ? void 0 : Y.posUser), g = x(
520
+ Ge(
521
+ ce(v.value),
522
+ ((z = e.initialValue) == null ? void 0 : z.permissions) || []
523
+ )
524
+ ), { restaurants: M } = me(), C = De().roles, ae = P(() => Ue(g.value)), oe = P(() => {
525
+ const s = ae.value;
526
+ return C.value.map(
527
+ (d) => ({
528
+ label: d.name,
529
+ value: d._id,
530
+ disabled: !!s && !s.includes(d._id)
531
+ })
532
+ );
533
+ });
534
+ function V(s) {
535
+ m.value = s;
536
+ }
537
+ function F(s) {
538
+ p.value = n(p.value, s);
539
+ }
540
+ function j() {
541
+ const s = ce(v.value), d = We(g.value);
542
+ return Je(s, d);
543
+ }
544
+ function U() {
545
+ var S, G, N, X, se, ne, Z, H, K, de;
546
+ const s = j(), d = g.value.filter((ee) => !ee.inverted);
547
+ return {
548
+ email: ((S = m.value) == null ? void 0 : S.email) ?? void 0,
549
+ phoneNumber: ((G = m.value) == null ? void 0 : G.phoneNumber) ?? void 0,
550
+ customPermissions: s,
551
+ // Deprecated: keep for backward compatibility, will be removed in the future
552
+ permissions: d.map((ee) => ({
553
+ ...ee,
554
+ subject: Le(ee.subject)
555
+ })),
556
+ permissionSetIds: y.value,
557
+ name: ((N = m.value) == null ? void 0 : N.displayName) || ((X = e.initialValue) == null ? void 0 : X.name) || "",
558
+ posUser: p.value ? {
559
+ ...p.value,
560
+ name: p.value.name || ((ne = (se = e.initialValue) == null ? void 0 : se.posUser) == null ? void 0 : ne.name) || ((Z = e.initialValue) == null ? void 0 : Z.name) || ((H = m.value) == null ? void 0 : H.displayName) || "",
561
+ code: p.value.code || ((de = (K = e.initialValue) == null ? void 0 : K.posUser) == null ? void 0 : de.code) || "",
562
+ passcode: p.value.passcode,
563
+ roles: p.value.roles.filter((ee) => !!ee.roleId)
564
+ } : void 0
565
+ };
566
+ }
567
+ const Q = x();
568
+ function a() {
569
+ g.value = ce(v.value);
570
+ }
571
+ function n(s, d) {
572
+ if (!s) return;
573
+ const S = Ue(d);
574
+ if (!S) return s;
575
+ const G = Ne(s);
576
+ return G.roles = G.roles.reduce((N, X) => (S.includes(X.roleId) && N.push(X), N), []), G;
577
+ }
578
+ async function _() {
579
+ await ke(), Q.value && Q.value.$el.scrollIntoView({ behavior: "smooth", block: "start" });
580
+ }
581
+ const O = x();
582
+ async function T() {
583
+ return (await O.value.validateInputsWithoutSubmit()).length ? null : U();
584
+ }
585
+ return c({
586
+ readFormData: U,
587
+ validate: T
588
+ }), (s, d) => {
589
+ const S = h("FmSelect"), G = h("FmForm");
590
+ return f(), I(G, {
591
+ ref_key: "formRef",
592
+ ref: O,
593
+ class: "mx-4"
594
+ }, {
595
+ default: E(() => {
596
+ var N, X, se, ne, Z, H;
597
+ return [
598
+ i("div", Dt, [
599
+ i("div", Ot, [
600
+ l.initialValue ? (f(), I(vt, {
601
+ key: 1,
602
+ data: l.initialValue
603
+ }, null, 8, ["data"])) : (f(), I(St, {
604
+ key: 0,
605
+ onInvite: d[0] || (d[0] = (K) => V(K))
606
+ }))
607
+ ]),
608
+ m.value || l.initialValue ? (f(), L(ie, { key: 0 }, [
609
+ (N = l.initialValue) != null && N.isOwner ? q("", !0) : (f(), I(S, {
610
+ key: 0,
611
+ modelValue: y.value,
612
+ "onUpdate:modelValue": [
613
+ d[1] || (d[1] = (K) => y.value = K),
614
+ a
615
+ ],
616
+ multiselect: "",
617
+ searchable: "",
618
+ "search-debounce": 300,
619
+ items: R.value,
620
+ label: r(b)("team.memberForm.permissionSet.title"),
621
+ placeholder: r(b)("team.memberForm.permissionSet.selectPlaceholder")
622
+ }, null, 8, ["modelValue", "items", "label", "placeholder"])),
623
+ (X = l.initialValue) != null && X.isOwner ? q("", !0) : (f(), I(Ye, {
624
+ key: 1,
625
+ modelValue: g.value,
626
+ "onUpdate:modelValue": d[2] || (d[2] = (K) => g.value = K),
627
+ "inherit-permissions": v.value,
628
+ onPermissionChanged: F
629
+ }, null, 8, ["modelValue", "inherit-permissions"])),
630
+ u(Bt, {
631
+ ref_key: "masterUserContentRef",
632
+ ref: Q,
633
+ modelValue: p.value,
634
+ "onUpdate:modelValue": [
635
+ d[3] || (d[3] = (K) => p.value = K),
636
+ _
637
+ ],
638
+ "fallback-name": ((se = l.initialValue) == null ? void 0 : se.name) || ((ne = m.value) == null ? void 0 : ne.displayName) || "",
639
+ "fallback-passcode": (H = (Z = l.initialValue) == null ? void 0 : Z.posUser) == null ? void 0 : H.passcode,
640
+ roles: oe.value,
641
+ restaurants: r(M)
642
+ }, null, 8, ["modelValue", "fallback-name", "fallback-passcode", "roles", "restaurants"])
643
+ ], 64)) : q("", !0)
644
+ ])
645
+ ];
646
+ }),
647
+ _: 1
648
+ }, 512);
649
+ };
650
+ }
651
+ }), Et = {
652
+ class: "space-y-24"
653
+ }, Lt = {
654
+ class: "space-y-8"
655
+ }, jt = {
656
+ class: "xs:hidden flex w-full items-start justify-between px-16"
657
+ }, Tt = {
658
+ class: "flex items-start gap-8"
659
+ }, zt = {
660
+ class: "space-y-4 hidden xs:block px-16"
661
+ }, Kt = {
662
+ class: "flex items-start gap-8"
663
+ }, qt = {
664
+ class: "flex items-center justify-start gap-8"
665
+ };
666
+ var J = /* @__PURE__ */ function(l) {
667
+ return l[l.ADD = 0] = "ADD", l[l.UPDATE = 1] = "UPDATE", l[l.CLOSED = 2] = "CLOSED", l;
668
+ }(J || {});
669
+ const ns = /* @__PURE__ */ le({
670
+ __name: "TeamMemberList",
671
+ setup(l, {
672
+ expose: c
673
+ }) {
674
+ const {
675
+ t: e
676
+ } = ue(), b = me(), m = De(), D = Me(), R = Ke(D), y = Be(), v = Qe(), p = Ze(), g = x(!0), M = ({
677
+ member: t,
678
+ className: o = ""
679
+ }) => {
680
+ const $ = {
681
+ label: e("common.update"),
682
+ onClick: () => F(re.Update, t)
683
+ }, te = {
684
+ label: e("common.remove"),
685
+ onClick: () => F(re.Remove, t),
686
+ itemClass: "text-fm-color-typo-error"
687
+ }, W = t.doc.isOwner ? [$] : [$, te];
688
+ return u(st, {
689
+ class: o,
690
+ items: W
691
+ }, null);
692
+ }, C = (t) => t.doc.isOwner ? e("team.labels.businessOwner") : t.restaurants.join(", "), ae = [{
693
+ accessorKey: "name",
694
+ header: () => e("team.table.columns.name"),
695
+ enableSorting: !1
696
+ }, {
697
+ accessorKey: "phoneNumber",
698
+ header: () => e("team.table.columns.phoneNumber"),
699
+ enableSorting: !1
700
+ }, {
701
+ accessorKey: "restaurant",
702
+ header: () => e("team.table.columns.restaurant"),
703
+ enableSorting: !1,
704
+ cell(t) {
705
+ const o = t.row.original;
706
+ return C(o);
707
+ }
708
+ }, {
709
+ accessorKey: "assignedRoles",
710
+ header: () => e("team.table.columns.assignedRoles"),
711
+ enableSorting: !1,
712
+ cell(t) {
713
+ const o = t.row.original, $ = v.getPermissionAssignmentByUserId(o.id), te = ($ == null ? void 0 : $.permissionSetIds) || o.doc.permissionSetIds || [];
714
+ return y.permissionSets.value.filter((A) => te.includes(A.id)).map((A) => A.name).join(", ");
715
+ }
716
+ }, {
717
+ accessorKey: "permission",
718
+ header: () => e("team.table.columns.permission"),
719
+ enableSorting: !1,
720
+ cell(t) {
721
+ const o = t.row.original;
722
+ return oe(o);
723
+ },
724
+ meta: {
725
+ width: "200px"
726
+ }
727
+ }, {
728
+ id: "action",
729
+ meta: {
730
+ cellClass: "pl-16",
731
+ headerContentClass: "-mx-16"
732
+ },
733
+ cell(t) {
734
+ const o = t.row.original;
735
+ return M({
736
+ member: o,
737
+ className: "flex justify-end w-full"
738
+ });
739
+ },
740
+ enableSorting: !1
741
+ }];
742
+ function oe(t) {
743
+ if (t.doc.isOwner)
744
+ return e("team.labels.businessOwner");
745
+ const o = u(Ve.FmTooltip, {
746
+ variant: "plain",
747
+ placement: "top"
748
+ }, {
749
+ default: () => u(Ve.FmIcon, {
750
+ name: "info",
751
+ class: "cursor-pointer text-fm-color-neutral-gray-300"
752
+ }, null),
753
+ content: () => u("div", null, [e("team.labels.permission"), t.permissionLabels.map(($) => u("div", null, [Pe("- "), $]))])
754
+ });
755
+ return u("div", {
756
+ class: "flex flex-row items-center gap-8"
757
+ }, [u("span", null, [e("team.labels.allowed", {
758
+ count: t.permissionLabels.length
759
+ })]), t.permissionLabels.length > 0 && o]);
760
+ }
761
+ function V(t) {
762
+ var W, A, w, he;
763
+ const o = v.getPermissionAssignmentByUserId(t.id), $ = (o == null ? void 0 : o.customPermissions) || t.permissions || [], te = (o == null ? void 0 : o.permissionSetIds) || [];
764
+ return {
765
+ id: t.id,
766
+ isOwner: t.doc.isOwner,
767
+ name: t.name,
768
+ phoneNumber: t.phoneNumber,
769
+ email: t.email,
770
+ permissions: $,
771
+ permissionSetIds: te,
772
+ posUser: t.doc.posUser ? {
773
+ code: ((W = t.doc.posUser) == null ? void 0 : W.code) ?? "",
774
+ name: ((A = t.doc.posUser) == null ? void 0 : A.name) ?? t.name,
775
+ passcode: ((w = t.doc.posUser) == null ? void 0 : w.passcode) ?? "",
776
+ roles: ((he = t.doc.posUser) == null ? void 0 : he.roles) ?? []
777
+ } : void 0
778
+ };
779
+ }
780
+ const F = (t, o) => {
781
+ if (t == re.Update) {
782
+ const $ = V(o);
783
+ _.value = $, U.value = J.UPDATE;
784
+ }
785
+ t == re.Remove && Y(o);
786
+ }, j = Ae(), U = x(J.CLOSED), Q = P(() => U.value !== J.CLOSED), a = P(() => U.value === J.ADD ? e("common.add") : e("common.update")), n = P(() => U.value === J.ADD ? e("team.actions.addMember") : e("team.actions.updateMember")), _ = x();
787
+ function O(t) {
788
+ t || (U.value = J.CLOSED);
789
+ }
790
+ function T() {
791
+ U.value = J.CLOSED;
792
+ }
793
+ const {
794
+ breakpoints: k
795
+ } = Re(), Y = (t) => {
796
+ j.open({
797
+ title: e("team.actions.removeMember"),
798
+ message: e("team.removeMember.confirmationMessage", {
799
+ memberName: t.name
800
+ }),
801
+ minWidth: k.value.lg ? 588 : 0,
802
+ primaryActions: {
803
+ text: "Remove",
804
+ close: !1,
805
+ variant: "destructive"
806
+ },
807
+ secondaryActions: {
808
+ text: "Cancel",
809
+ close: !0
810
+ }
811
+ }).onPrimary(async () => {
812
+ await R.minor(async () => {
813
+ await pe.deleteTeamMember(t.id), await Z();
814
+ }, {
815
+ successMessage: e("team.removeMember.successMessage", {
816
+ memberName: t.name
817
+ })
818
+ }), j.close();
819
+ });
820
+ }, z = () => {
821
+ _.value = null, U.value = J.ADD;
822
+ }, s = P(() => p.members), d = x(), S = x(), G = P(() => Object.values(je).map((t) => ({
823
+ label: t.label,
824
+ value: t.subject
825
+ }))), {
826
+ searchKey: N,
827
+ filter: X
828
+ } = Ce(""), se = P(() => s.value.filter((t) => {
829
+ var W;
830
+ const o = !d.value || t.managableRestaurantIds.some((A) => d.value.includes(A)), $ = ((W = t.permissions) == null ? void 0 : W.map((A) => A.subject).flat().filter(Boolean)) || [], te = !S.value || $.some((A) => S.value.includes(A));
831
+ return o && te && X([t.name, t.phoneNumber, C(t)]);
832
+ }));
833
+ async function ne() {
834
+ await m.readRoles();
835
+ }
836
+ async function Z() {
837
+ g.value = !0;
838
+ try {
839
+ await p.readTeamMembers();
840
+ } finally {
841
+ g.value = !1;
842
+ }
843
+ }
844
+ const H = x();
845
+ async function K() {
846
+ if (!H.value) return;
847
+ const t = await H.value.validate();
848
+ if (!t) return;
849
+ const o = U.value === J.ADD;
850
+ await R.minor(async () => {
851
+ await (o ? pe.createTeamMember(t) : pe.updateTeamMember(_.value.id, t)), T(), await ee(), await Z();
852
+ }, {
853
+ successMessage: o ? e("team.addMember.successMessage", {
854
+ memberName: t.name
855
+ }) : e("team.updateMember.successMessage", {
856
+ memberName: t.name
857
+ })
858
+ }), U.value = J.CLOSED;
859
+ }
860
+ async function de() {
861
+ await y.readPermissionSets();
862
+ }
863
+ async function ee() {
864
+ await v.readPermissionAssignments();
865
+ }
866
+ return Ie(b.currentBusiness, async () => {
867
+ var t;
868
+ (t = b.currentBusiness.value) != null && t._id && (await de(), await ee(), Z(), ne());
869
+ }, {
870
+ immediate: !0
871
+ }), c({
872
+ create: z
873
+ }), (t, o) => {
874
+ const $ = h("FmSearch"), te = h("FmTable"), W = h("FmButton"), A = h("FmSideSheet");
875
+ return f(), L(ie, null, [i("div", Et, [i("div", Lt, [i("div", jt, [i("div", Tt, [u(r(ge), {
876
+ modelValue: d.value,
877
+ "onUpdate:modelValue": o[0] || (o[0] = (w) => d.value = w),
878
+ "managable-only": !1,
879
+ multiple: "",
880
+ variant: "dark",
881
+ class: "!w-auto"
882
+ }, null, 8, ["modelValue"]), u(xe, {
883
+ modelValue: S.value,
884
+ "onUpdate:modelValue": o[1] || (o[1] = (w) => S.value = w),
885
+ multiple: "",
886
+ variant: "dark",
887
+ items: G.value,
888
+ "selected-prefix": r(e)("team.filter.selected_permission_prefix"),
889
+ placeholder: r(e)("team.filter.permission_placeholder")
890
+ }, null, 8, ["modelValue", "items", "selected-prefix", "placeholder"])]), u($, {
891
+ modelValue: r(N),
892
+ "onUpdate:modelValue": o[2] || (o[2] = (w) => ye(N) ? N.value = w : null),
893
+ class: "w-[320px] xs:w-full xs:mt-8",
894
+ autofocus: "",
895
+ placeholder: r(e)("team.search.placeholder")
896
+ }, null, 8, ["modelValue", "placeholder"])]), i("div", zt, [u($, {
897
+ modelValue: r(N),
898
+ "onUpdate:modelValue": o[3] || (o[3] = (w) => ye(N) ? N.value = w : null),
899
+ class: "w-[320px] xs:w-full xs:mt-8",
900
+ autofocus: "",
901
+ placeholder: r(e)("team.search.placeholder")
902
+ }, null, 8, ["modelValue", "placeholder"]), i("div", Kt, [u(r(ge), {
903
+ modelValue: d.value,
904
+ "onUpdate:modelValue": o[4] || (o[4] = (w) => d.value = w),
905
+ "managable-only": !1,
906
+ multiple: "",
907
+ variant: "dark",
908
+ class: "!w-auto"
909
+ }, null, 8, ["modelValue"]), u(xe, {
910
+ modelValue: S.value,
911
+ "onUpdate:modelValue": o[5] || (o[5] = (w) => S.value = w),
912
+ multiple: "",
913
+ variant: "dark",
914
+ items: G.value,
915
+ "selected-prefix": r(e)("team.filter.selected_permission_prefix"),
916
+ placeholder: r(e)("team.filter.permission_placeholder")
917
+ }, null, 8, ["modelValue", "items", "selected-prefix", "placeholder"])])]), s.value.length === 0 && !g.value ? (f(), I(r(ze), {
918
+ key: 0,
919
+ title: r(e)("team.emptyState.title"),
920
+ subtitle: r(e)("team.emptyState.description")
921
+ }, null, 8, ["title", "subtitle"])) : (f(), I(Te, {
922
+ key: 1
923
+ }, {
924
+ default: E(() => [u(te, {
925
+ "column-defs": ae,
926
+ "row-data": se.value,
927
+ "page-size": se.value.length,
928
+ loading: g.value,
929
+ "pin-header-row": "",
930
+ "hide-footer": "",
931
+ onRowClick: o[6] || (o[6] = (w) => F(r(re).Update, w.original))
932
+ }, null, 8, ["row-data", "page-size", "loading"])]),
933
+ _: 1
934
+ }))])]), u(A, {
935
+ header: n.value,
936
+ "model-value": Q.value,
937
+ "max-width": 560,
938
+ "dismiss-away": "",
939
+ "onUpdate:modelValue": o[7] || (o[7] = (w) => O(w))
940
+ }, {
941
+ "side-sheet-footer": E(() => [i("div", qt, [u(W, {
942
+ label: a.value,
943
+ size: "md",
944
+ variant: "primary",
945
+ onClick: we(K, ["prevent"])
946
+ }, null, 8, ["label"]), u(W, {
947
+ label: r(e)("common.cancel"),
948
+ size: "md",
949
+ variant: "secondary",
950
+ onClick: T
951
+ }, null, 8, ["label"])])]),
952
+ default: E(() => [u(At, {
953
+ ref_key: "memberForm",
954
+ ref: H,
955
+ initialValue: _.value,
956
+ class: "gap-8"
957
+ }, null, 8, ["initialValue"])]),
958
+ _: 1
959
+ }, 8, ["header", "model-value"])], 64);
960
+ };
961
+ }
962
+ });
963
+ export {
964
+ ns as default
965
+ };