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