@feedmepos/mf-hrm-portal 2.0.12-dev → 2.0.13

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 (29) hide show
  1. package/dist/{AuditLogList-Am6PW6qN.js → AuditLogList-BRLWRnMw.js} +4 -4
  2. package/dist/EmployeeList-CaZN66DH.js +700 -0
  3. package/dist/{Main-BY_V1guq.js → Main-CFRwFhOp.js} +9 -9
  4. package/dist/{Main-BC_y5Gzg.js → Main-DDJqYruE.js} +4 -4
  5. package/dist/{Main-Chau30wK.js → Main-DX6DtLSq.js} +5 -5
  6. package/dist/{PermissionSetList-CDUFrGRE.js → PermissionSetList-CfKgOGUa.js} +5 -5
  7. package/dist/{PortalPermissionEditor.vue_vue_type_script_setup_true_lang-CGIontQw.js → PortalPermissionEditor.vue_vue_type_script_setup_true_lang-CANjzJpE.js} +1078 -1078
  8. package/dist/{RoleList-BVQ4zkA8.js → RoleList-DVW9rJKE.js} +7 -7
  9. package/dist/{TeamMemberList-D65MpqIr.js → TeamMemberList-CZDwbZVL.js} +195 -191
  10. package/dist/{TimesheetList-Dc295zCI.js → TimesheetList-DMuID6CQ.js} +7 -7
  11. package/dist/{app-Iv5hLrRX.js → app-jGOQVOD0.js} +43 -43
  12. package/dist/app.js +1 -1
  13. package/dist/{dayjs.min-CJGjjQIJ.js → dayjs.min-D2KkLYBN.js} +1 -1
  14. package/dist/{employee-C2Qhr8xO.js → employee-Bh77woAn.js} +4 -4
  15. package/dist/{index-5ziPpN4I.js → index-BpdsYZQZ.js} +17 -17
  16. package/dist/{index-DzRWjF3a.js → index-DNRSCsVp.js} +1 -1
  17. package/dist/{iteration-L8TLGaCI.js → iteration-iewRosUH.js} +2 -2
  18. package/dist/{lodash-Bbes-RWy.js → lodash-BuzCumRN.js} +1 -1
  19. package/dist/src/composables/useDebounce.d.ts +1 -1
  20. package/dist/style.css +1 -1
  21. package/dist/{timesheet-Dbp6blBA.js → timesheet-D-fS5DjW.js} +3 -3
  22. package/dist/tsconfig.app.tsbuildinfo +1 -1
  23. package/dist/{useAppStore-e7cSGuDZ.js → useAppStore-RlI38pvN.js} +1 -1
  24. package/dist/useDebounce-B8ZPVS5C.js +15 -0
  25. package/dist/{useLoading-C8ko-jia.js → useLoading-CJnGoe22.js} +1 -1
  26. package/dist/{useReportPermissions-B0EDgKey.js → useReportPermissions-CwzEzTF1.js} +3 -3
  27. package/package.json +1 -1
  28. package/dist/EmployeeList-00LF0l6U.js +0 -696
  29. package/dist/useDebounce-BngBuKwH.js +0 -12
