@feedmepos/mf-hrm-portal 1.1.3-dev.4 → 1.1.3-dev.7

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