@feedmepos/mf-hrm-portal 2.1.1-dev.2 → 2.1.1-dev.3

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 (83) hide show
  1. package/dist/ApprovalCodeList-BH5sgVMU.js +638 -0
  2. package/dist/AuditLogList-Q4L5Te8O.js +1145 -0
  3. package/dist/CollapsibleWrapper.vue_vue_type_script_setup_true_lang-BLJlmPVa.js +58 -0
  4. package/dist/EmployeeList-GtKmJZbf.js +899 -0
  5. package/dist/GrantUserList-CnLjOi5_.js +468 -0
  6. package/dist/Main-Cn7Dawg4.js +120 -0
  7. package/dist/{Main-B_L5flWT.js → Main-DLlpEU3j.js} +11 -9
  8. package/dist/{Main-DgemO-iy.js → Main-cskEZ3k_.js} +1033 -1035
  9. package/dist/PermissionSetList-C2fK2pTz.js +357 -0
  10. package/dist/PortalPermissionEditor.vue_vue_type_script_setup_true_lang-CMh0DL1_.js +3458 -0
  11. package/dist/{PortalUserSearcher.vue_vue_type_style_index_0_scoped_79737e32_lang-DbPzVpnG.js → PortalUserSearcher.vue_vue_type_style_index_0_scoped_a439fdd8_lang-BJp9hEfv.js} +1 -2
  12. package/dist/ResponsiveFabButton.vue_vue_type_script_setup_true_lang-Cn-3MRBO.js +38 -0
  13. package/dist/RoleList-CcuT1ERb.js +567 -0
  14. package/dist/TeamMemberList-Dfs2iNdC.js +1131 -0
  15. package/dist/{TimesheetList-C_IMtsTH.js → TimesheetList-B1H_6zfP.js} +136 -141
  16. package/dist/{TimesheetList.vue_vue_type_style_index_0_scoped_2c7a177a_lang-DGwteHIL.js → TimesheetList.vue_vue_type_style_index_0_scoped_91afda4e_lang-DeTpbaRk.js} +14 -13
  17. package/dist/{app-BW91YDke.js → app-DX-PG6wx.js} +2725 -5281
  18. package/dist/app.js +1 -1
  19. package/dist/approval-code-Q4666xp5.js +58 -0
  20. package/dist/{dayjs.min-DwQTpnVK.js → dayjs.min-BJrHE7oz.js} +1 -1
  21. package/dist/{employee-yM0kdY70.js → employee-BJcqtqLM.js} +27 -26
  22. package/dist/grant-user-CQZaTzVt.js +67 -0
  23. package/dist/{TableEmptyState.vue_vue_type_script_setup_true_lang-Ci_MVqGK.js → index.vue_vue_type_script_setup_true_lang-BVVwfd7B.js} +19 -50
  24. package/dist/iteration-Cfaqt-0s.js +7682 -0
  25. package/dist/{lodash-DLReQyP0.js → lodash-ClKqCmlZ.js} +1 -1
  26. package/dist/restaurant-YOVMuuFY.js +1876 -0
  27. package/dist/role-CR_-nBDY.js +82 -0
  28. package/dist/rule-BB-3S-2R.js +996 -0
  29. package/dist/src/api/approval-code/index.d.ts +7 -0
  30. package/dist/src/api/audit-log/index.d.ts +0 -6
  31. package/dist/src/components/CheckboxInput.vue.d.ts +1 -1
  32. package/dist/src/components/button/ResponsiveFabButton.vue.d.ts +1 -7
  33. package/dist/src/components/table/TableEmptyState.vue.d.ts +15 -7
  34. package/dist/src/composables/useBasePermission.d.ts +1 -2
  35. package/dist/src/helpers/permission-set.d.ts +4 -8
  36. package/dist/src/helpers/rule.d.ts +1 -2
  37. package/dist/src/router/shared.d.ts +3 -1
  38. package/dist/src/stores/approval-code.d.ts +140 -0
  39. package/dist/src/stores/permission-set.d.ts +3 -12
  40. package/dist/src/types/approval-code.d.ts +99 -0
  41. package/dist/src/types/audit-log.d.ts +1 -1
  42. package/dist/src/views/approval-code/ApprovalCodeList.vue.d.ts +26 -0
  43. package/dist/src/views/approval-code/components/ApprovalCodeForm.vue.d.ts +17 -0
  44. package/dist/src/views/approval-code/locales/index.d.ts +320 -0
  45. package/dist/src/views/audit-log/locales/index.d.ts +0 -296
  46. package/dist/src/views/hr/employee/EmployeeList.vue.d.ts +0 -1
  47. package/dist/src/views/pos-access/locales/index.d.ts +48 -0
  48. package/dist/src/views/team/components/BasePermission.vue.d.ts +0 -13
  49. package/dist/src/views/team/locales/index.d.ts +0 -72
  50. package/dist/style.css +1 -1
  51. package/dist/tsconfig.app.tsbuildinfo +1 -1
  52. package/dist/useAppStore-DNTlIeMv.js +93 -0
  53. package/dist/useDebounce-CWb5QR9G.js +28 -0
  54. package/dist/{useLoading-B89K5XKO.js → useLoading-BH02lYns.js} +1 -1
  55. package/dist/{useReportPermissions-Bjfhr6FD.js → useReportPermissions-ybHA26cJ.js} +3 -3
  56. package/package.json +2 -2
  57. package/dist/AuditLogList-DHiqs9G0.js +0 -1611
  58. package/dist/ConditionFormHost.vue_vue_type_script_setup_true_lang-CWqNWNdD.js +0 -387
  59. package/dist/EmployeeList-CUd3VH5h.js +0 -884
  60. package/dist/Main-DUbLeLlK.js +0 -577
  61. package/dist/PermissionSetList-BaC4lKV5.js +0 -392
  62. package/dist/PortalPermissionEditor.vue_vue_type_script_setup_true_lang-DddOxcG_.js +0 -4121
  63. package/dist/ResponsiveFabButton.vue_vue_type_script_setup_true_lang-QrqYEy8i.js +0 -42
  64. package/dist/RoleList-CThb6VEd.js +0 -684
  65. package/dist/Skeleton.vue_vue_type_script_setup_true_lang-B4PxNMwq.js +0 -16
  66. package/dist/TeamMemberList-CAw4jr1b.js +0 -1186
  67. package/dist/iteration-Dj50K6I7.js +0 -9556
  68. package/dist/rule-BJ-o-PKi.js +0 -1057
  69. package/dist/src/composables/useConditionDraft.d.ts +0 -40
  70. package/dist/src/composables/useCoverConditionOverride.d.ts +0 -61
  71. package/dist/src/helpers/business-timezone.d.ts +0 -22
  72. package/dist/src/helpers/filter.d.ts +0 -15
  73. package/dist/src/helpers/permission-reconcile.d.ts +0 -15
  74. package/dist/src/helpers/permission-reconcile.test.d.ts +0 -1
  75. package/dist/src/views/audit-log/event-line.d.ts +0 -13
  76. package/dist/src/views/audit-log/snapshot-diff.d.ts +0 -11
  77. package/dist/src/views/team/condition-builders/ConditionFormHost.vue.d.ts +0 -22
  78. package/dist/src/views/team/condition-builders/ConditionFormRenderer.vue.d.ts +0 -23
  79. package/dist/src/views/team/condition-builders/component-map.d.ts +0 -4
  80. package/dist/src/views/team/condition-builders/condition-form-dedupe.d.ts +0 -23
  81. package/dist/useAppStore-CHkGWiai.js +0 -169
  82. package/dist/useDebounce-B8ZPVS5C.js +0 -15
  83. /package/dist/src/views/{grant → pos-access}/Main.vue.d.ts +0 -0