@@ -0,0 +1,700 @@
1
+ import { toRaw as De, defineComponent as Se, ref as p, computed as _, watch as ye, resolveComponent as f, createElementBlock as A, openBlock as w, Fragment as Y, renderSlot as Ne, createVNode as n, unref as t, withCtx as F, createElementVNode as c, createBlock as D, createCommentVNode as N, isRef as he, renderList as Ue, toDisplayString as Q, onUnmounted as Be, h as fe, normalizeClass as Te, createTextVNode as Ae, withModifiers as ze } from "vue";
2
+ import { useCoreStore as ke, useI18n as Ie, RestaurantSelector as _e } from "@feedmepos/mf-common";
3
+ import { useSnackbar as Ce, components as Me, useDialog as Ke, useBreakpoints as Ge, FmButtonVariant as je } from "@feedmepos/ui-library";
4
+ import { S as be, _ as qe } from "./SelectFilter-DUj7GBtT.js";
5
+ import { _ as He } from "./app-jGOQVOD0.js";
6
+ import { H as Je } from "./HorizontalSplitter-o860F4xM.js";
7
+ import { _ as We } from "./index.vue_vue_type_script_setup_true_lang-Vc5ARO29.js";
8
+ import { u as Re } from "./useSearch-B6WK1LBB.js";
9
+ import { u as Qe } from "./useDebounce-B8ZPVS5C.js";
10
+ import { u as Le, E as Ye } from "./employee-Bh77woAn.js";
11
+ import { l as Ze } from "./lodash-BuzCumRN.js";
12
+ import { _ as Ve, a as Fe } from "./FormSection.vue_vue_type_script_setup_true_lang-BVb8c4YU.js";
13
+ import { u as Xe, a as el } from "./useRestaurantMap-e9fQJiLC.js";
14
+ import { u as Pe } from "./useLoading-CJnGoe22.js";
15
+ import { u as $e } from "./useAppStore-RlI38pvN.js";
16
+ /* empty css */
17
+ function we(P) {
18
+ return JSON.parse(JSON.stringify(P));
19
+ }
20
+ function xe(P) {
21
+ if (typeof structuredClone > "u")
22
+ return we(P);
23
+ try {
24
+ return structuredClone(De(P));
25
+ } catch {
26
+ return we(P);
27
+ }
28
+ }
29
+ const ll = { class: "fm-typo-en-title-md-600" }, al = { class: "space-y-40" }, tl = { class: "flex flex-row gap-16" }, sl = { class: "space-y-16" }, ol = { class: "flex gap-8 items-center justify-start" }, Ee = 4, rl = /* @__PURE__ */ Se({
30
+ __name: "EmployeeForm",
31
+ props: {
32
+ roleErrorMessage: {
33
+ type: String,
34
+ default: ""
35
+ }
36
+ },
37
+ emits: ["submitted"],
38
+ setup(P, { expose: oe, emit: d }) {
39
+ const x = $e(), h = ke(), k = Le(), re = Ce(), Z = Pe(re), C = d, { t: u } = Ie(), b = p(!1), E = p(!0), S = (e) => {
40
+ s.value = e ? xe(e) : z(), $.value = xe(s.value), I.value = [], U.value = s.value.restaurants.map((l) => l.restaurantId), s.value.passcode && (I.value = s.value.passcode.split(""), y.value = !0), E.value = !e, b.value = !0;
41
+ };
42
+ function z() {
43
+ return {
44
+ code: "",
45
+ isMasterUser: !1,
46
+ name: "",
47
+ passcode: "",
48
+ restaurants: []
49
+ };
50
+ }
51
+ const X = _(() => E.value ? u("hr.employee.form.add") : u("hr.employee.form.update")), ne = _(() => E.value ? u("common.create") : u("common.update")), $ = p(z()), s = p(z()), { searchKey: L, filter: ee } = Re(), ue = _(() => {
52
+ const e = {};
53
+ return x.roles.value.forEach((l) => {
54
+ e[l._id] = l.name;
55
+ }), e;
56
+ });
57
+ function K(e) {
58
+ const l = le(e) ?? "";
59
+ return ue.value[l] || "";
60
+ }
61
+ const M = _(() => h.restaurants.value.filter(({ _id: l, profile: r, managable: m }) => m ? ee([r.code, r.name, K(l)]) : U.value.includes(l)).map(({ _id: l, profile: r, managable: m }) => {
62
+ const g = x.roles.value.filter((v) => v.restaurants.some((V) => V.id == l)).map((v) => ({
63
+ label: v.name,
64
+ value: v._id,
65
+ disabled: !v.isUsable
66
+ }));
67
+ return {
68
+ value: l,
69
+ label: `${r.code ? r.code + "-" : ""}${r.name}`,
70
+ roleOptions: g,
71
+ disabled: !m
72
+ };
73
+ })), G = _(() => {
74
+ const e = {};
75
+ return s.value.restaurants.forEach((l) => {
76
+ e[l.restaurantId] = l.roleId;
77
+ }), e;
78
+ }), le = (e) => G.value[e] ?? null, ae = (e, l) => {
79
+ s.value.restaurants = [
80
+ ...s.value.restaurants.filter((r) => r.restaurantId !== e),
81
+ {
82
+ restaurantId: e,
83
+ roleId: l
84
+ }
85
+ ];
86
+ }, U = p(s.value.restaurants.map((e) => e.restaurantId)), j = _(
87
+ () => U.value.filter(
88
+ (e) => M.value.some((l) => l.value === e && !l.disabled)
89
+ )
90
+ ), q = _(() => {
91
+ const e = M.value.filter((l) => !l.disabled).length;
92
+ return e > 0 && e === j.value.length;
93
+ }), te = () => {
94
+ const e = U.value.filter((l) => !j.value.includes(l));
95
+ if (q.value === !0)
96
+ H(e);
97
+ else {
98
+ const l = M.value.filter((r) => !r.disabled).map((r) => r.value);
99
+ H([...l, ...e]);
100
+ }
101
+ }, H = (e) => {
102
+ U.value = e, s.value.restaurants = e.map((l) => {
103
+ var g, v;
104
+ const r = M.value.find((V) => V.value === l);
105
+ if (r != null && r.disabled)
106
+ return s.value.restaurants.find((V) => V.restaurantId === l) ?? {
107
+ restaurantId: l,
108
+ roleId: ""
109
+ };
110
+ const m = ((g = r == null ? void 0 : r.roleOptions.find((V) => !V.disabled)) == null ? void 0 : g.value) || "";
111
+ return {
112
+ restaurantId: l,
113
+ roleId: ((v = s.value.restaurants.find((V) => V.restaurantId === l)) == null ? void 0 : v.roleId) || m
114
+ };
115
+ });
116
+ }, I = p([]), y = p(!1);
117
+ function ie() {
118
+ y.value && (y.value = !1, I.value = []);
119
+ }
120
+ const R = p(!1), O = p(!1);
121
+ async function de() {
122
+ O.value = !0;
123
+ try {
124
+ const e = await Ye.generateEmployeePasscode();
125
+ y.value = !1, I.value = e.split("");
126
+ } finally {
127
+ O.value = !1;
128
+ }
129
+ }
130
+ const ce = Xe(
131
+ () => !Ze.isEqual(s.value, $.value),
132
+ () => {
133
+ b.value = !1;
134
+ }
135
+ );
136
+ async function J() {
137
+ const e = {
138
+ user: {
139
+ name: s.value.name,
140
+ passcode: s.value.passcode,
141
+ code: s.value.code
142
+ },
143
+ roles: s.value.restaurants
144
+ };
145
+ s.value.isMasterUser ? await k.createMasterEmployee(e) : (delete e.user.code, await k.createEmployee(e));
146
+ }
147
+ async function me() {
148
+ var r, m;
149
+ const e = $.value, l = {
150
+ user: {
151
+ name: s.value.name,
152
+ passcode: s.value.passcode
153
+ },
154
+ roles: s.value.restaurants,
155
+ previousRoles: (r = e.restaurants) == null ? void 0 : r.map((g) => ({
156
+ restaurantId: g.restaurantId,
157
+ roleId: g.roleId
158
+ }))
159
+ };
160
+ if (!s.value.isMasterUser)
161
+ await k.updateEmployee(e._id, l);
162
+ else {
163
+ const g = {
164
+ user: {
165
+ name: s.value.name,
166
+ passcode: s.value.passcode,
167
+ code: s.value.code
168
+ },
169
+ roles: s.value.restaurants,
170
+ previousRoles: (m = e.restaurants) == null ? void 0 : m.map((v) => ({
171
+ restaurantId: v.restaurantId,
172
+ roleId: v.roleId
173
+ }))
174
+ };
175
+ $.value.isMasterUser ? await k.updateMasterEmployee(e._id, g) : await k.migrateToMasterUser(e._id, g);
176
+ }
177
+ }
178
+ async function a() {
179
+ E.value ? await Z.minor(
180
+ async () => {
181
+ await J();
182
+ },
183
+ {
184
+ successMessage: u("hr.employee.create.successMessage"),
185
+ isLoading: R
186
+ }
187
+ ) : await Z.minor(
188
+ async () => {
189
+ await me();
190
+ },
191
+ {
192
+ successMessage: u("hr.employee.update.successMessage"),
193
+ isLoading: R
194
+ }
195
+ ), C("submitted"), b.value = !1;
196
+ }
197
+ return ye(
198
+ () => b.value,
199
+ (e) => {
200
+ }
201
+ ), oe({
202
+ show: b,
203
+ trigger: S
204
+ }), (e, l) => {
205
+ const r = f("FmSwitch"), m = f("FmTextField"), g = f("FmPinField"), v = f("FmFormGroup"), V = f("FmButton"), se = f("FmSearch"), W = f("FmCheckbox"), i = f("FmSelect"), B = f("fm-button"), Oe = f("fm-side-sheet");
206
+ return w(), A(Y, null, [
207
+ Ne(e.$slots, "default", { trigger: S }),
208
+ n(Oe, {
209
+ id: "unit-form",
210
+ modelValue: b.value,
211
+ "onUpdate:modelValue": l[9] || (l[9] = (o) => b.value = o),
212
+ "is-container": t(Me).FmForm,
213
+ "is-container-props": {
214
+ onValidationSuccess: a,
215
+ blameFormChildOnValidationFailed: !0
216
+ },
217
+ "max-width": 560,
218
+ "onOn:clickedAway": t(ce)
219
+ }, {
220
+ "side-sheet-header": F(() => [
221
+ c("p", ll, Q(X.value), 1)
222
+ ]),
223
+ "side-sheet-footer": F(() => [
224
+ c("div", ol, [
225
+ n(B, {
226
+ label: ne.value,
227
+ size: "lg",
228
+ type: "submit",
229
+ variant: "primary",
230
+ disabled: R.value
231
+ }, null, 8, ["label", "disabled"]),
232
+ n(B, {
233
+ label: t(u)("common.cancel"),
234
+ size: "lg",
235
+ variant: "tertiary",
236
+ disabled: R.value,
237
+ onClick: l[8] || (l[8] = () => b.value = !1)
238
+ }, null, 8, ["label", "disabled"])
239
+ ])
240
+ ]),
241
+ default: F(() => [
242
+ c("div", al, [
243
+ n(Ve, {
244
+ title: t(u)("hr.employee.form.employeeSetting")
245
+ }, {
246
+ default: F(() => [
247
+ n(Fe, {
248
+ label: t(u)("hr.employee.form.masterUserConfig")
249
+ }, {
250
+ default: F(() => [
251
+ n(r, {
252
+ modelValue: s.value.isMasterUser,
253
+ "onUpdate:modelValue": l[0] || (l[0] = (o) => s.value.isMasterUser = o),
254
+ value: "masterUser",
255
+ label: t(u)("hr.employee.form.masterUser"),
256
+ sublabel: t(u)("hr.employee.form.masterUserSublabel"),
257
+ "label-placement": "right"
258
+ }, null, 8, ["modelValue", "label", "sublabel"])
259
+ ]),
260
+ _: 1
261
+ }, 8, ["label"]),
262
+ c("div", tl, [
263
+ s.value.isMasterUser ? (w(), D(m, {
264
+ key: 0,
265
+ modelValue: s.value.code,
266
+ "onUpdate:modelValue": l[1] || (l[1] = (o) => s.value.code = o),
267
+ label: t(u)("hr.employee.form.code")
268
+ }, null, 8, ["modelValue", "label"])) : N("", !0),
269
+ n(m, {
270
+ modelValue: s.value.name,
271
+ "onUpdate:modelValue": l[2] || (l[2] = (o) => s.value.name = o),
272
+ class: "w-full",
273
+ label: t(u)("hr.employee.form.name"),
274
+ rules: [(o) => !!o || t(u)("hr.employee.form.required")]
275
+ }, null, 8, ["modelValue", "label", "rules"])
276
+ ]),
277
+ n(Fe, {
278
+ label: t(u)("hr.employee.form.passcode")
279
+ }, {
280
+ default: F(() => [
281
+ c("div", sl, [
282
+ n(v, {
283
+ modelValue: I.value,
284
+ "onUpdate:modelValue": l[5] || (l[5] = (o) => I.value = o),
285
+ rules: [
286
+ (o) => (o == null ? void 0 : o.filter((pe) => !!pe).length) !== Ee ? t(u)("hr.employee.form.passcodeRequired") : !0
287
+ ]
288
+ }, {
289
+ default: F(() => [
290
+ n(g, {
291
+ modelValue: I.value,
292
+ "onUpdate:modelValue": l[3] || (l[3] = (o) => I.value = o),
293
+ length: Ee,
294
+ masked: y.value,
295
+ onComplete: l[4] || (l[4] = (o) => s.value.passcode = o),
296
+ onFocus: ie
297
+ }, null, 8, ["modelValue", "masked"])
298
+ ]),
299
+ _: 1
300
+ }, 8, ["modelValue", "rules"]),
301
+ n(V, {
302
+ variant: "secondary",
303
+ "text-color": "primary",
304
+ "border-color": "primary",
305
+ label: t(u)("hr.employee.form.passcodeGenerate"),
306
+ size: "md",
307
+ loading: O.value,
308
+ onClick: de
309
+ }, null, 8, ["label", "loading"])
310
+ ])
311
+ ]),
312
+ _: 1
313
+ }, 8, ["label"])
314
+ ]),
315
+ _: 1
316
+ }, 8, ["title"]),
317
+ n(Ve, {
318
+ title: t(u)("hr.employee.form.role")
319
+ }, {
320
+ default: F(() => [
321
+ n(se, {
322
+ modelValue: t(L),
323
+ "onUpdate:modelValue": l[6] || (l[6] = (o) => he(L) ? L.value = o : null),
324
+ placeholder: t(u)("hr.restaurant.search.placeholder")
325
+ }, null, 8, ["modelValue", "placeholder"]),
326
+ n(v, {
327
+ modelValue: U.value,
328
+ "onUpdate:modelValue": l[7] || (l[7] = (o) => U.value = o),
329
+ rules: [(o) => o.length > 0 || t(u)("hr.employee.form.atLeastOneRestaurant")]
330
+ }, {
331
+ default: F(() => [
332
+ n(W, {
333
+ "model-value": q.value,
334
+ label: t(u)("hr.employee.form.all"),
335
+ value: "1",
336
+ indeterminate: j.value.length > 0,
337
+ "onUpdate:modelValue": te
338
+ }, null, 8, ["model-value", "label", "indeterminate"]),
339
+ (w(!0), A(Y, null, Ue(M.value, (o, pe) => {
340
+ var ge;
341
+ return w(), A(Y, { key: pe }, [
342
+ n(W, {
343
+ "model-value": U.value,
344
+ label: o.label,
345
+ value: o.value,
346
+ disabled: o.disabled,
347
+ "onUpdate:modelValue": H
348
+ }, null, 8, ["model-value", "label", "value", "disabled"]),
349
+ U.value.includes(o.value) ? (w(), D(i, {
350
+ key: 0,
351
+ class: "ml-32 mr-8",
352
+ items: o.roleOptions,
353
+ "model-value": le(o.value),
354
+ multiselect: !1,
355
+ placeholder: ((ge = o.roleOptions.find((ve) => !ve.disabled) ?? o.roleOptions[0]) == null ? void 0 : ge.label) ?? "",
356
+ disabled: o.disabled,
357
+ "onUpdate:modelValue": (ve) => ae(o.value, ve)
358
+ }, null, 8, ["items", "model-value", "placeholder", "disabled", "onUpdate:modelValue"])) : N("", !0)
359
+ ], 64);
360
+ }), 128))
361
+ ]),
362
+ _: 1
363
+ }, 8, ["modelValue", "rules"])
364
+ ]),
365
+ _: 1
366
+ }, 8, ["title"])
367
+ ])
368
+ ]),
369
+ _: 1
370
+ }, 8, ["modelValue", "is-container", "is-container-props", "onOn:clickedAway"])
371
+ ], 64);
372
+ };
373
+ }
374
+ }), nl = {
375
+ class: "space-y-8"
376
+ }, ul = {
377
+ class: "xs:hidden flex w-full items-start justify-between"
378
+ }, il = {
379
+ class: "flex items-start gap-8"
380
+ }, dl = {
381
+ class: "flex"
382
+ }, cl = {
383
+ class: "space-y-4 sm:hidden md:hidden lg:hidden"
384
+ }, ml = {
385
+ class: "px-16"
386
+ }, pl = {
387
+ class: "px-16 flex items-start gap-8"
388
+ }, vl = {
389
+ class: "flex h-full flex-col overflow-auto"
390
+ }, fl = {
391
+ class: "pb-64 sm:hidden md:hidden lg:hidden"
392
+ }, yl = {
393
+ class: "space-y-4"
394
+ }, hl = {
395
+ class: "fm-typo-en-body-lg-600"
396
+ }, gl = {
397
+ key: 0,
398
+ class: "mr-4"
399
+ }, _l = {
400
+ class: "text-fm-color-typo-secondary"
401
+ }, T = 200, bl = /* @__PURE__ */ Se({
402
+ __name: "EmployeeList",
403
+ setup(P, {
404
+ expose: oe
405
+ }) {
406
+ const {
407
+ t: d
408
+ } = Ie(), x = p(), h = Le(), {
409
+ currentBusiness: k,
410
+ sessionUser: re
411
+ } = ke(), Z = _(() => h.listEmployees.value), {
412
+ searchKey: C
413
+ } = Re(""), u = p(""), b = _(() => Z.value), E = _(() => h.totalEmployees.value), S = p(1), z = _(() => h.isLoading.value), X = _(() => {
414
+ var a;
415
+ return JSON.stringify({
416
+ businessId: ((a = k.value) == null ? void 0 : a._id) ?? "",
417
+ search: u.value.trim(),
418
+ restaurantIds: [...x.value ?? []].sort(),
419
+ roleIds: [...y.value ?? []].sort()
420
+ });
421
+ }), ne = el(), $ = (a) => {
422
+ const e = ne.value[a.restaurantId], l = e == null ? void 0 : e.profile.code;
423
+ let m = a.restaurantName || (e == null ? void 0 : e.profile.name) || "";
424
+ return a.roleName && (m = `${l ? l + " - " : ""}${m} (${a.roleName})`), m;
425
+ }, s = [{
426
+ accessorKey: "code",
427
+ size: 100,
428
+ header: () => d("hr.employee.columns.code")
429
+ }, {
430
+ accessorKey: "name",
431
+ header: () => d("hr.employee.columns.name"),
432
+ enableSorting: !1
433
+ }, {
434
+ accessorKey: "restaurants",
435
+ align: "center",
436
+ header: () => d("hr.employee.columns.restaurants"),
437
+ enableSorting: !1,
438
+ cell(a) {
439
+ return a.row.original.restaurants.map((e, l) => {
440
+ const r = $(e);
441
+ return fe("div", (l ? `
442
+ ` : "") + r);
443
+ });
444
+ }
445
+ }, {
446
+ accessorKey: "since",
447
+ header: () => d("hr.employee.columns.since"),
448
+ enableSorting: !1
449
+ }, {
450
+ id: "action",
451
+ size: 52,
452
+ meta: {
453
+ cellClass: "pl-16",
454
+ headerContentClass: "-mx-16"
455
+ },
456
+ cell: (a) => fe("div", {
457
+ class: "w-full flex justify-end items-center"
458
+ }, [fe(Me.FmButton, {
459
+ prependIcon: "delete",
460
+ variant: je.Tertiary,
461
+ textColor: "neutral-gray-400",
462
+ onClick: (e) => {
463
+ e.stopPropagation(), q(a.row.original);
464
+ }
465
+ })])
466
+ }], L = Ce(), ee = Ke(), ue = Pe(L), K = p(!1), M = p(), G = p(), le = _(() => h.restrictEmployeeIds.value);
467
+ function ae(a) {
468
+ const e = le.value.includes(a._id);
469
+ return e && L.open({
470
+ message: d("hr.employee.cannotUpdateMasterUser", {
471
+ name: a.name
472
+ }),
473
+ type: "error"
474
+ }), e;
475
+ }
476
+ const U = (a) => {
477
+ var l;
478
+ a && ae(a) || (l = G.value) == null || l.trigger(a);
479
+ }, {
480
+ breakpoints: j
481
+ } = Ge(), q = (a) => {
482
+ ae(a) || ee.open({
483
+ title: d("hr.employee.remove.title"),
484
+ message: d("hr.employee.remove.message", {
485
+ name: a.name
486
+ }),
487
+ minWidth: j.value.lg ? 588 : 0,
488
+ primaryActions: {
489
+ text: d("common.remove"),
490
+ close: !1,
491
+ variant: "destructive",
492
+ isLoading: K
493
+ },
494
+ secondaryActions: {
495
+ text: d("common.cancel"),
496
+ close: !0
497
+ }
498
+ }).onPrimary(async () => {
499
+ if (K.value) return;
500
+ const l = a.isMasterUser ? h.deleteMasterEmployee : h.deleteEmployee;
501
+ await ue.minor(async () => {
502
+ await l(a), await O();
503
+ }, {
504
+ isLoading: K,
505
+ successMessage: d("hr.employee.remove.successMessage", {
506
+ name: a.name
507
+ })
508
+ }).catch(() => {
509
+ }), ee.close();
510
+ });
511
+ }, te = p("");
512
+ function H() {
513
+ var a;
514
+ (a = G.value) == null || a.trigger();
515
+ }
516
+ const I = _(() => $e().roles.value.map((a) => ({
517
+ label: a.name,
518
+ value: a._id
519
+ }))), y = p();
520
+ async function ie() {
521
+ try {
522
+ await h.syncUsersMeta(), await O(), L.open({
523
+ message: d("hr.employee.sync.successMessage"),
524
+ type: "success"
525
+ });
526
+ } catch (a) {
527
+ console.error("Error syncing users:", a), L.open({
528
+ message: d("hr.employee.sync.errorMessage"),
529
+ type: "error"
530
+ });
531
+ }
532
+ }
533
+ async function R(a = S.value) {
534
+ var e, l;
535
+ await h.readEmployeesPage({
536
+ limit: T,
537
+ offset: (a - 1) * T,
538
+ search: u.value.trim() || void 0,
539
+ restaurantIds: (e = x.value) != null && e.length ? x.value : void 0,
540
+ roleIds: (l = y.value) != null && l.length ? y.value : void 0
541
+ });
542
+ }
543
+ async function O() {
544
+ var e;
545
+ if (!((e = k.value) != null && e._id)) return;
546
+ await R(S.value);
547
+ const a = Math.max(1, Math.ceil(E.value / T));
548
+ S.value > a && (S.value = a, await R(S.value));
549
+ }
550
+ async function de() {
551
+ var a, e;
552
+ return await h.readAllEmployeesPage({
553
+ search: u.value.trim() || void 0,
554
+ restaurantIds: (a = x.value) != null && a.length ? x.value : void 0,
555
+ roleIds: (e = y.value) != null && e.length ? y.value : void 0
556
+ }, E.value);
557
+ }
558
+ const ce = Qe(C, () => {
559
+ u.value = C.value;
560
+ }, 300);
561
+ Be(ce);
562
+ let J = !1;
563
+ async function me({
564
+ pageIndex: a
565
+ }) {
566
+ var e;
567
+ if ((e = k.value) != null && e._id && !J && !(a === 0 && S.value === 1 && b.value.length > 0)) {
568
+ J = !0, S.value = a + 1;
569
+ try {
570
+ await R(S.value);
571
+ } finally {
572
+ J = !1;
573
+ }
574
+ }
575
+ }
576
+ return ye(X, async () => {
577
+ var a;
578
+ S.value = 1, (a = k.value) != null && a._id && await R(1);
579
+ }, {
580
+ immediate: !0
581
+ }), ye(() => M.value && M.value.restaurants, (a) => {
582
+ a && a.length > 0 && (te.value = "");
583
+ }), oe({
584
+ create: H,
585
+ filteredEmployees: b,
586
+ exportEmployees: de
587
+ }), (a, e) => {
588
+ var se, W;
589
+ const l = f("FmButton"), r = f("FmTooltip"), m = f("FmSearch"), g = f("FmTable"), v = f("FmListItem"), V = f("FmList");
590
+ return w(), A(Y, null, [n(rl, {
591
+ ref_key: "employeeFormRef",
592
+ ref: G,
593
+ modelValue: M.value,
594
+ "onUpdate:modelValue": e[0] || (e[0] = (i) => M.value = i),
595
+ "role-error-message": te.value,
596
+ class: "gap-8",
597
+ onSubmitted: O
598
+ }, null, 8, ["modelValue", "role-error-message"]), c("div", nl, [c("div", ul, [c("div", il, [n(t(_e), {
599
+ modelValue: x.value,
600
+ "onUpdate:modelValue": e[1] || (e[1] = (i) => x.value = i),
601
+ "managable-only": !1,
602
+ multiple: "",
603
+ variant: "dark",
604
+ class: "!w-auto"
605
+ }, null, 8, ["modelValue"]), n(be, {
606
+ modelValue: y.value,
607
+ "onUpdate:modelValue": e[2] || (e[2] = (i) => y.value = i),
608
+ multiple: "",
609
+ variant: "dark",
610
+ items: I.value,
611
+ "selected-prefix": t(d)("hr.employee.filter.selected_role_prefix"),
612
+ placeholder: t(d)("hr.employee.filter.role_placeholder")
613
+ }, null, 8, ["modelValue", "items", "selected-prefix", "placeholder"])]), c("div", dl, [(se = t(re)) != null && se.role.isAdmin ? (w(), D(r, {
614
+ key: 0,
615
+ content: t(d)("hr.employee.sync.tooltip")
616
+ }, {
617
+ default: F(() => [n(l, {
618
+ icon: "refresh",
619
+ label: t(d)("hr.employee.sync.tooltip"),
620
+ variant: "tertiary",
621
+ onClick: ie
622
+ }, null, 8, ["label"])]),
623
+ _: 1
624
+ }, 8, ["content"])) : N("", !0), n(m, {
625
+ modelValue: t(C),
626
+ "onUpdate:modelValue": e[3] || (e[3] = (i) => he(C) ? C.value = i : null),
627
+ autofocus: "",
628
+ class: "pl-4 w-[320px]",
629
+ placeholder: t(d)("hr.employee.search.placeholder")
630
+ }, null, 8, ["modelValue", "placeholder"])])]), c("div", cl, [c("div", ml, [n(m, {
631
+ modelValue: t(C),
632
+ "onUpdate:modelValue": e[4] || (e[4] = (i) => he(C) ? C.value = i : null),
633
+ autofocus: "",
634
+ placeholder: t(d)("hr.employee.search.placeholder")
635
+ }, null, 8, ["modelValue", "placeholder"])]), n(Je), c("div", pl, [n(t(_e), {
636
+ modelValue: x.value,
637
+ "onUpdate:modelValue": e[5] || (e[5] = (i) => x.value = i),
638
+ "managable-only": !1,
639
+ multiple: "",
640
+ variant: "dark",
641
+ class: "!w-auto"
642
+ }, null, 8, ["modelValue"]), n(be, {
643
+ modelValue: y.value,
644
+ "onUpdate:modelValue": e[6] || (e[6] = (i) => y.value = i),
645
+ multiple: "",
646
+ items: I.value,
647
+ variant: "dark",
648
+ "selected-prefix": t(d)("hr.employee.filter.selected_role_prefix"),
649
+ placeholder: t(d)("hr.employee.filter.role_placeholder")
650
+ }, null, 8, ["modelValue", "items", "selected-prefix", "placeholder"])])]), (W = t(k)) != null && W._id ? (w(), D(He, {
651
+ key: 0
652
+ }, {
653
+ default: F(() => [c("div", vl, [E.value === 0 && !t(h).isLoading.value ? (w(), D(t(We), {
654
+ key: 0,
655
+ title: t(d)("hr.employee.noData.title"),
656
+ subtitle: t(d)("hr.employee.noData.subtitle")
657
+ }, null, 8, ["title", "subtitle"])) : N("", !0), E.value > 0 || t(h).isLoading.value ? (w(), D(g, {
658
+ key: X.value,
659
+ class: Te(["xs:hidden employee-list-table min-h-0 flex-1", {
660
+ "employee-list-table--pagination-loading": z.value
661
+ }]),
662
+ "column-defs": s,
663
+ "row-data": b.value,
664
+ "page-size": T,
665
+ "page-count": Math.ceil(E.value / T),
666
+ "row-count": E.value,
667
+ "fetch-fn": me,
668
+ "hide-footer": E.value <= T,
669
+ loading: t(h).isLoading.value,
670
+ virtual: !1,
671
+ "pin-header-row": "",
672
+ onRowClick: e[7] || (e[7] = (i) => U(i.original))
673
+ }, null, 8, ["class", "row-data", "page-count", "row-count", "hide-footer", "loading"])) : N("", !0), c("div", fl, [n(V, {
674
+ separator: ""
675
+ }, {
676
+ default: F(() => [(w(!0), A(Y, null, Ue(b.value, (i) => (w(), D(v, {
677
+ key: i._id,
678
+ class: "py-12 px-16 items-center justify-between",
679
+ onClick: (B) => U(i)
680
+ }, {
681
+ default: F(() => [c("div", yl, [c("p", hl, [i.code ? (w(), A("span", gl, Q(i.code) + ".", 1)) : N("", !0), Ae(Q(i.name), 1)]), c("div", _l, [c("p", null, Q(t(d)("hr.employee.restaurants", {
682
+ restaurants: i.restaurants.map((B) => $(B)).join(", ")
683
+ })), 1), c("p", null, " Since: " + Q(i.since), 1)])]), n(l, {
684
+ icon: "delete",
685
+ variant: "tertiary",
686
+ "text-color": "neutral-gray-400",
687
+ onClick: ze((B) => q(i), ["stop"])
688
+ }, null, 8, ["onClick"])]),
689
+ _: 2
690
+ }, 1032, ["onClick"]))), 128))]),
691
+ _: 1
692
+ })])])]),
693
+ _: 1
694
+ })) : N("", !0)])], 64);
695
+ };
696
+ }
697
+ }), Dl = /* @__PURE__ */ qe(bl, [["__scopeId", "data-v-0db27cb8"]]);
698
+ export {
699
+ Dl as default
700
+ };