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