@feedmepos/mf-hrm-portal 2.2.3 → 2.2.5-dev

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