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