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

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