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

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-Bd00VQx_.js} +4 -4
  2. package/dist/EmployeeList-CK7KmG5w.js +697 -0
  3. package/dist/{Main-BC_y5Gzg.js → Main-B_8kCVUX.js} +4 -4
  4. package/dist/{Main-BY_V1guq.js → Main-BlREdQ9j.js} +9 -9
  5. package/dist/{Main-Chau30wK.js → Main-DkBOgy7G.js} +5 -5
  6. package/dist/{PermissionSetList-CDUFrGRE.js → PermissionSetList-DfDMzjya.js} +5 -5
  7. package/dist/{PortalPermissionEditor.vue_vue_type_script_setup_true_lang-CGIontQw.js → PortalPermissionEditor.vue_vue_type_script_setup_true_lang-Akov0s-D.js} +683 -683
  8. package/dist/{RoleList-BVQ4zkA8.js → RoleList-BxXhMLc4.js} +7 -7
  9. package/dist/{TeamMemberList-D65MpqIr.js → TeamMemberList--YzyKgRn.js} +209 -208
  10. package/dist/{TimesheetList-Dc295zCI.js → TimesheetList-K8CKfOu5.js} +7 -7
  11. package/dist/{app-Iv5hLrRX.js → app-CDx8kP2V.js} +43 -43
  12. package/dist/app.js +1 -1
  13. package/dist/{dayjs.min-CJGjjQIJ.js → dayjs.min-SNComb-n.js} +1 -1
  14. package/dist/{employee-C2Qhr8xO.js → employee-CGtCzQdZ.js} +4 -4
  15. package/dist/{index-DzRWjF3a.js → index-Ctx7lXyr.js} +1 -1
  16. package/dist/{index-5ziPpN4I.js → index-qJ7dWPV1.js} +17 -17
  17. package/dist/{iteration-L8TLGaCI.js → iteration-Df2doI7u.js} +2 -2
  18. package/dist/{lodash-Bbes-RWy.js → lodash--VoFIg3j.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-C8L7eQVO.js} +3 -3
  22. package/dist/tsconfig.app.tsbuildinfo +1 -1
  23. package/dist/{useAppStore-e7cSGuDZ.js → useAppStore-FR1TO4HT.js} +1 -1
  24. package/dist/useDebounce-B8ZPVS5C.js +15 -0
  25. package/dist/{useLoading-C8ko-jia.js → useLoading-CKrnW2DY.js} +1 -1
  26. package/dist/{useReportPermissions-B0EDgKey.js → useReportPermissions-BeiN0ZNJ.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,697 @@
1
+ import { toRaw as Oe, defineComponent as Se, ref as p, computed as _, watch as ye, resolveComponent as f, createElementBlock as A, openBlock as F, Fragment as Y, renderSlot as Ne, createVNode as n, unref as t, withCtx as V, createElementVNode as c, createBlock as O, createCommentVNode as T, isRef as he, renderList as Ue, toDisplayString as Q, onUnmounted as Be, withDirectives as Te, h as fe, normalizeClass as Ae, vShow as ze, createTextVNode as Ke, withModifiers as Ge } 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 je, useBreakpoints as qe, FmButtonVariant as He } from "@feedmepos/ui-library";
4
+ import { S as be, _ as Je } from "./SelectFilter-DUj7GBtT.js";
5
+ import { _ as We } from "./app-CDx8kP2V.js";
6
+ import { H as Qe } from "./HorizontalSplitter-o860F4xM.js";
7
+ import { _ as Ye } from "./index.vue_vue_type_script_setup_true_lang-Vc5ARO29.js";
8
+ import { u as Re } from "./useSearch-B6WK1LBB.js";
9
+ import { u as Ze } from "./useDebounce-B8ZPVS5C.js";
10
+ import { u as Le, E as Xe } from "./employee-CGtCzQdZ.js";
11
+ import { l as el } from "./lodash--VoFIg3j.js";
12
+ import { _ as Ve, a as Fe } from "./FormSection.vue_vue_type_script_setup_true_lang-BVb8c4YU.js";
13
+ import { u as ll, a as al } from "./useRestaurantMap-e9fQJiLC.js";
14
+ import { u as Pe } from "./useLoading-CKrnW2DY.js";
15
+ import { u as $e } from "./useAppStore-FR1TO4HT.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(Oe(P));
25
+ } catch {
26
+ return we(P);
27
+ }
28
+ }
29
+ const tl = { class: "fm-typo-en-title-md-600" }, sl = { class: "space-y-40" }, ol = { class: "flex flex-row gap-16" }, rl = { class: "space-y-16" }, nl = { class: "flex gap-8 items-center justify-start" }, Ee = 4, ul = /* @__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 w = $e(), h = ke(), I = Le(), re = Ce(), Z = Pe(re), C = d, { t: u } = Ie(), x = p(!1), E = p(!0), U = (e) => {
40
+ s.value = e ? xe(e) : z(), $.value = xe(s.value), k.value = [], S.value = s.value.restaurants.map((l) => l.restaurantId), s.value.passcode && (k.value = s.value.passcode.split(""), y.value = !0), E.value = !e, x.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: R, filter: ee } = Re(), ue = _(() => {
52
+ const e = {};
53
+ return w.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)]) : S.value.includes(l)).map(({ _id: l, profile: r, managable: m }) => {
62
+ const g = w.roles.value.filter((v) => v.restaurants.some((b) => b.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
+ }, S = p(s.value.restaurants.map((e) => e.restaurantId)), j = _(
87
+ () => S.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 = S.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
+ S.value = e, s.value.restaurants = e.map((l) => {
103
+ var g, v;
104
+ const r = M.value.find((b) => b.value === l);
105
+ if (r != null && r.disabled)
106
+ return s.value.restaurants.find((b) => b.restaurantId === l) ?? {
107
+ restaurantId: l,
108
+ roleId: ""
109
+ };
110
+ const m = ((g = r == null ? void 0 : r.roleOptions.find((b) => !b.disabled)) == null ? void 0 : g.value) || "";
111
+ return {
112
+ restaurantId: l,
113
+ roleId: ((v = s.value.restaurants.find((b) => b.restaurantId === l)) == null ? void 0 : v.roleId) || m
114
+ };
115
+ });
116
+ }, k = p([]), y = p(!1);
117
+ function ie() {
118
+ y.value && (y.value = !1, k.value = []);
119
+ }
120
+ const L = p(!1), D = p(!1);
121
+ async function de() {
122
+ D.value = !0;
123
+ try {
124
+ const e = await Xe.generateEmployeePasscode();
125
+ y.value = !1, k.value = e.split("");
126
+ } finally {
127
+ D.value = !1;
128
+ }
129
+ }
130
+ const ce = ll(
131
+ () => !el.isEqual(s.value, $.value),
132
+ () => {
133
+ x.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 I.createMasterEmployee(e) : (delete e.user.code, await I.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 I.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 I.updateMasterEmployee(e._id, g) : await I.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: L
186
+ }
187
+ ) : await Z.minor(
188
+ async () => {
189
+ await me();
190
+ },
191
+ {
192
+ successMessage: u("hr.employee.update.successMessage"),
193
+ isLoading: L
194
+ }
195
+ ), C("submitted"), x.value = !1;
196
+ }
197
+ return ye(
198
+ () => x.value,
199
+ (e) => {
200
+ }
201
+ ), oe({
202
+ show: x,
203
+ trigger: U
204
+ }), (e, l) => {
205
+ const r = f("FmSwitch"), m = f("FmTextField"), g = f("FmPinField"), v = f("FmFormGroup"), b = f("FmButton"), se = f("FmSearch"), W = f("FmCheckbox"), i = f("FmSelect"), N = f("fm-button"), De = f("fm-side-sheet");
206
+ return F(), A(Y, null, [
207
+ Ne(e.$slots, "default", { trigger: U }),
208
+ n(De, {
209
+ id: "unit-form",
210
+ modelValue: x.value,
211
+ "onUpdate:modelValue": l[9] || (l[9] = (o) => x.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": V(() => [
221
+ c("p", tl, Q(X.value), 1)
222
+ ]),
223
+ "side-sheet-footer": V(() => [
224
+ c("div", nl, [
225
+ n(N, {
226
+ label: ne.value,
227
+ size: "lg",
228
+ type: "submit",
229
+ variant: "primary",
230
+ disabled: L.value
231
+ }, null, 8, ["label", "disabled"]),
232
+ n(N, {
233
+ label: t(u)("common.cancel"),
234
+ size: "lg",
235
+ variant: "tertiary",
236
+ disabled: L.value,
237
+ onClick: l[8] || (l[8] = () => x.value = !1)
238
+ }, null, 8, ["label", "disabled"])
239
+ ])
240
+ ]),
241
+ default: V(() => [
242
+ c("div", sl, [
243
+ n(Ve, {
244
+ title: t(u)("hr.employee.form.employeeSetting")
245
+ }, {
246
+ default: V(() => [
247
+ n(Fe, {
248
+ label: t(u)("hr.employee.form.masterUserConfig")
249
+ }, {
250
+ default: V(() => [
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", ol, [
263
+ s.value.isMasterUser ? (F(), O(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"])) : T("", !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: V(() => [
281
+ c("div", rl, [
282
+ n(v, {
283
+ modelValue: k.value,
284
+ "onUpdate:modelValue": l[5] || (l[5] = (o) => k.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: V(() => [
290
+ n(g, {
291
+ modelValue: k.value,
292
+ "onUpdate:modelValue": l[3] || (l[3] = (o) => k.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(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: D.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: V(() => [
321
+ n(se, {
322
+ modelValue: t(R),
323
+ "onUpdate:modelValue": l[6] || (l[6] = (o) => he(R) ? R.value = o : null),
324
+ placeholder: t(u)("hr.restaurant.search.placeholder")
325
+ }, null, 8, ["modelValue", "placeholder"]),
326
+ n(v, {
327
+ modelValue: S.value,
328
+ "onUpdate:modelValue": l[7] || (l[7] = (o) => S.value = o),
329
+ rules: [(o) => o.length > 0 || t(u)("hr.employee.form.atLeastOneRestaurant")]
330
+ }, {
331
+ default: V(() => [
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
+ (F(!0), A(Y, null, Ue(M.value, (o, pe) => {
340
+ var ge;
341
+ return F(), A(Y, { key: pe }, [
342
+ n(W, {
343
+ "model-value": S.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
+ S.value.includes(o.value) ? (F(), O(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"])) : T("", !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
+ }), il = {
375
+ class: "space-y-8"
376
+ }, dl = {
377
+ class: "xs:hidden flex w-full items-start justify-between"
378
+ }, cl = {
379
+ class: "flex items-start gap-8"
380
+ }, ml = {
381
+ class: "flex"
382
+ }, pl = {
383
+ class: "space-y-4 sm:hidden md:hidden lg:hidden"
384
+ }, vl = {
385
+ class: "px-16"
386
+ }, fl = {
387
+ class: "px-16 flex items-start gap-8"
388
+ }, yl = {
389
+ class: "flex h-full flex-col overflow-auto"
390
+ }, hl = {
391
+ class: "pb-64 sm:hidden md:hidden lg:hidden"
392
+ }, gl = {
393
+ class: "space-y-4"
394
+ }, _l = {
395
+ class: "fm-typo-en-body-lg-600"
396
+ }, bl = {
397
+ key: 0,
398
+ class: "mr-4"
399
+ }, Vl = {
400
+ class: "text-fm-color-typo-secondary"
401
+ }, B = 200, Fl = /* @__PURE__ */ Se({
402
+ __name: "EmployeeList",
403
+ setup(P, {
404
+ expose: oe
405
+ }) {
406
+ const {
407
+ t: d
408
+ } = Ie(), w = p(), h = Le(), {
409
+ currentBusiness: I,
410
+ sessionUser: re
411
+ } = ke(), Z = _(() => h.listEmployees.value), {
412
+ searchKey: C
413
+ } = Re(""), u = p(""), x = _(() => Z.value), E = _(() => h.totalEmployees.value), U = p(1), z = _(() => h.isLoading.value), X = _(() => {
414
+ var a;
415
+ return JSON.stringify({
416
+ businessId: ((a = I.value) == null ? void 0 : a._id) ?? "",
417
+ search: u.value.trim(),
418
+ restaurantIds: [...w.value ?? []].sort(),
419
+ roleIds: [...y.value ?? []].sort()
420
+ });
421
+ }), ne = al(), $ = (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: He.Tertiary,
461
+ textColor: "neutral-gray-400",
462
+ onClick: (e) => {
463
+ e.stopPropagation(), q(a.row.original);
464
+ }
465
+ })])
466
+ }], R = Ce(), ee = je(), ue = Pe(R), 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 && R.open({
470
+ message: d("hr.employee.cannotUpdateMasterUser", {
471
+ name: a.name
472
+ }),
473
+ type: "error"
474
+ }), e;
475
+ }
476
+ const S = (a) => {
477
+ var l;
478
+ a && ae(a) || (l = G.value) == null || l.trigger(a);
479
+ }, {
480
+ breakpoints: j
481
+ } = qe(), 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 D();
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 k = _(() => $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 D(), R.open({
523
+ message: d("hr.employee.sync.successMessage"),
524
+ type: "success"
525
+ });
526
+ } catch (a) {
527
+ console.error("Error syncing users:", a), R.open({
528
+ message: d("hr.employee.sync.errorMessage"),
529
+ type: "error"
530
+ });
531
+ }
532
+ }
533
+ async function L(a = U.value) {
534
+ var e, l;
535
+ await h.readEmployeesPage({
536
+ limit: B,
537
+ offset: (a - 1) * B,
538
+ search: u.value.trim() || void 0,
539
+ restaurantIds: (e = w.value) != null && e.length ? w.value : void 0,
540
+ roleIds: (l = y.value) != null && l.length ? y.value : void 0
541
+ });
542
+ }
543
+ async function D() {
544
+ var e;
545
+ if (!((e = I.value) != null && e._id)) return;
546
+ await L(U.value);
547
+ const a = Math.max(1, Math.ceil(E.value / B));
548
+ U.value > a && (U.value = a, await L(U.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 = w.value) != null && a.length ? w.value : void 0,
555
+ roleIds: (e = y.value) != null && e.length ? y.value : void 0
556
+ }, E.value);
557
+ }
558
+ const ce = Ze(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 = I.value) != null && e._id && !J) {
568
+ J = !0, U.value = a + 1;
569
+ try {
570
+ await L(U.value);
571
+ } finally {
572
+ J = !1;
573
+ }
574
+ }
575
+ }
576
+ return ye(X, () => {
577
+ U.value = 1;
578
+ }), ye(() => M.value && M.value.restaurants, (a) => {
579
+ a && a.length > 0 && (te.value = "");
580
+ }), oe({
581
+ create: H,
582
+ filteredEmployees: x,
583
+ exportEmployees: de
584
+ }), (a, e) => {
585
+ var se, W;
586
+ const l = f("FmButton"), r = f("FmTooltip"), m = f("FmSearch"), g = f("FmTable"), v = f("FmListItem"), b = f("FmList");
587
+ return F(), A(Y, null, [n(ul, {
588
+ ref_key: "employeeFormRef",
589
+ ref: G,
590
+ modelValue: M.value,
591
+ "onUpdate:modelValue": e[0] || (e[0] = (i) => M.value = i),
592
+ "role-error-message": te.value,
593
+ class: "gap-8",
594
+ onSubmitted: D
595
+ }, null, 8, ["modelValue", "role-error-message"]), c("div", il, [c("div", dl, [c("div", cl, [n(t(_e), {
596
+ modelValue: w.value,
597
+ "onUpdate:modelValue": e[1] || (e[1] = (i) => w.value = i),
598
+ "managable-only": !1,
599
+ multiple: "",
600
+ variant: "dark",
601
+ class: "!w-auto"
602
+ }, null, 8, ["modelValue"]), n(be, {
603
+ modelValue: y.value,
604
+ "onUpdate:modelValue": e[2] || (e[2] = (i) => y.value = i),
605
+ multiple: "",
606
+ variant: "dark",
607
+ items: k.value,
608
+ "selected-prefix": t(d)("hr.employee.filter.selected_role_prefix"),
609
+ placeholder: t(d)("hr.employee.filter.role_placeholder")
610
+ }, null, 8, ["modelValue", "items", "selected-prefix", "placeholder"])]), c("div", ml, [(se = t(re)) != null && se.role.isAdmin ? (F(), O(r, {
611
+ key: 0,
612
+ content: t(d)("hr.employee.sync.tooltip")
613
+ }, {
614
+ default: V(() => [n(l, {
615
+ icon: "refresh",
616
+ label: t(d)("hr.employee.sync.tooltip"),
617
+ variant: "tertiary",
618
+ onClick: ie
619
+ }, null, 8, ["label"])]),
620
+ _: 1
621
+ }, 8, ["content"])) : T("", !0), n(m, {
622
+ modelValue: t(C),
623
+ "onUpdate:modelValue": e[3] || (e[3] = (i) => he(C) ? C.value = i : null),
624
+ autofocus: "",
625
+ class: "pl-4 w-[320px]",
626
+ placeholder: t(d)("hr.employee.search.placeholder")
627
+ }, null, 8, ["modelValue", "placeholder"])])]), c("div", pl, [c("div", vl, [n(m, {
628
+ modelValue: t(C),
629
+ "onUpdate:modelValue": e[4] || (e[4] = (i) => he(C) ? C.value = i : null),
630
+ autofocus: "",
631
+ placeholder: t(d)("hr.employee.search.placeholder")
632
+ }, null, 8, ["modelValue", "placeholder"])]), n(Qe), c("div", fl, [n(t(_e), {
633
+ modelValue: w.value,
634
+ "onUpdate:modelValue": e[5] || (e[5] = (i) => w.value = i),
635
+ "managable-only": !1,
636
+ multiple: "",
637
+ variant: "dark",
638
+ class: "!w-auto"
639
+ }, null, 8, ["modelValue"]), n(be, {
640
+ modelValue: y.value,
641
+ "onUpdate:modelValue": e[6] || (e[6] = (i) => y.value = i),
642
+ multiple: "",
643
+ items: k.value,
644
+ variant: "dark",
645
+ "selected-prefix": t(d)("hr.employee.filter.selected_role_prefix"),
646
+ placeholder: t(d)("hr.employee.filter.role_placeholder")
647
+ }, null, 8, ["modelValue", "items", "selected-prefix", "placeholder"])])]), (W = t(I)) != null && W._id ? (F(), O(We, {
648
+ key: 0
649
+ }, {
650
+ default: V(() => [c("div", yl, [E.value === 0 && !t(h).isLoading.value ? (F(), O(t(Ye), {
651
+ key: 0,
652
+ title: t(d)("hr.employee.noData.title"),
653
+ subtitle: t(d)("hr.employee.noData.subtitle")
654
+ }, null, 8, ["title", "subtitle"])) : T("", !0), Te((F(), O(g, {
655
+ key: X.value,
656
+ class: Ae(["xs:hidden employee-list-table min-h-0 flex-1", {
657
+ "employee-list-table--pagination-loading": z.value
658
+ }]),
659
+ "column-defs": s,
660
+ "row-data": x.value,
661
+ "page-size": B,
662
+ "page-count": Math.ceil(E.value / B),
663
+ "row-count": E.value,
664
+ "fetch-fn": me,
665
+ "hide-footer": E.value <= B,
666
+ loading: t(h).isLoading.value,
667
+ virtual: !1,
668
+ "pin-header-row": "",
669
+ onRowClick: e[7] || (e[7] = (i) => S(i.original))
670
+ }, null, 8, ["class", "row-data", "page-count", "row-count", "hide-footer", "loading"])), [[ze, E.value > 0 || t(h).isLoading.value]]), c("div", hl, [n(b, {
671
+ separator: ""
672
+ }, {
673
+ default: V(() => [(F(!0), A(Y, null, Ue(x.value, (i) => (F(), O(v, {
674
+ key: i._id,
675
+ class: "py-12 px-16 items-center justify-between",
676
+ onClick: (N) => S(i)
677
+ }, {
678
+ default: V(() => [c("div", gl, [c("p", _l, [i.code ? (F(), A("span", bl, Q(i.code) + ".", 1)) : T("", !0), Ke(Q(i.name), 1)]), c("div", Vl, [c("p", null, Q(t(d)("hr.employee.restaurants", {
679
+ restaurants: i.restaurants.map((N) => $(N)).join(", ")
680
+ })), 1), c("p", null, " Since: " + Q(i.since), 1)])]), n(l, {
681
+ icon: "delete",
682
+ variant: "tertiary",
683
+ "text-color": "neutral-gray-400",
684
+ onClick: Ge((N) => q(i), ["stop"])
685
+ }, null, 8, ["onClick"])]),
686
+ _: 2
687
+ }, 1032, ["onClick"]))), 128))]),
688
+ _: 1
689
+ })])])]),
690
+ _: 1
691
+ })) : T("", !0)])], 64);
692
+ };
693
+ }
694
+ }), Bl = /* @__PURE__ */ Je(Fl, [["__scopeId", "data-v-20a87df1"]]);
695
+ export {
696
+ Bl as default
697
+ };