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