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

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