@@ -1,1186 +0,0 @@
1
- import { defineComponent as we, resolveComponent as V, createElementBlock as D, openBlock as h, createElementVNode as m, createVNode as c, toDisplayString as R, unref as o, computed as k, ref as v, createCommentVNode as K, withCtx as ie, createBlock as z, watch as pe, Fragment as De, renderList as us, withKeys as qe, withModifiers as Fe, nextTick as ms, onUnmounted as ds, h as cs, createTextVNode as ps } from "vue";
2
- import { useI18n as Ie, useCoreStore as Oe, baseClientInstance as Ke } from "@feedmepos/mf-common";
3
- import { useSnackbar as He, useDialog as es, useBreakpoints as ss, components as Be } from "@feedmepos/ui-library";
4
- import { u as fs } from "./useDebounce-B8ZPVS5C.js";
5
- import { _ as vs, S as be } from "./SelectFilter-ATOm0hdn.js";
6
- import { v as ze, m as bs, b as hs, _ as ys, a as _s } from "./app-BW91YDke.js";
7
- import { u as gs, _ as xs } from "./useDiscardConfirm-DPhEV6v0.js";
8
- import { _ as Ss } from "./TableEmptyState.vue_vue_type_script_setup_true_lang-Ci_MVqGK.js";
9
- import { _ as Us } from "./Skeleton.vue_vue_type_script_setup_true_lang-B4PxNMwq.js";
10
- import { u as Fs } from "./useLoading-B89K5XKO.js";
11
- import { l as Se } from "./lodash-DLReQyP0.js";
12
- import { g as Ge, d as fe, u as ts } from "./iteration-Dj50K6I7.js";
13
- import { u as as, c as je, d as We, m as Ae, i as ls, p as Je, j as Vs, k as Xe, l as Ze, n as ws, o as Is, s as Ps, q as ks, v as Rs, t as Ue } from "./rule-BJ-o-PKi.js";
14
- import { u as os } from "./useAppStore-CHkGWiai.js";
15
- import { u as ns, i as $s } from "./PortalUserSearcher.vue_vue_type_style_index_0_scoped_79737e32_lang-DbPzVpnG.js";
16
- import { _ as Cs } from "./PortalPermissionEditor.vue_vue_type_script_setup_true_lang-DddOxcG_.js";
17
- var ye = /* @__PURE__ */ ((i) => (i.Update = "Update", i.Remove = "Remove", i))(ye || {});
18
- const Ve = "__unassigned__";
19
- function Qe(i) {
20
- if (!(i != null && i.length) || i[0] === Ve) return i;
21
- const $ = i.filter((n) => n !== Ve);
22
- return $.length === i.length ? i : [Ve, ...$];
23
- }
24
- const Ms = { class: "w-full flex flex-col gap-16" }, Ns = { class: "flex items-center gap-16" }, As = { class: "space-y-4 min-w-0 flex-1" }, Ds = { class: "text-fm-color-typo-secondary fm-typo-en-body-lg-400" }, Os = { class: "fm-typo-en-body-lg-600 truncate" }, Es = { class: "w-full flex gap-16 items-center" }, Bs = { class: "flex-1 flex flex-col gap-4 min-w-0" }, js = { class: "text-fm-color-typo-secondary fm-typo-en-body-lg-400" }, Ls = { class: "fm-typo-en-body-lg-600 truncate" }, Ts = { class: "flex-1 flex flex-col gap-4 min-w-0" }, qs = { class: "text-fm-color-typo-secondary fm-typo-en-body-lg-400" }, Ks = { class: "fm-typo-en-body-lg-600 truncate" }, zs = /* @__PURE__ */ we({
25
- __name: "MemberInfo",
26
- props: {
27
- data: {}
28
- },
29
- setup(i) {
30
- const { t: $ } = Ie();
31
- return (n, a) => {
32
- const f = V("FmAvatar");
33
- return h(), D("div", Ms, [
34
- m("div", Ns, [
35
- c(f, {
36
- size: "xl",
37
- name: i.data.name
38
- }, null, 8, ["name"]),
39
- m("div", As, [
40
- m("p", Ds, R(o($)("team.memberForm.memberInfo.memberName")), 1),
41
- m("p", Os, R(i.data.name || "--"), 1)
42
- ])
43
- ]),
44
- m("div", Es, [
45
- m("div", Bs, [
46
- m("p", js, R(o($)("team.memberForm.memberInfo.mobileNumber")), 1),
47
- m("p", Ls, R(i.data.phoneNumber || "--"), 1)
48
- ]),
49
- m("div", Ts, [
50
- m("p", qs, R(o($)("team.memberForm.memberInfo.emailAddress")), 1),
51
- m("p", Ks, R(i.data.email || "--"), 1)
52
- ])
53
- ])
54
- ]);
55
- };
56
- }
57
- }), Ye = {
58
- async readPermissionUserByPhoneNo(i) {
59
- var n;
60
- const { currentBusiness: $ } = Oe();
61
- return Ge(
62
- await Ke("/").get(`/user/b/${(n = $.value) == null ? void 0 : n._id}/phone/${i}`)
63
- );
64
- },
65
- async readPermissionUserByEmail(i) {
66
- var n;
67
- const { currentBusiness: $ } = Oe();
68
- return Ge(
69
- await Ke("/").get(`/user/b/${(n = $.value) == null ? void 0 : n._id}/email/${i}`)
70
- );
71
- }
72
- }, Gs = { class: "flex flex-col gap-24 w-full" }, Ws = {
73
- key: 0,
74
- class: "flex flex-col gap-8"
75
- }, Js = { class: "user-info-icon user-info-icon--lg" }, Xs = { class: "flex-1 overflow-hidden" }, Zs = { class: "profile-displayName" }, Qs = { class: "profile-email" }, Ys = { class: "profile-phone" }, Hs = { key: 2 }, et = /* @__PURE__ */ we({
76
- __name: "PortalUserSearcher",
77
- emits: ["invite"],
78
- setup(i, { emit: $ }) {
79
- const n = $, { t: a } = Ie(), f = He(), O = Oe(), { supportedCountries: w, ready: C } = ns(), le = k(() => {
80
- var F;
81
- const U = (F = O.currentCountry.value) == null ? void 0 : F.toUpperCase();
82
- return U && $s(U) ? U : void 0;
83
- }), x = v("phone"), S = v(""), p = v(""), b = v();
84
- async function ue() {
85
- if (!S.value && !p.value) {
86
- f.open({
87
- type: "error",
88
- title: a("team.memberForm.searchUser.emptyError")
89
- });
90
- return;
91
- }
92
- const U = x.value === "phone" ? await Ye.readPermissionUserByPhoneNo(S.value.replace(/ /g, "")) : await Ye.readPermissionUserByEmail(p.value);
93
- U || f.open({
94
- type: "error",
95
- title: a("team.memberForm.searchUser.userNotFound")
96
- }), b.value = U;
97
- }
98
- const G = k(() => {
99
- var l;
100
- let U = ((l = b.value) == null ? void 0 : l.displayName) ?? "";
101
- U || (U = "Feed Me");
102
- const [F, r] = U.split(" ");
103
- return r ? `${F[0]}${r[0]}` : F.slice(0, 2);
104
- }), A = v(!1);
105
- function M(U) {
106
- n("invite", U), A.value = !0;
107
- }
108
- function W() {
109
- A.value = !1;
110
- }
111
- return (U, F) => {
112
- var E, B, L;
113
- const r = V("FmRadio"), l = V("FmPhoneNumber"), y = V("FmCircularProgress"), I = V("FmTextField"), Z = V("FmRadioGroup"), J = V("FmButton");
114
- return h(), D("div", Gs, [
115
- A.value ? K("", !0) : (h(), D("div", Ws, [
116
- c(Z, {
117
- modelValue: x.value,
118
- "onUpdate:modelValue": F[2] || (F[2] = (u) => x.value = u)
119
- }, {
120
- default: ie(() => [
121
- c(r, {
122
- value: "phone",
123
- label: o(a)("team.memberForm.searchUser.phoneNumber")
124
- }, null, 8, ["label"]),
125
- x.value === "phone" && o(C) ? (h(), z(l, {
126
- key: 0,
127
- modelValue: S.value,
128
- "onUpdate:modelValue": F[0] || (F[0] = (u) => S.value = u),
129
- "default-country": le.value,
130
- "extra-country-codes": o(w),
131
- class: "ml-8"
132
- }, null, 8, ["modelValue", "default-country", "extra-country-codes"])) : x.value === "phone" ? (h(), z(y, {
133
- key: 1,
134
- class: "ml-8"
135
- })) : K("", !0),
136
- c(r, {
137
- value: "email",
138
- label: o(a)("team.memberForm.searchUser.email")
139
- }, null, 8, ["label"]),
140
- x.value === "email" ? (h(), z(I, {
141
- key: 2,
142
- modelValue: p.value,
143
- "onUpdate:modelValue": F[1] || (F[1] = (u) => p.value = u),
144
- placeholder: o(a)("team.memberForm.searchUser.emailPlaceholder"),
145
- class: "ml-8"
146
- }, null, 8, ["modelValue", "placeholder"])) : K("", !0)
147
- ]),
148
- _: 1
149
- }, 8, ["modelValue"]),
150
- c(J, {
151
- label: o(a)("team.memberForm.searchUser.search"),
152
- variant: "secondary",
153
- onClick: ue
154
- }, null, 8, ["label"])
155
- ])),
156
- b.value ? (h(), D("div", {
157
- key: 1,
158
- class: "profile-menu--profile cursor-pointer hover:bg-fm-color-opacity-sm",
159
- onClick: F[3] || (F[3] = (u) => M(b.value))
160
- }, [
161
- m("div", Js, R(G.value), 1),
162
- m("div", Xs, [
163
- m("p", Zs, R((E = b.value) == null ? void 0 : E.displayName), 1),
164
- m("p", Qs, R((B = b.value) == null ? void 0 : B.email), 1),
165
- m("p", Ys, R((L = b.value) == null ? void 0 : L.phoneNumber), 1)
166
- ])
167
- ])) : K("", !0),
168
- A.value ? (h(), D("div", Hs, [
169
- c(J, {
170
- label: o(a)("team.memberForm.searchUser.changeUser"),
171
- variant: "secondary",
172
- onClick: W
173
- }, null, 8, ["label"])
174
- ])) : K("", !0)
175
- ]);
176
- };
177
- }
178
- }), st = /* @__PURE__ */ vs(et, [["__scopeId", "data-v-79737e32"]]), tt = { class: "flex flex-col gap-40" }, at = { class: "flex items-center" }, lt = { class: "flex-1 flex flex-col" }, ot = { class: "fm-typo-en-title-sm-600" }, nt = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, rt = { class: "flex flex-row gap-16" }, it = { class: "flex flex-col gap-8" }, ut = { class: "fm-typo-en-body-lg-400" }, mt = { class: "space-y-16 rounded-lg border border-fm-color-neutral-gray-200 p-16" }, dt = { class: "fm-typo-en-title-sm-600" }, ct = { class: "space-y-16" }, pt = { class: "grid grid-cols-[minmax(0,1fr)_minmax(0,1fr)_auto] gap-16" }, ft = { class: "text-sm font-semibold text-fm-color-typo-primary" }, vt = { class: "text-sm font-semibold text-fm-color-typo-primary" }, bt = { class: "flex justify-self-end" }, ht = ["aria-label", "onClick", "onKeydown"], Le = 4, yt = /* @__PURE__ */ we({
179
- __name: "TeamMemberMasterUser",
180
- props: {
181
- modelValue: {
182
- type: Object,
183
- default: void 0
184
- },
185
- fallbackName: {
186
- type: String,
187
- required: !0
188
- },
189
- fallbackPasscode: {
190
- type: String,
191
- default: void 0
192
- },
193
- restaurants: {
194
- type: Array,
195
- required: !0
196
- },
197
- roles: {
198
- type: Array,
199
- required: !0
200
- }
201
- },
202
- emits: ["update:model-value"],
203
- setup(i, { emit: $ }) {
204
- const n = i, a = $, { t: f } = Ie(), O = v(!0), w = v([]);
205
- function C() {
206
- return { restaurantId: "", roleId: "" };
207
- }
208
- const le = k(
209
- () => {
210
- var r;
211
- return ((r = n.modelValue) == null ? void 0 : r.roles.map((l) => l.restaurantId).filter(Boolean)) ?? [];
212
- }
213
- );
214
- function x(r) {
215
- r ? n.modelValue || a("update:model-value", {
216
- code: "",
217
- name: n.fallbackName,
218
- roles: [C()],
219
- passcode: n.fallbackPasscode || ""
220
- }) : a("update:model-value", null);
221
- }
222
- function S(r, l) {
223
- if (!n.modelValue || r === "passcode" && n.modelValue.passcode === l) return;
224
- const y = fe(n.modelValue);
225
- y[r] = l, a("update:model-value", y);
226
- }
227
- function p(r = "") {
228
- return n.restaurants.filter((l) => l.managable || l._id === r).map((l) => ({
229
- label: `${l.profile.code ? `${l.profile.code} - ` : ""}${l.profile.name}`,
230
- value: l._id,
231
- disabled: le.value.includes(l._id) && l._id !== r
232
- }));
233
- }
234
- function b(r = "") {
235
- return n.roles.map((l) => ({
236
- label: l.label,
237
- value: l.value,
238
- disabled: !!l.disabled && l.value !== r
239
- }));
240
- }
241
- function ue(r, l) {
242
- var E, B, L;
243
- if (!n.modelValue) return;
244
- const y = n.modelValue.roles.length > 0 ? [...n.modelValue.roles] : [C()], I = ((E = y[r]) == null ? void 0 : E.roleId) ?? "", Z = b(I), J = ((B = Z.find((u) => u.value === I && !u.disabled)) == null ? void 0 : B.value) ?? ((L = Z.find((u) => !u.disabled)) == null ? void 0 : L.value) ?? "";
245
- y[r] = { restaurantId: l, roleId: J }, S("roles", y);
246
- }
247
- function G(r, l) {
248
- var I;
249
- if (!n.modelValue) return;
250
- const y = n.modelValue.roles.length > 0 ? [...n.modelValue.roles] : [C()];
251
- y[r] = {
252
- restaurantId: ((I = y[r]) == null ? void 0 : I.restaurantId) ?? "",
253
- roleId: l
254
- }, S("roles", y);
255
- }
256
- function A() {
257
- n.modelValue && S("roles", [...n.modelValue.roles, C()]);
258
- }
259
- function M(r) {
260
- if (!n.modelValue) return;
261
- const l = n.modelValue.roles.length > 0 ? [...n.modelValue.roles] : [C()];
262
- S(
263
- "roles",
264
- l.length === 1 ? [C()] : l.filter((y, I) => I !== r)
265
- );
266
- }
267
- const W = k(() => {
268
- if (!n.modelValue) return !1;
269
- const r = n.restaurants.some(
270
- (y) => y.managable && !le.value.includes(y._id)
271
- ), l = n.modelValue.roles.every(
272
- (y) => y.restaurantId && y.roleId
273
- );
274
- return r && l;
275
- });
276
- function U() {
277
- O.value && (O.value = !1, w.value = [], S("passcode", ""));
278
- }
279
- pe(
280
- () => {
281
- var r;
282
- return (r = n.modelValue) == null ? void 0 : r.passcode;
283
- },
284
- (r) => {
285
- r && r.length === Le ? (w.value = r.split(""), O.value = !0) : (w.value = [], O.value = !1);
286
- },
287
- { immediate: !0 }
288
- ), pe(
289
- () => {
290
- var r;
291
- return (r = n.modelValue) == null ? void 0 : r.roles;
292
- },
293
- (r) => {
294
- n.modelValue && (!r || r.length === 0) && S("roles", [C()]);
295
- },
296
- { immediate: !0, deep: !0 }
297
- );
298
- const F = k({
299
- get: () => {
300
- var r;
301
- return ((r = n.modelValue) == null ? void 0 : r.roles) ?? [];
302
- },
303
- set: () => {
304
- }
305
- });
306
- return (r, l) => {
307
- const y = V("FmSwitch"), I = V("FmTextField"), Z = V("FmPinField"), J = V("FmFormGroup"), E = V("FmSelect"), B = V("FmIcon"), L = V("FmButton");
308
- return h(), D("div", tt, [
309
- m("div", at, [
310
- m("div", lt, [
311
- m("div", ot, R(o(f)("team.memberForm.masterUser.title")), 1),
312
- m("div", nt, R(o(f)("team.memberForm.masterUser.sublabel")), 1)
313
- ]),
314
- m("div", null, [
315
- c(y, {
316
- "model-value": !!i.modelValue,
317
- value: "master-user",
318
- "onUpdate:modelValue": x
319
- }, null, 8, ["model-value"])
320
- ])
321
- ]),
322
- i.modelValue ? (h(), D(De, { key: 0 }, [
323
- m("div", rt, [
324
- c(I, {
325
- "model-value": i.modelValue.code,
326
- label: o(f)("team.memberForm.masterUser.code"),
327
- "onUpdate:modelValue": l[0] || (l[0] = (u) => S("code", u))
328
- }, null, 8, ["model-value", "label"]),
329
- c(I, {
330
- "model-value": i.modelValue.name,
331
- class: "w-full",
332
- label: o(f)("team.memberForm.masterUser.name"),
333
- rules: [(u) => !!u || o(f)("team.memberForm.masterUser.nameEmptyError")],
334
- "onUpdate:modelValue": l[1] || (l[1] = (u) => S("name", u))
335
- }, null, 8, ["model-value", "label", "rules"])
336
- ]),
337
- m("div", it, [
338
- m("div", ut, R(o(f)("team.memberForm.masterUser.passcode")), 1),
339
- c(J, {
340
- modelValue: w.value,
341
- "onUpdate:modelValue": l[4] || (l[4] = (u) => w.value = u),
342
- rules: [
343
- (u) => (u == null ? void 0 : u.filter((_) => !!_).length) !== Le ? o(f)("team.memberForm.masterUser.passcodeRequired") : !0
344
- ]
345
- }, {
346
- default: ie(() => [
347
- (h(), z(Z, {
348
- key: `pin-field-${O.value}`,
349
- modelValue: w.value,
350
- "onUpdate:modelValue": l[2] || (l[2] = (u) => w.value = u),
351
- length: Le,
352
- masked: O.value,
353
- onComplete: l[3] || (l[3] = (u) => S("passcode", u)),
354
- onFocus: U
355
- }, null, 8, ["modelValue", "masked"]))
356
- ]),
357
- _: 1
358
- }, 8, ["modelValue", "rules"])
359
- ]),
360
- c(J, {
361
- tag: "div",
362
- modelValue: F.value,
363
- "onUpdate:modelValue": l[5] || (l[5] = (u) => F.value = u),
364
- rules: [
365
- (u) => !u || u.length === 0 || u.every((_) => !_.restaurantId) ? o(f)("team.memberForm.masterUser.restaurantRequired") : u.some((_) => !_.restaurantId || !_.roleId) ? o(f)("team.memberForm.masterUser.roleRequired") : !0
366
- ]
367
- }, {
368
- default: ie(() => [
369
- m("div", mt, [
370
- m("div", dt, R(o(f)("team.memberForm.masterUser.assignmentSection")), 1),
371
- m("div", ct, [
372
- m("div", pt, [
373
- m("div", ft, R(o(f)("team.table.columns.restaurant")), 1),
374
- m("div", vt, R(o(f)("team.memberForm.masterUser.role")), 1),
375
- l[6] || (l[6] = m("div", null, null, -1))
376
- ]),
377
- (h(!0), D(De, null, us(i.modelValue.roles, (u, _) => (h(), D("div", {
378
- key: `${u.restaurantId || "new"}-${_}`,
379
- class: "grid grid-cols-[minmax(0,1fr)_minmax(0,1fr)_auto] items-center gap-16"
380
- }, [
381
- c(E, {
382
- class: "min-w-0",
383
- "model-value": u.restaurantId,
384
- items: p(u.restaurantId),
385
- multiselect: !1,
386
- placeholder: o(f)("team.table.columns.restaurant"),
387
- "onUpdate:modelValue": (X) => ue(_, X)
388
- }, null, 8, ["model-value", "items", "placeholder", "onUpdate:modelValue"]),
389
- c(E, {
390
- class: "min-w-0",
391
- "model-value": u.roleId,
392
- items: b(u.roleId),
393
- multiselect: !1,
394
- placeholder: o(f)("team.memberForm.masterUser.role"),
395
- disabled: !u.restaurantId,
396
- "onUpdate:modelValue": (X) => G(_, X)
397
- }, null, 8, ["model-value", "items", "placeholder", "disabled", "onUpdate:modelValue"]),
398
- m("div", bt, [
399
- i.modelValue.roles.length > 1 ? (h(), D("div", {
400
- key: 0,
401
- role: "button",
402
- tabindex: "0",
403
- class: "inline-flex h-40 w-40 shrink-0 cursor-pointer items-center justify-center rounded-lg text-fm-color-neutral-gray-400 transition-colors hover:bg-fm-color-neutral-gray-100 focus:outline-none focus:ring-2 focus:ring-fm-color-primary",
404
- "aria-label": o(f)("common.remove"),
405
- onClick: Fe((X) => M(_), ["stop"]),
406
- onKeydown: [
407
- qe(Fe((X) => M(_), ["prevent", "stop"]), ["enter"]),
408
- qe(Fe((X) => M(_), ["prevent", "stop"]), ["space"])
409
- ]
410
- }, [
411
- c(B, {
412
- name: "delete",
413
- size: "md"
414
- })
415
- ], 40, ht)) : K("", !0)
416
- ])
417
- ]))), 128))
418
- ]),
419
- c(L, {
420
- type: "button",
421
- variant: "secondary",
422
- "text-color": "primary",
423
- "border-color": "primary",
424
- "prepend-icon": "add",
425
- label: o(f)("team.memberForm.masterUser.addAnother"),
426
- size: "md",
427
- disabled: !W.value,
428
- onClick: Fe(A, ["stop"])
429
- }, null, 8, ["label", "disabled"])
430
- ])
431
- ]),
432
- _: 1
433
- }, 8, ["modelValue", "rules"])
434
- ], 64)) : K("", !0)
435
- ]);
436
- };
437
- }
438
- }), _t = { class: "flex flex-col gap-32" }, gt = { class: "flex w-full" }, xt = {
439
- key: 0,
440
- class: "space-y-24"
441
- }, St = { class: "space-y-16 rounded-lg border border-fm-color-neutral-gray-200 p-16" }, Ut = { class: "fm-typo-en-title-sm-600" }, Ft = { class: "space-y-16" }, Vt = { class: "fm-typo-en-title-sm-600" }, wt = {
442
- key: 1,
443
- class: "flex items-center justify-center py-64"
444
- }, It = /* @__PURE__ */ we({
445
- __name: "AddMemberForm",
446
- props: {
447
- initialValue: {
448
- type: Object
449
- },
450
- roleErrorMessage: {
451
- type: String,
452
- default: ""
453
- },
454
- loading: {
455
- type: Boolean,
456
- default: !1
457
- }
458
- },
459
- setup(i, { expose: $ }) {
460
- var $e, Ce, oe;
461
- const n = i, { t: a } = Ie(), f = es(), { breakpoints: O } = ss(), w = v(), C = as(), le = k(
462
- () => C.permissionSets.value.map((s) => ({
463
- label: s.name,
464
- value: s.id
465
- }))
466
- ), x = v((($e = n.initialValue) == null ? void 0 : $e.permissionSetIds) || []), S = k(
467
- () => je(x.value, C.permissionSets.value)
468
- ), p = v((Ce = n.initialValue) == null ? void 0 : Ce.posUser), b = v(
469
- We(
470
- Ae(S.value),
471
- ((oe = n.initialValue) == null ? void 0 : oe.permissions) || []
472
- )
473
- ), { customReportPermissions: ue, isLoaded: G } = ls(), A = new Set(
474
- Je.filter((s) => s.subject.startsWith(Vs)).map((s) => s.subject)
475
- ), M = k(() => {
476
- const s = new Set(A);
477
- for (const d of ue.value) s.add(d.subject);
478
- return s;
479
- }), W = k(() => {
480
- const s = /* @__PURE__ */ new Set();
481
- for (const d of Je)
482
- d.category === ze.reports && s.add(d.subject);
483
- for (const d of ue.value)
484
- d.category === ze.reports && s.add(d.subject);
485
- return s;
486
- }), U = ts(), F = os().roles, r = k(() => Xe(b.value)), l = k(() => {
487
- const s = Ze(b.value);
488
- return s === null ? U.restaurants.value : U.restaurants.value.filter((d) => s.includes(d._id));
489
- }), y = k(() => {
490
- const s = r.value;
491
- return F.value.map(
492
- (d) => ({
493
- label: d.name,
494
- value: d._id,
495
- disabled: !!s && !s.includes(d._id)
496
- })
497
- );
498
- }), I = v({ permissionSetIds: [], userPermissions: [], posUser: void 0 });
499
- function Z(s) {
500
- w.value = void 0, x.value = [...(s == null ? void 0 : s.permissionSetIds) ?? []], b.value = We(
501
- Ae(
502
- je(
503
- x.value,
504
- C.permissionSets.value
505
- )
506
- ),
507
- (s == null ? void 0 : s.permissions) || []
508
- ), p.value = s != null && s.posUser ? Q(fe(s.posUser), b.value) : void 0, ve.value = !!p.value, I.value = {
509
- permissionSetIds: [...x.value],
510
- userPermissions: fe(b.value),
511
- posUser: p.value ? fe(p.value) : void 0
512
- };
513
- }
514
- function J() {
515
- return !n.initialValue && w.value ? !0 : !Se.isEqual(x.value, I.value.permissionSetIds) || !Se.isEqual(b.value, I.value.userPermissions) || !Se.isEqual(p.value, I.value.posUser);
516
- }
517
- function E(s) {
518
- w.value = s;
519
- }
520
- function B(s) {
521
- p.value = Q(p.value, s);
522
- }
523
- function L(s) {
524
- return Ae(
525
- je(s, C.permissionSets.value)
526
- );
527
- }
528
- function u(s) {
529
- b.value = L(s);
530
- }
531
- function _(s) {
532
- const d = [...s ?? []];
533
- if (Se.isEqual(d, x.value)) return;
534
- const j = !Se.isEqual(
535
- b.value,
536
- L(x.value)
537
- );
538
- if (x.value = d, !j) {
539
- u(d);
540
- return;
541
- }
542
- f.open({
543
- title: a("permissionSet.form.overrideInherited.title"),
544
- message: a("permissionSet.form.overrideInherited.message"),
545
- minWidth: O.value.lg ? 588 : 0,
546
- primaryActions: {
547
- text: a("permissionSet.form.overrideInherited.override"),
548
- close: !1
549
- },
550
- secondaryActions: {
551
- text: a("permissionSet.form.overrideInherited.keepCurrent"),
552
- close: !0
553
- }
554
- }).onPrimary(() => {
555
- u(d), f.close();
556
- });
557
- }
558
- function X() {
559
- const s = Ae(S.value), d = G.value ? M.value : A, j = ws(b.value, d), T = Is(j, W.value), q = Ps(T);
560
- return ks(s, q);
561
- }
562
- function Pe() {
563
- var j, T, q, Y, H, de, ee, se, te, Me;
564
- const s = X(), d = b.value.filter((ce) => !ce.inverted);
565
- return {
566
- email: ((j = w.value) == null ? void 0 : j.email) ?? void 0,
567
- phoneNumber: ((T = w.value) == null ? void 0 : T.phoneNumber) ?? void 0,
568
- customPermissions: s,
569
- permissions: d.map((ce) => ({
570
- ...ce,
571
- subject: bs(ce.subject)
572
- })),
573
- permissionSetIds: x.value,
574
- name: ((q = w.value) == null ? void 0 : q.displayName) || ((Y = n.initialValue) == null ? void 0 : Y.name) || "",
575
- posUser: p.value ? {
576
- ...p.value,
577
- name: p.value.name || ((de = (H = n.initialValue) == null ? void 0 : H.posUser) == null ? void 0 : de.name) || ((ee = n.initialValue) == null ? void 0 : ee.name) || ((se = w.value) == null ? void 0 : se.displayName) || "",
578
- code: p.value.code || ((Me = (te = n.initialValue) == null ? void 0 : te.posUser) == null ? void 0 : Me.code) || "",
579
- passcode: p.value.passcode,
580
- roles: p.value.roles.filter((ce) => !!ce.roleId)
581
- } : p.value === null ? null : void 0
582
- };
583
- }
584
- const _e = v();
585
- function Q(s, d) {
586
- if (!s) return s;
587
- const j = Xe(d), T = Ze(d);
588
- if (j === null && T === null) return s;
589
- const q = fe(s);
590
- return q.roles = q.roles.filter(
591
- (Y) => (j === null || j.includes(Y.roleId)) && (T === null || T.includes(Y.restaurantId))
592
- ), q;
593
- }
594
- const ve = v(!!p.value), me = v(!1);
595
- function ge(s) {
596
- p.value = s, me.value = !0;
597
- }
598
- pe(
599
- () => !!p.value,
600
- async (s) => {
601
- s && !ve.value && me.value && (await ms(), _e.value && _e.value.$el.scrollIntoView({ behavior: "smooth", block: "start" })), ve.value = s;
602
- }
603
- );
604
- const ke = v();
605
- async function Re() {
606
- return (await ke.value.validateInputsWithoutSubmit()).length ? null : Pe();
607
- }
608
- return pe(
609
- () => n.initialValue,
610
- (s, d) => {
611
- if (!d || !s || d.id !== s.id) {
612
- me.value = !1, Z(s);
613
- return;
614
- }
615
- s.posUser !== void 0 && !me.value && (p.value = s.posUser ? Q(fe(s.posUser), b.value) : void 0, I.value = {
616
- ...I.value,
617
- posUser: p.value ? fe(p.value) : void 0
618
- });
619
- },
620
- { immediate: !0 }
621
- ), pe(
622
- b,
623
- (s) => {
624
- p.value = Q(p.value, s);
625
- },
626
- { deep: !0 }
627
- ), $({
628
- readFormData: Pe,
629
- validate: Re,
630
- isModified: J
631
- }), (s, d) => {
632
- const j = V("FmSelect"), T = V("FmCircularProgress"), q = V("FmForm");
633
- return h(), z(q, {
634
- ref_key: "formRef",
635
- ref: ke,
636
- class: "mx-4"
637
- }, {
638
- default: ie(() => {
639
- var Y, H, de, ee, se;
640
- return [
641
- m("div", _t, [
642
- m("div", gt, [
643
- i.initialValue ? (h(), z(zs, {
644
- key: 1,
645
- data: i.initialValue
646
- }, null, 8, ["data"])) : (h(), z(st, {
647
- key: 0,
648
- onInvite: d[0] || (d[0] = (te) => E(te))
649
- }))
650
- ]),
651
- w.value || i.initialValue ? (h(), D(De, { key: 0 }, [
652
- (Y = i.initialValue) != null && Y.isOwner ? K("", !0) : (h(), D("div", xt, [
653
- m("div", St, [
654
- m("div", Ut, R(o(a)("team.memberForm.permissionSet.title")), 1),
655
- c(j, {
656
- "model-value": x.value,
657
- multiselect: "",
658
- searchable: "",
659
- "search-debounce": 300,
660
- items: le.value,
661
- placeholder: o(a)("team.memberForm.permissionSet.selectPlaceholder"),
662
- "onUpdate:modelValue": _
663
- }, null, 8, ["model-value", "items", "placeholder"])
664
- ]),
665
- m("div", Ft, [
666
- m("div", Vt, R(o(a)("team.memberForm.permissions.title")), 1),
667
- c(Cs, {
668
- modelValue: b.value,
669
- "onUpdate:modelValue": d[1] || (d[1] = (te) => b.value = te),
670
- "inherit-permissions": S.value,
671
- onPermissionChanged: B
672
- }, null, 8, ["modelValue", "inherit-permissions"])
673
- ])
674
- ])),
675
- i.loading ? (h(), D("div", wt, [
676
- c(T, { size: "xl" })
677
- ])) : (h(), z(yt, {
678
- key: 2,
679
- ref_key: "masterUserContentRef",
680
- ref: _e,
681
- "model-value": p.value,
682
- "fallback-name": ((H = i.initialValue) == null ? void 0 : H.name) || ((de = w.value) == null ? void 0 : de.displayName) || "",
683
- "fallback-passcode": (se = (ee = i.initialValue) == null ? void 0 : ee.posUser) == null ? void 0 : se.passcode,
684
- roles: y.value,
685
- restaurants: l.value,
686
- "onUpdate:modelValue": ge
687
- }, null, 8, ["model-value", "fallback-name", "fallback-passcode", "roles", "restaurants"]))
688
- ], 64)) : K("", !0)
689
- ])
690
- ];
691
- }),
692
- _: 1
693
- }, 512);
694
- };
695
- }
696
- }), Pt = {
697
- class: "space-y-24"
698
- }, kt = {
699
- class: "space-y-8"
700
- }, Rt = {
701
- key: 0,
702
- class: "flex w-full items-start justify-between px-16"
703
- }, $t = {
704
- class: "flex items-start gap-8"
705
- }, Ct = {
706
- key: 1,
707
- class: "space-y-4 px-16"
708
- }, Mt = {
709
- class: "flex items-start gap-8"
710
- }, Nt = {
711
- class: "flex h-full flex-col overflow-auto"
712
- }, At = {
713
- class: "flex w-full items-center justify-between"
714
- }, Dt = {
715
- class: "fm-typo-en-title-md-600"
716
- }, Ot = {
717
- class: "flex items-center justify-start gap-8"
718
- }, he = 100;
719
- var ae = /* @__PURE__ */ function(i) {
720
- return i[i.ADD = 0] = "ADD", i[i.UPDATE = 1] = "UPDATE", i[i.CLOSED = 2] = "CLOSED", i;
721
- }(ae || {});
722
- const ea = /* @__PURE__ */ we({
723
- __name: "TeamMemberList",
724
- setup(i, {
725
- expose: $
726
- }) {
727
- const {
728
- fetchCustomReportPermissions: n
729
- } = ls();
730
- ns();
731
- const {
732
- t: a
733
- } = Ie(), f = Oe(), O = ts(), w = os(), C = He(), le = Fs(C), x = as(), S = Rs(), p = v(!0), b = v(!1), ue = k(() => O.isLoading.value), G = v([]), A = v(0), M = v(1), W = v(""), U = v("");
734
- pe(O.restaurants, (e) => {
735
- if (e.length > 0 && G.value.length > 0) {
736
- const t = new Map(e.map((P) => [P._id, P.profile.name])), g = e.map((P) => P.profile.name).sort();
737
- G.value = G.value.map((P) => ({
738
- ...P,
739
- restaurants: P.managableRestaurantIds === null ? g : P.managableRestaurantIds.map((ne) => t.get(ne) ?? "").filter(Boolean).sort()
740
- }));
741
- }
742
- });
743
- const F = k(() => [{
744
- label: a("team.filter.unassigned_label"),
745
- value: Ve
746
- }, ...O.restaurants.value.map((e) => ({
747
- label: `${e.profile.code ? `${e.profile.code} - ` : ""}${e.profile.name}`,
748
- value: e._id
749
- }))]), r = ({
750
- member: e,
751
- className: t = ""
752
- }) => {
753
- const g = {
754
- label: a("team.actions.updateMember"),
755
- onClick: () => L(ye.Update, e)
756
- }, P = {
757
- label: a("team.actions.removeMember"),
758
- onClick: () => L(ye.Remove, e),
759
- itemClass: "text-fm-color-typo-error"
760
- }, ne = e.doc.isOwner ? [g] : [g, P];
761
- return c(xs, {
762
- class: t,
763
- items: ne
764
- }, null);
765
- }, l = (e) => e.doc.isOwner ? a("team.labels.businessOwner") : e.restaurants.join(", "), y = [{
766
- accessorKey: "name",
767
- header: () => a("team.table.columns.name"),
768
- enableSorting: !1,
769
- cell(e) {
770
- const t = e.row.original;
771
- return c("div", {
772
- class: "flex items-center gap-8"
773
- }, [c(Be.FmAvatar, {
774
- name: t.name,
775
- size: "sm",
776
- class: "shrink-0"
777
- }, null), c("span", {
778
- class: "truncate"
779
- }, [t.name])]);
780
- }
781
- }, {
782
- accessorKey: "phoneNumber",
783
- header: () => a("team.table.columns.phoneNumber"),
784
- enableSorting: !1
785
- }, {
786
- accessorKey: "restaurant",
787
- header: () => a("team.table.columns.restaurant"),
788
- enableSorting: !1,
789
- cell(e) {
790
- if (ue.value)
791
- return cs(Us);
792
- const t = e.row.original;
793
- return l(t);
794
- }
795
- }, {
796
- accessorKey: "assignedRoles",
797
- header: () => a("team.table.columns.assignedRoles"),
798
- enableSorting: !1,
799
- cell(e) {
800
- const t = e.row.original, g = S.getPermissionAssignmentByUserId(t.id), P = (g == null ? void 0 : g.permissionSetIds) || t.doc.permissionSetIds || [];
801
- return x.permissionSets.value.filter((re) => P.includes(re.id)).map((re) => re.name).join(", ");
802
- }
803
- }, {
804
- accessorKey: "permission",
805
- header: () => a("team.table.columns.permission"),
806
- enableSorting: !1,
807
- cell(e) {
808
- const t = e.row.original;
809
- return I(t);
810
- },
811
- meta: {
812
- width: "200px"
813
- }
814
- }, {
815
- id: "action",
816
- meta: {
817
- cellClass: "pl-16",
818
- headerContentClass: "-mx-16"
819
- },
820
- cell(e) {
821
- const t = e.row.original;
822
- return r({
823
- member: t,
824
- className: "flex justify-end w-full"
825
- });
826
- },
827
- enableSorting: !1
828
- }];
829
- function I(e) {
830
- if (e.doc.isOwner)
831
- return a("team.labels.businessOwner");
832
- const t = c(Be.FmTooltip, {
833
- variant: "plain",
834
- placement: "top"
835
- }, {
836
- default: () => c(Be.FmIcon, {
837
- name: "info",
838
- class: "cursor-pointer text-fm-color-neutral-gray-300"
839
- }, null),
840
- content: () => c("div", null, [a("team.labels.permission"), e.permissionLabels.map((g) => c("div", null, [ps("- "), g]))])
841
- });
842
- return c("div", {
843
- class: "flex flex-row items-center gap-8"
844
- }, [c("span", null, [a("team.labels.allowed", {
845
- count: e.permissionLabels.length
846
- })]), e.permissionLabels.length > 0 && t]);
847
- }
848
- function Z(e) {
849
- var ne, re, Ne, xe;
850
- const t = S.getPermissionAssignmentByUserId(e.id), g = (t == null ? void 0 : t.customPermissions) ?? e.permissions ?? [], P = (t == null ? void 0 : t.permissionSetIds) ?? e.doc.permissionSetIds ?? [];
851
- return {
852
- id: e.id,
853
- isOwner: e.doc.isOwner,
854
- name: e.name,
855
- phoneNumber: e.phoneNumber,
856
- email: e.email,
857
- permissions: g,
858
- permissionSetIds: P,
859
- posUser: e.doc.posUser ? {
860
- code: ((ne = e.doc.posUser) == null ? void 0 : ne.code) ?? "",
861
- name: ((re = e.doc.posUser) == null ? void 0 : re.name) ?? e.name,
862
- passcode: ((Ne = e.doc.posUser) == null ? void 0 : Ne.passcode) ?? "",
863
- roles: ((xe = e.doc.posUser) == null ? void 0 : xe.roles) ?? []
864
- } : void 0
865
- };
866
- }
867
- function J(e) {
868
- const t = S.getPermissionAssignmentByUserId(e.id), g = (t == null ? void 0 : t.customPermissions) ?? e.permissions ?? [], P = (t == null ? void 0 : t.permissionSetIds) ?? e.doc.permissionSetIds ?? [];
869
- return {
870
- id: e.id,
871
- isOwner: e.doc.isOwner,
872
- name: e.name,
873
- phoneNumber: e.phoneNumber,
874
- email: e.email,
875
- permissions: g,
876
- permissionSetIds: P,
877
- posUser: void 0
878
- };
879
- }
880
- const E = v(!1);
881
- let B = 0;
882
- const L = async (e, t) => {
883
- if (e == ye.Update) {
884
- const g = ++B;
885
- Q.value = J(t), _.value = ae.UPDATE, E.value = t.doc.hasPosUser === !0;
886
- try {
887
- const P = await Ue.readTeamMember(t.id);
888
- if (g !== B) return;
889
- Q.value = Z(P);
890
- } catch {
891
- if (g !== B) return;
892
- C.open({
893
- message: a("common.error"),
894
- type: "error"
895
- }), ge();
896
- } finally {
897
- g === B && (E.value = !1);
898
- }
899
- }
900
- e == ye.Remove && $e(t);
901
- }, u = es(), _ = v(ae.CLOSED), X = k(() => _.value !== ae.CLOSED), Pe = k(() => _.value === ae.ADD ? a("common.add") : a("common.update")), _e = k(() => _.value === ae.ADD ? a("team.actions.addMember") : a("team.actions.updateMember")), Q = v();
902
- function ve() {
903
- B++, E.value = !1, _.value = ae.CLOSED;
904
- }
905
- const me = gs(() => {
906
- var e;
907
- return ((e = ee.value) == null ? void 0 : e.isModified()) ?? !1;
908
- }, ve);
909
- function ge() {
910
- me();
911
- }
912
- function ke(e) {
913
- e || ge();
914
- }
915
- const {
916
- breakpoints: Re
917
- } = ss(), $e = (e) => {
918
- u.open({
919
- title: a("team.actions.removeMember"),
920
- message: a("team.removeMember.confirmationMessage", {
921
- memberName: e.name
922
- }),
923
- minWidth: Re.value.lg ? 588 : 0,
924
- primaryActions: {
925
- text: "Remove",
926
- close: !1,
927
- variant: "destructive",
928
- isLoading: te
929
- },
930
- secondaryActions: {
931
- text: "Cancel",
932
- close: !0
933
- }
934
- }).onPrimary(async () => {
935
- te.value || (await le.minor(async () => {
936
- await Ue.deleteTeamMember(e.id), await de();
937
- }, {
938
- isLoading: te,
939
- successMessage: a("team.removeMember.successMessage", {
940
- memberName: e.name
941
- })
942
- }), u.close());
943
- });
944
- }, Ce = () => {
945
- Q.value = null, _.value = ae.ADD;
946
- }, oe = v(), s = v(), d = v(), j = k(() => {
947
- var e;
948
- return JSON.stringify({
949
- businessId: ((e = f.currentBusiness.value) == null ? void 0 : e._id) ?? "",
950
- search: U.value.trim(),
951
- restaurantIds: [...oe.value ?? []].sort(),
952
- permissionSubjects: [...s.value ?? []].sort(),
953
- permissionSetIds: [...d.value ?? []].sort()
954
- });
955
- }), T = k(() => Object.values(hs).map((e) => ({
956
- label: e.label,
957
- value: e.subject
958
- }))), q = k(() => [{
959
- label: a("team.filter.unassigned_label"),
960
- value: Ve
961
- }, ...x.permissionSets.value.map((e) => ({
962
- label: e.name,
963
- value: e.id
964
- }))]);
965
- async function Y() {
966
- await w.readRoles();
967
- }
968
- async function H(e = M.value) {
969
- var t;
970
- p.value = !0;
971
- try {
972
- const g = await Ue.readTeamMembersPage({
973
- limit: he,
974
- offset: (e - 1) * he,
975
- search: U.value.trim() || void 0,
976
- restaurantIds: Qe(oe.value),
977
- permissionSubjects: (t = s.value) != null && t.length ? s.value : void 0,
978
- permissionSetIds: Qe(d.value)
979
- });
980
- G.value = g.items, A.value = g.total;
981
- } finally {
982
- p.value = !1;
983
- }
984
- }
985
- async function de() {
986
- var t;
987
- if (!((t = f.currentBusiness.value) != null && t._id)) return;
988
- await H(M.value);
989
- const e = Math.max(1, Math.ceil(A.value / he));
990
- M.value > e && (M.value = e, await H(M.value));
991
- }
992
- const ee = v(), se = v(!1), te = v(!1);
993
- async function Me() {
994
- if (!ee.value) return;
995
- const e = await ee.value.validate();
996
- if (!e) return;
997
- const t = _.value === ae.ADD;
998
- await le.minor(async () => {
999
- await (t ? Ue.createTeamMember(e) : Ue.updateTeamMember(Q.value.id, e)), ve(), await Te(), await de();
1000
- }, {
1001
- successMessage: t ? a("team.addMember.successMessage", {
1002
- memberName: e.name
1003
- }) : a("team.updateMember.successMessage", {
1004
- memberName: e.name
1005
- }),
1006
- isLoading: se
1007
- }), _.value = ae.CLOSED;
1008
- }
1009
- async function ce() {
1010
- await x.readPermissionSets();
1011
- }
1012
- async function Te() {
1013
- await S.readPermissionAssignments();
1014
- }
1015
- let Ee = !1;
1016
- async function rs({
1017
- pageIndex: e
1018
- }) {
1019
- var t;
1020
- if ((t = f.currentBusiness.value) != null && t._id && !Ee && !(e === 0 && M.value === 1 && G.value.length > 0)) {
1021
- Ee = !0, M.value = e + 1;
1022
- try {
1023
- await H(M.value);
1024
- } finally {
1025
- Ee = !1;
1026
- }
1027
- }
1028
- }
1029
- const is = fs(W, () => {
1030
- U.value = W.value;
1031
- });
1032
- return ds(is), pe(j, async () => {
1033
- var e;
1034
- M.value = 1, b.value = !1, (e = f.currentBusiness.value) != null && e._id && (await H(1), b.value = !0);
1035
- }, {
1036
- immediate: !0
1037
- }), pe(f.currentBusiness, async () => {
1038
- var e;
1039
- if ((e = f.currentBusiness.value) != null && e._id)
1040
- try {
1041
- await Promise.all([O.readRestaurants(), ce(), Te(), n(), Y()]);
1042
- } catch (t) {
1043
- console.error("Failed to load team member dependencies:", t), C.open({
1044
- message: t instanceof Error ? t.message : String(t),
1045
- type: "error"
1046
- });
1047
- }
1048
- }, {
1049
- immediate: !0
1050
- }), $({
1051
- create: Ce
1052
- }), (e, t) => {
1053
- var xe;
1054
- const g = V("FmSearch"), P = V("FmTable"), ne = V("FmIcon"), re = V("FmButton"), Ne = V("FmSideSheet");
1055
- return h(), D(De, null, [m("div", Pt, [m("div", kt, [o(Re).xs ? (h(), D("div", Ct, [c(g, {
1056
- modelValue: W.value,
1057
- "onUpdate:modelValue": t[4] || (t[4] = (N) => W.value = N),
1058
- class: "w-[320px] xs:w-full xs:mt-8",
1059
- placeholder: o(a)("team.search.placeholder")
1060
- }, null, 8, ["modelValue", "placeholder"]), m("div", Mt, [c(be, {
1061
- modelValue: oe.value,
1062
- "onUpdate:modelValue": t[5] || (t[5] = (N) => oe.value = N),
1063
- multiple: "",
1064
- items: F.value,
1065
- variant: "dark",
1066
- "selected-prefix": o(a)("team.table.columns.restaurant"),
1067
- placeholder: o(a)("team.table.columns.restaurant"),
1068
- class: "!w-auto"
1069
- }, null, 8, ["modelValue", "items", "selected-prefix", "placeholder"]), c(be, {
1070
- modelValue: s.value,
1071
- "onUpdate:modelValue": t[6] || (t[6] = (N) => s.value = N),
1072
- multiple: "",
1073
- variant: "dark",
1074
- items: T.value,
1075
- "selected-prefix": o(a)("team.filter.selected_permission_prefix"),
1076
- placeholder: o(a)("team.filter.permission_placeholder")
1077
- }, null, 8, ["modelValue", "items", "selected-prefix", "placeholder"]), c(be, {
1078
- modelValue: d.value,
1079
- "onUpdate:modelValue": t[7] || (t[7] = (N) => d.value = N),
1080
- multiple: "",
1081
- variant: "dark",
1082
- items: q.value,
1083
- "selected-prefix": o(a)("team.filter.selected_assigned_role_prefix"),
1084
- placeholder: o(a)("team.filter.assigned_role_placeholder")
1085
- }, null, 8, ["modelValue", "items", "selected-prefix", "placeholder"])])])) : (h(), D("div", Rt, [m("div", $t, [c(be, {
1086
- modelValue: oe.value,
1087
- "onUpdate:modelValue": t[0] || (t[0] = (N) => oe.value = N),
1088
- multiple: "",
1089
- items: F.value,
1090
- variant: "dark",
1091
- "selected-prefix": o(a)("team.table.columns.restaurant"),
1092
- placeholder: o(a)("team.table.columns.restaurant"),
1093
- class: "!w-auto"
1094
- }, null, 8, ["modelValue", "items", "selected-prefix", "placeholder"]), c(be, {
1095
- modelValue: s.value,
1096
- "onUpdate:modelValue": t[1] || (t[1] = (N) => s.value = N),
1097
- multiple: "",
1098
- variant: "dark",
1099
- items: T.value,
1100
- "selected-prefix": o(a)("team.filter.selected_permission_prefix"),
1101
- placeholder: o(a)("team.filter.permission_placeholder")
1102
- }, null, 8, ["modelValue", "items", "selected-prefix", "placeholder"]), c(be, {
1103
- modelValue: d.value,
1104
- "onUpdate:modelValue": t[2] || (t[2] = (N) => d.value = N),
1105
- multiple: "",
1106
- variant: "dark",
1107
- items: q.value,
1108
- "selected-prefix": o(a)("team.filter.selected_assigned_role_prefix"),
1109
- placeholder: o(a)("team.filter.assigned_role_placeholder")
1110
- }, null, 8, ["modelValue", "items", "selected-prefix", "placeholder"])]), c(g, {
1111
- modelValue: W.value,
1112
- "onUpdate:modelValue": t[3] || (t[3] = (N) => W.value = N),
1113
- class: "w-[320px] xs:w-full xs:mt-8",
1114
- autofocus: "",
1115
- placeholder: o(a)("team.search.placeholder")
1116
- }, null, 8, ["modelValue", "placeholder"])])), (xe = o(f).currentBusiness.value) != null && xe._id ? (h(), z(ys, {
1117
- key: 2
1118
- }, {
1119
- default: ie(() => [m("div", Nt, [b.value ? K("", !0) : (h(), z(_s, {
1120
- key: 0
1121
- })), b.value ? (h(), z(Ss, {
1122
- key: 1,
1123
- "is-loading": p.value,
1124
- "is-empty": A.value === 0,
1125
- title: o(a)("team.emptyState.title"),
1126
- subtitle: o(a)("team.emptyState.description")
1127
- }, {
1128
- default: ie(() => [(h(), z(P, {
1129
- key: j.value,
1130
- "column-defs": y,
1131
- "row-data": G.value,
1132
- "page-size": he,
1133
- "page-count": Math.ceil(A.value / he),
1134
- "row-count": A.value,
1135
- "fetch-fn": rs,
1136
- "hide-footer": A.value <= he,
1137
- loading: p.value,
1138
- "pin-header-row": "",
1139
- onRowClick: t[8] || (t[8] = (N) => L(o(ye).Update, N.original))
1140
- }, null, 8, ["row-data", "page-count", "row-count", "hide-footer", "loading"]))]),
1141
- _: 1
1142
- }, 8, ["is-loading", "is-empty", "title", "subtitle"])) : K("", !0)])]),
1143
- _: 1
1144
- })) : K("", !0)])]), c(Ne, {
1145
- "model-value": X.value,
1146
- "max-width": 960,
1147
- "close-button": !1,
1148
- "onUpdate:modelValue": ke,
1149
- "onOn:clickedAway": o(me)
1150
- }, {
1151
- "side-sheet-header": ie(() => [m("div", At, [m("p", Dt, R(_e.value), 1), c(ne, {
1152
- name: "close",
1153
- size: "md",
1154
- class: "cursor-pointer",
1155
- onClick: o(me)
1156
- }, null, 8, ["onClick"])])]),
1157
- "side-sheet-footer": ie(() => [m("div", Ot, [c(re, {
1158
- label: Pe.value,
1159
- size: "md",
1160
- variant: "primary",
1161
- "is-loading": se.value,
1162
- disabled: se.value,
1163
- onClick: Fe(Me, ["prevent"])
1164
- }, null, 8, ["label", "is-loading", "disabled"]), c(re, {
1165
- label: o(a)("common.cancel"),
1166
- size: "md",
1167
- variant: "secondary",
1168
- disabled: se.value,
1169
- onClick: ge
1170
- }, null, 8, ["label", "disabled"])])]),
1171
- default: ie(() => [X.value ? (h(), z(It, {
1172
- key: 0,
1173
- ref_key: "memberForm",
1174
- ref: ee,
1175
- initialValue: Q.value,
1176
- loading: E.value,
1177
- class: "gap-8"
1178
- }, null, 8, ["initialValue", "loading"])) : K("", !0)]),
1179
- _: 1
1180
- }, 8, ["model-value", "onOn:clickedAway"])], 64);
1181
- };
1182
- }
1183
- });
1184
- export {
1185
- ea as default
1186
- };