@feedmepos/mf-hrm-portal 2.0.19-dev.1 → 2.0.20-dev.1

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