@feedmepos/mf-hrm-portal 1.1.4-dev.4 → 2.0.0

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