@feedmepos/mf-hrm-portal 2.0.20-dev.1 → 2.0.20-dev.3

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 (31) hide show
  1. package/dist/{AuditLogList-Bsj-qg8n.js → AuditLogList-7E8iWQWx.js} +4 -4
  2. package/dist/EmployeeList-DyNW3cUo.js +851 -0
  3. package/dist/{Main-CSMAtoMj.js → Main-BLJyOcEv.js} +184 -176
  4. package/dist/{Main-BGc6kNaR.js → Main-BZjZxFHp.js} +2008 -2001
  5. package/dist/Main-C9lMH4EN.js +90 -0
  6. package/dist/PermissionSetList-BuCp14Os.js +355 -0
  7. package/dist/{PortalPermissionEditor.vue_vue_type_script_setup_true_lang-CdWgTjZw.js → PortalPermissionEditor.vue_vue_type_script_setup_true_lang-BQSDnH-Z.js} +675 -661
  8. package/dist/RoleList-L8L1xmJ2.js +564 -0
  9. package/dist/TeamMemberList-DEN9rHqb.js +1124 -0
  10. package/dist/{TimesheetList-tFjvFHqH.js → TimesheetList-D88u0GFn.js} +61 -53
  11. package/dist/{app-CL7rUfL3.js → app-g_SrJtfC.js} +191 -193
  12. package/dist/app.js +1 -1
  13. package/dist/{dayjs.min-ChdFPuFV.js → dayjs.min-BGHzwXCt.js} +1 -1
  14. package/dist/employee-Dep-q_aU.js +200 -0
  15. package/dist/{iteration-BbD0nOgO.js → iteration-Dc-Bz5bA.js} +173 -175
  16. package/dist/{lodash-CDf3aG6G.js → lodash-Cxw1GZ6L.js} +1 -1
  17. package/dist/{rule-BJ-y3Sp8.js → rule-ClRtpdqO.js} +27 -26
  18. package/dist/src/types/team.d.ts +1 -0
  19. package/dist/style.css +1 -1
  20. package/dist/{timesheet-BmV02Rkz.js → timesheet-CZoSvFYT.js} +2 -2
  21. package/dist/tsconfig.app.tsbuildinfo +1 -1
  22. package/dist/{useAppStore-D8QAGZ02.js → useAppStore-CTBRpqmO.js} +36 -38
  23. package/dist/{useLoading-KpcQw0p4.js → useLoading-XvrLj1VM.js} +1 -1
  24. package/dist/{useReportPermissions-CmGJAz_N.js → useReportPermissions-nivbQm9V.js} +3 -3
  25. package/package.json +1 -1
  26. package/dist/EmployeeList-Cy2ayCko.js +0 -824
  27. package/dist/Main-D7bV8EuC.js +0 -86
  28. package/dist/PermissionSetList-CuHhDqWl.js +0 -347
  29. package/dist/RoleList-e0WUqt4Y.js +0 -545
  30. package/dist/TeamMemberList-CpPa1KyV.js +0 -1097
  31. package/dist/employee-kKV7UnHU.js +0 -204
@@ -0,0 +1,851 @@
1
+ import { toRaw as Te, defineComponent as $e, ref as v, computed as k, watch as X, resolveComponent as g, createElementBlock as P, openBlock as h, Fragment as de, renderSlot as je, createVNode as n, unref as o, withCtx as b, createElementVNode as m, createBlock as j, createCommentVNode as G, toDisplayString as K, renderList as Me, withKeys as ke, withModifiers as ee, normalizeClass as Le, onUnmounted as Ge, isRef as Ee, createTextVNode as qe, h as ue } from "vue";
2
+ import { useI18n as Ae, useCoreStore as He } from "@feedmepos/mf-common";
3
+ import { useSnackbar as Pe, components as De, useDialog as Je, useBreakpoints as We } from "@feedmepos/ui-library";
4
+ import { S as ce, _ as Qe } from "./SelectFilter-DUj7GBtT.js";
5
+ import { _ as Ye, a as Ze } from "./app-g_SrJtfC.js";
6
+ import { _ as Fe, u as Xe, H as ea } from "./FormItem.vue_vue_type_script_setup_true_lang-D3MOFOUI.js";
7
+ import { u as aa, _ as ta } from "./useDiscardConfirm-DPhEV6v0.js";
8
+ import { _ as la } from "./index.vue_vue_type_script_setup_true_lang-Vc5ARO29.js";
9
+ import { u as sa, _ as Ve } from "./useDebounce-CWb5QR9G.js";
10
+ import { u as Ne, E as oa } from "./employee-Dep-q_aU.js";
11
+ import { u as ze } from "./iteration-Dc-Bz5bA.js";
12
+ import { l as ra } from "./lodash-Cxw1GZ6L.js";
13
+ import { _ as Se } from "./FormSection.vue_vue_type_script_setup_true_lang-DknXTYiK.js";
14
+ import { u as Oe } from "./useLoading-XvrLj1VM.js";
15
+ import { u as we } from "./useAppStore-CTBRpqmO.js";
16
+ /* empty css */
17
+ function Ce(B) {
18
+ return JSON.parse(JSON.stringify(B));
19
+ }
20
+ function Re(B) {
21
+ if (typeof structuredClone > "u")
22
+ return Ce(B);
23
+ try {
24
+ return structuredClone(Te(B));
25
+ } catch {
26
+ return Ce(B);
27
+ }
28
+ }
29
+ const na = { class: "flex w-full items-center justify-between" }, ia = { class: "fm-typo-en-title-md-600" }, ua = { class: "space-y-40" }, ca = { class: "flex flex-row gap-16" }, da = { class: "space-y-16" }, ma = { class: "rounded-lg border border-fm-color-neutral-gray-200 p-16 space-y-16" }, pa = { class: "fm-typo-en-title-sm-600" }, fa = { class: "space-y-16" }, va = { class: "grid grid-cols-[minmax(0,1fr)_minmax(0,1fr)_auto] gap-16" }, ya = { class: "text-sm font-semibold text-fm-color-typo-primary" }, ha = { class: "text-sm font-semibold text-fm-color-typo-primary" }, ga = { class: "flex justify-self-end" }, _a = ["tabindex", "aria-disabled", "aria-label", "onClick", "onKeydown"], ba = { class: "flex gap-8 items-center justify-start" }, Ue = 4, wa = /* @__PURE__ */ $e({
30
+ __name: "EmployeeForm",
31
+ props: {
32
+ roleErrorMessage: {
33
+ type: String,
34
+ default: ""
35
+ }
36
+ },
37
+ emits: ["submitted"],
38
+ setup(B, { expose: me, emit: i }) {
39
+ const E = we(), f = ze(), R = Ne(), pe = Pe(), D = Oe(pe), fe = i, { t: c } = Ae(), U = v(!1), N = v(!0);
40
+ function T() {
41
+ return {
42
+ restaurantId: "",
43
+ roleId: ""
44
+ };
45
+ }
46
+ function ve(r) {
47
+ if (!r) return w();
48
+ const t = Re(r);
49
+ return {
50
+ code: t.code ?? "",
51
+ isMasterUser: t.isMasterUser ?? !1,
52
+ name: t.name ?? "",
53
+ passcode: t.passcode ?? "",
54
+ restaurants: t.restaurants.length > 0 ? t.restaurants.map(({ restaurantId: d, roleId: y }) => ({
55
+ restaurantId: d,
56
+ roleId: y
57
+ })) : [T()]
58
+ };
59
+ }
60
+ const ae = (r) => {
61
+ s.value = ve(r), F.value = Re(s.value), te.value = r == null ? void 0 : r._id, S.value = [], s.value.passcode && (S.value = s.value.passcode.split(""), M.value = !0), N.value = !r, U.value = !0;
62
+ };
63
+ function w() {
64
+ return {
65
+ code: "",
66
+ isMasterUser: !1,
67
+ name: "",
68
+ passcode: "",
69
+ restaurants: [T()]
70
+ };
71
+ }
72
+ const q = k(() => N.value ? c("hr.employee.form.add") : c("hr.employee.form.update")), H = k(() => N.value ? c("common.create") : c("common.update")), F = v(w()), s = v(w()), te = v(void 0), z = k(
73
+ () => s.value.restaurants.map((r) => r.restaurantId).filter(Boolean)
74
+ );
75
+ function V(r) {
76
+ var t;
77
+ return r ? !((t = f.restaurants.value.find((d) => d._id === r)) != null && t.managable) : !1;
78
+ }
79
+ function le(r = "") {
80
+ return f.restaurants.value.filter((t) => t.managable || t._id === r).map((t) => ({
81
+ label: `${t.profile.code ? `${t.profile.code} - ` : ""}${t.profile.name}`,
82
+ value: t._id,
83
+ disabled: z.value.includes(t._id) && t._id !== r
84
+ }));
85
+ }
86
+ function se(r, t = "") {
87
+ return r ? E.roles.value.filter((d) => d.restaurants.some((y) => y.id == r)).map((d) => ({
88
+ label: d.name,
89
+ value: d._id,
90
+ disabled: !d.isUsable && d._id !== t
91
+ })) : [];
92
+ }
93
+ function ye(r, t) {
94
+ var x, C, L;
95
+ const d = ((x = s.value.restaurants[r]) == null ? void 0 : x.roleId) ?? "", y = se(t, d), _ = ((C = y.find((A) => A.value === d && !A.disabled)) == null ? void 0 : C.value) ?? ((L = y.find((A) => !A.disabled)) == null ? void 0 : L.value) ?? "";
96
+ s.value.restaurants[r] = {
97
+ restaurantId: t,
98
+ roleId: _
99
+ };
100
+ }
101
+ function he(r, t) {
102
+ s.value.restaurants[r].roleId = t;
103
+ }
104
+ function ge() {
105
+ s.value.restaurants = [
106
+ ...s.value.restaurants,
107
+ T()
108
+ ];
109
+ }
110
+ function $(r) {
111
+ var d;
112
+ const t = ((d = s.value.restaurants[r]) == null ? void 0 : d.restaurantId) ?? "";
113
+ if (!V(t)) {
114
+ if (s.value.restaurants.length === 1) {
115
+ s.value.restaurants = [T()];
116
+ return;
117
+ }
118
+ s.value.restaurants = s.value.restaurants.filter(
119
+ (y, _) => _ !== r
120
+ );
121
+ }
122
+ }
123
+ const oe = k(() => {
124
+ const r = f.restaurants.value.some(
125
+ (d) => d.managable && !z.value.includes(d._id)
126
+ ), t = s.value.restaurants.every(
127
+ (d) => d.restaurantId && d.roleId
128
+ );
129
+ return r && t;
130
+ }), S = v([]), M = v(!1);
131
+ function J() {
132
+ M.value && (M.value = !1, S.value = []);
133
+ }
134
+ const O = v(!1), W = v(!1);
135
+ async function Z() {
136
+ W.value = !0;
137
+ try {
138
+ const r = await oa.generateEmployeePasscode();
139
+ M.value = !1, S.value = r.split("");
140
+ } finally {
141
+ W.value = !1;
142
+ }
143
+ }
144
+ const Q = aa(
145
+ () => !ra.isEqual(s.value, F.value),
146
+ () => {
147
+ U.value = !1;
148
+ }
149
+ );
150
+ async function re() {
151
+ const r = {
152
+ user: {
153
+ name: s.value.name,
154
+ passcode: s.value.passcode,
155
+ code: s.value.code
156
+ },
157
+ roles: s.value.restaurants
158
+ };
159
+ s.value.isMasterUser ? await R.createMasterEmployee(r) : (delete r.user.code, await R.createEmployee(r));
160
+ }
161
+ async function ne() {
162
+ var y, _;
163
+ const r = F.value, t = te.value, d = {
164
+ user: {
165
+ name: s.value.name,
166
+ passcode: s.value.passcode
167
+ },
168
+ roles: s.value.restaurants,
169
+ previousRoles: (y = r.restaurants) == null ? void 0 : y.map((x) => ({
170
+ restaurantId: x.restaurantId,
171
+ roleId: x.roleId
172
+ }))
173
+ };
174
+ if (!s.value.isMasterUser)
175
+ await R.updateEmployee(t, d);
176
+ else {
177
+ const x = {
178
+ user: {
179
+ name: s.value.name,
180
+ passcode: s.value.passcode,
181
+ code: s.value.code
182
+ },
183
+ roles: s.value.restaurants,
184
+ previousRoles: (_ = r.restaurants) == null ? void 0 : _.map((C) => ({
185
+ restaurantId: C.restaurantId,
186
+ roleId: C.roleId
187
+ }))
188
+ };
189
+ F.value.isMasterUser ? await R.updateMasterEmployee(t, x) : await R.migrateToMasterUser(t, x);
190
+ }
191
+ }
192
+ async function _e() {
193
+ N.value ? await D.minor(
194
+ async () => {
195
+ await re();
196
+ },
197
+ {
198
+ successMessage: c("hr.employee.create.successMessage"),
199
+ isLoading: O
200
+ }
201
+ ) : await D.minor(
202
+ async () => {
203
+ await ne();
204
+ },
205
+ {
206
+ successMessage: c("hr.employee.update.successMessage"),
207
+ isLoading: O
208
+ }
209
+ ), fe("submitted"), U.value = !1;
210
+ }
211
+ return X(
212
+ () => U.value,
213
+ (r) => {
214
+ }
215
+ ), me({
216
+ show: U,
217
+ trigger: ae
218
+ }), (r, t) => {
219
+ const d = g("FmIcon"), y = g("FmSwitch"), _ = g("FmTextField"), x = g("FmPinField"), C = g("FmFormGroup"), L = g("FmButton"), A = g("FmSelect"), e = g("fm-button"), l = g("fm-side-sheet");
220
+ return h(), P(de, null, [
221
+ je(r.$slots, "default", { trigger: ae }),
222
+ n(l, {
223
+ id: "unit-form",
224
+ "model-value": U.value,
225
+ "is-container": o(De).FmForm,
226
+ "is-container-props": {
227
+ onValidationSuccess: _e,
228
+ blameFormChildOnValidationFailed: !0
229
+ },
230
+ "max-width": 960,
231
+ "close-button": !1,
232
+ "onOn:clickedAway": o(Q)
233
+ }, {
234
+ "side-sheet-header": b(() => [
235
+ m("div", na, [
236
+ m("p", ia, K(q.value), 1),
237
+ n(d, {
238
+ name: "close",
239
+ size: "md",
240
+ class: "cursor-pointer",
241
+ onClick: o(Q)
242
+ }, null, 8, ["onClick"])
243
+ ])
244
+ ]),
245
+ "side-sheet-footer": b(() => [
246
+ m("div", ba, [
247
+ n(e, {
248
+ label: H.value,
249
+ size: "lg",
250
+ type: "submit",
251
+ variant: "primary",
252
+ disabled: O.value
253
+ }, null, 8, ["label", "disabled"]),
254
+ n(e, {
255
+ label: o(c)("common.cancel"),
256
+ size: "lg",
257
+ variant: "tertiary",
258
+ disabled: O.value,
259
+ onClick: o(Q)
260
+ }, null, 8, ["label", "disabled", "onClick"])
261
+ ])
262
+ ]),
263
+ default: b(() => [
264
+ m("div", ua, [
265
+ n(Se, {
266
+ title: o(c)("hr.employee.form.employeeSetting")
267
+ }, {
268
+ default: b(() => [
269
+ n(Fe, {
270
+ label: o(c)("hr.employee.form.masterUserConfig")
271
+ }, {
272
+ default: b(() => [
273
+ n(y, {
274
+ modelValue: s.value.isMasterUser,
275
+ "onUpdate:modelValue": t[0] || (t[0] = (a) => s.value.isMasterUser = a),
276
+ value: "masterUser",
277
+ label: o(c)("hr.employee.form.masterUser"),
278
+ sublabel: o(c)("hr.employee.form.masterUserSublabel"),
279
+ "label-placement": "right"
280
+ }, null, 8, ["modelValue", "label", "sublabel"])
281
+ ]),
282
+ _: 1
283
+ }, 8, ["label"]),
284
+ m("div", ca, [
285
+ s.value.isMasterUser ? (h(), j(_, {
286
+ key: 0,
287
+ modelValue: s.value.code,
288
+ "onUpdate:modelValue": t[1] || (t[1] = (a) => s.value.code = a),
289
+ label: o(c)("hr.employee.form.code")
290
+ }, null, 8, ["modelValue", "label"])) : G("", !0),
291
+ n(_, {
292
+ modelValue: s.value.name,
293
+ "onUpdate:modelValue": t[2] || (t[2] = (a) => s.value.name = a),
294
+ class: "w-full",
295
+ label: o(c)("hr.employee.form.name"),
296
+ rules: [(a) => !!a || o(c)("hr.employee.form.required")]
297
+ }, null, 8, ["modelValue", "label", "rules"])
298
+ ]),
299
+ n(Fe, {
300
+ label: o(c)("hr.employee.form.passcode")
301
+ }, {
302
+ default: b(() => [
303
+ m("div", da, [
304
+ n(C, {
305
+ modelValue: S.value,
306
+ "onUpdate:modelValue": t[5] || (t[5] = (a) => S.value = a),
307
+ rules: [
308
+ (a) => (a == null ? void 0 : a.filter((u) => !!u).length) !== Ue ? o(c)("hr.employee.form.passcodeRequired") : !0
309
+ ]
310
+ }, {
311
+ default: b(() => [
312
+ n(x, {
313
+ modelValue: S.value,
314
+ "onUpdate:modelValue": t[3] || (t[3] = (a) => S.value = a),
315
+ length: Ue,
316
+ masked: M.value,
317
+ onComplete: t[4] || (t[4] = (a) => s.value.passcode = a),
318
+ onFocus: J
319
+ }, null, 8, ["modelValue", "masked"])
320
+ ]),
321
+ _: 1
322
+ }, 8, ["modelValue", "rules"]),
323
+ n(L, {
324
+ variant: "secondary",
325
+ "text-color": "primary",
326
+ "border-color": "primary",
327
+ label: o(c)("hr.employee.form.passcodeGenerate"),
328
+ size: "md",
329
+ loading: W.value,
330
+ onClick: Z
331
+ }, null, 8, ["label", "loading"])
332
+ ])
333
+ ]),
334
+ _: 1
335
+ }, 8, ["label"])
336
+ ]),
337
+ _: 1
338
+ }, 8, ["title"]),
339
+ n(Se, null, {
340
+ default: b(() => [
341
+ n(C, {
342
+ modelValue: s.value.restaurants,
343
+ "onUpdate:modelValue": t[6] || (t[6] = (a) => s.value.restaurants = a),
344
+ tag: "div",
345
+ rules: [
346
+ (a) => a.length > 0 || o(c)("hr.employee.form.atLeastOneRestaurant"),
347
+ (a) => a.every((u) => u.restaurantId && u.roleId) || o(c)("hr.employee.form.roleRequired")
348
+ ]
349
+ }, {
350
+ default: b(() => [
351
+ m("div", ma, [
352
+ m("div", pa, K(o(c)("hr.employee.form.assignmentSection")), 1),
353
+ m("div", fa, [
354
+ m("div", va, [
355
+ m("div", ya, K(o(c)("hr.employee.columns.restaurants")), 1),
356
+ m("div", ha, K(o(c)("hr.employee.form.role")), 1),
357
+ t[7] || (t[7] = m("div", null, null, -1))
358
+ ]),
359
+ (h(!0), P(de, null, Me(s.value.restaurants, (a, u) => (h(), P("div", {
360
+ key: `${a.restaurantId || "new"}-${u}`,
361
+ class: "grid grid-cols-[minmax(0,1fr)_minmax(0,1fr)_auto] items-center gap-16"
362
+ }, [
363
+ n(A, {
364
+ class: "min-w-0",
365
+ "model-value": a.restaurantId,
366
+ items: le(a.restaurantId),
367
+ multiselect: !1,
368
+ placeholder: o(c)("hr.employee.columns.restaurants"),
369
+ disabled: V(a.restaurantId),
370
+ "onUpdate:modelValue": (I) => ye(u, I)
371
+ }, null, 8, ["model-value", "items", "placeholder", "disabled", "onUpdate:modelValue"]),
372
+ n(A, {
373
+ class: "min-w-0",
374
+ "model-value": a.roleId,
375
+ items: se(a.restaurantId, a.roleId),
376
+ multiselect: !1,
377
+ placeholder: o(c)("hr.employee.form.role"),
378
+ disabled: !a.restaurantId || V(a.restaurantId),
379
+ "onUpdate:modelValue": (I) => he(u, I)
380
+ }, null, 8, ["model-value", "items", "placeholder", "disabled", "onUpdate:modelValue"]),
381
+ m("div", ga, [
382
+ s.value.restaurants.length > 1 ? (h(), P("div", {
383
+ key: 0,
384
+ role: "button",
385
+ tabindex: V(a.restaurantId) ? -1 : 0,
386
+ "aria-disabled": V(a.restaurantId),
387
+ class: Le(["inline-flex h-40 w-40 shrink-0 items-center justify-center rounded-lg text-fm-color-neutral-gray-400 transition-colors hover:bg-fm-color-neutral-gray-100 focus:outline-none focus:ring-2 focus:ring-fm-color-primary disabled:cursor-not-allowed disabled:text-fm-color-neutral-gray-200 disabled:hover:bg-transparent", {
388
+ "cursor-pointer": !V(a.restaurantId),
389
+ "pointer-events-none": V(a.restaurantId)
390
+ }]),
391
+ "aria-label": o(c)("common.remove"),
392
+ onClick: ee((I) => $(u), ["stop"]),
393
+ onKeydown: [
394
+ ke(ee((I) => $(u), ["prevent", "stop"]), ["enter"]),
395
+ ke(ee((I) => $(u), ["prevent", "stop"]), ["space"])
396
+ ]
397
+ }, [
398
+ n(d, {
399
+ name: "delete",
400
+ size: "md"
401
+ })
402
+ ], 42, _a)) : G("", !0)
403
+ ])
404
+ ]))), 128))
405
+ ]),
406
+ n(L, {
407
+ type: "button",
408
+ variant: "secondary",
409
+ "text-color": "primary",
410
+ "border-color": "primary",
411
+ "prepend-icon": "add",
412
+ label: o(c)("hr.employee.form.addAnother"),
413
+ size: "md",
414
+ disabled: !oe.value,
415
+ onClick: ee(ge, ["stop"])
416
+ }, null, 8, ["label", "disabled"])
417
+ ])
418
+ ]),
419
+ _: 1
420
+ }, 8, ["modelValue", "rules"])
421
+ ]),
422
+ _: 1
423
+ })
424
+ ])
425
+ ]),
426
+ _: 1
427
+ }, 8, ["model-value", "is-container", "is-container-props", "onOn:clickedAway"])
428
+ ], 64);
429
+ };
430
+ }
431
+ }), xa = {
432
+ class: "space-y-8"
433
+ }, Ia = {
434
+ key: 0,
435
+ class: "flex w-full items-start justify-between"
436
+ }, ka = {
437
+ class: "flex items-start gap-8"
438
+ }, Ea = {
439
+ class: "flex"
440
+ }, Fa = {
441
+ key: 1,
442
+ class: "space-y-4"
443
+ }, Va = {
444
+ class: "px-16"
445
+ }, Sa = {
446
+ class: "px-16 flex items-start gap-8"
447
+ }, Ca = {
448
+ class: "flex h-full flex-col overflow-auto"
449
+ }, Ra = {
450
+ class: "pb-64 sm:hidden md:hidden lg:hidden"
451
+ }, Ua = {
452
+ class: "space-y-4"
453
+ }, $a = {
454
+ class: "fm-typo-en-body-lg-600"
455
+ }, Ma = {
456
+ key: 0,
457
+ class: "mr-4"
458
+ }, La = {
459
+ class: "text-fm-color-typo-secondary"
460
+ }, Y = 200, Aa = /* @__PURE__ */ $e({
461
+ __name: "EmployeeList",
462
+ setup(B, {
463
+ expose: me
464
+ }) {
465
+ const {
466
+ t: i
467
+ } = Ae(), E = v(), f = Ne(), R = ze(), pe = He(), {
468
+ currentBusiness: D,
469
+ sessionUser: fe
470
+ } = pe, c = we(), U = k(() => R.isLoading.value), N = v(c.roles.value.length === 0);
471
+ X(R.restaurants, (e) => {
472
+ if (e.length > 0 && f.listEmployees.value.length > 0) {
473
+ const l = new Map(e.map((a) => [a._id, a]));
474
+ f.listEmployees.value = f.listEmployees.value.map((a) => ({
475
+ ...a,
476
+ restaurants: a.restaurants.map((u) => {
477
+ var I, ie;
478
+ return {
479
+ ...u,
480
+ restaurantName: ((I = l.get(u.restaurantId)) == null ? void 0 : I.profile.name) || u.restaurantName,
481
+ restaurantCode: ((ie = l.get(u.restaurantId)) == null ? void 0 : ie.profile.code) ?? void 0
482
+ };
483
+ })
484
+ }));
485
+ }
486
+ });
487
+ const T = k(() => R.restaurants.value.map((e) => ({
488
+ label: `${e.profile.code ? `${e.profile.code} - ` : ""}${e.profile.name}`,
489
+ value: e._id
490
+ }))), ve = X(c.roles, (e) => {
491
+ if (e.length > 0) {
492
+ if (N.value = !1, f.listEmployees.value.length > 0) {
493
+ const l = new Map(e.map((a) => [a._id, a.name]));
494
+ f.listEmployees.value = f.listEmployees.value.map((a) => ({
495
+ ...a,
496
+ restaurants: a.restaurants.map((u) => ({
497
+ ...u,
498
+ roleName: l.get(u.roleId) || u.roleName
499
+ }))
500
+ }));
501
+ }
502
+ ve();
503
+ }
504
+ }), ae = k(() => f.listEmployees.value), {
505
+ searchKey: w
506
+ } = Xe(), q = v(""), H = k(() => ae.value), F = k(() => f.totalEmployees.value), s = v(1), te = k(() => f.isLoading.value), z = v(!1), V = k(() => {
507
+ var e;
508
+ return JSON.stringify({
509
+ businessId: ((e = D.value) == null ? void 0 : e._id) ?? "",
510
+ search: q.value.trim(),
511
+ restaurantIds: [...E.value ?? []].sort(),
512
+ roleIds: [...t.value ?? []].sort()
513
+ });
514
+ }), le = (e) => {
515
+ const l = e.restaurantCode, a = e.restaurantName;
516
+ return l ? `${l} - ${a}` : a;
517
+ }, se = (e) => e.roleName || "-";
518
+ function ye(e) {
519
+ return [{
520
+ label: i("hr.employee.form.update"),
521
+ onClick: () => Z(e)
522
+ }, {
523
+ label: i("hr.employee.remove.title"),
524
+ onClick: () => re(e),
525
+ itemClass: "text-fm-color-typo-error"
526
+ }];
527
+ }
528
+ const he = ({
529
+ employee: e,
530
+ className: l = ""
531
+ }) => n("div", {
532
+ class: l,
533
+ onClick: (a) => {
534
+ a.stopPropagation();
535
+ }
536
+ }, [n(ta, {
537
+ items: ye(e)
538
+ }, null)]), ge = [{
539
+ accessorKey: "code",
540
+ size: 100,
541
+ header: () => i("hr.employee.columns.code")
542
+ }, {
543
+ accessorKey: "name",
544
+ header: () => i("hr.employee.columns.name"),
545
+ enableSorting: !1,
546
+ cell(e) {
547
+ const l = e.row.original;
548
+ return n("div", {
549
+ class: "flex items-center gap-8"
550
+ }, [n(De.FmAvatar, {
551
+ initials: l.name,
552
+ size: "sm",
553
+ class: "shrink-0"
554
+ }, null), n("span", {
555
+ class: "truncate"
556
+ }, [l.name])]);
557
+ }
558
+ }, {
559
+ accessorKey: "restaurants",
560
+ align: "center",
561
+ header: () => i("hr.employee.columns.restaurants"),
562
+ enableSorting: !1,
563
+ cell(e) {
564
+ return U.value || N.value ? ue(Ve) : e.row.original.restaurants.map((l, a) => {
565
+ const u = le(l);
566
+ return ue("div", {
567
+ key: l.restaurantId || a
568
+ }, (a ? `
569
+ ` : "") + u);
570
+ });
571
+ }
572
+ }, {
573
+ accessorKey: "assignedRole",
574
+ align: "center",
575
+ header: () => i("hr.employee.columns.assignedRole"),
576
+ enableSorting: !1,
577
+ cell(e) {
578
+ return U.value || N.value ? ue(Ve, {
579
+ width: "120px"
580
+ }) : e.row.original.restaurants.map((l, a) => {
581
+ const u = se(l);
582
+ return ue("div", {
583
+ key: l.restaurantId || a
584
+ }, (a ? `
585
+ ` : "") + u);
586
+ });
587
+ }
588
+ }, {
589
+ accessorKey: "since",
590
+ header: () => i("hr.employee.columns.since"),
591
+ enableSorting: !1
592
+ }, {
593
+ id: "action",
594
+ size: 52,
595
+ meta: {
596
+ cellClass: "pl-16",
597
+ headerContentClass: "-mx-16"
598
+ },
599
+ cell(e) {
600
+ return he({
601
+ employee: e.row.original,
602
+ className: "flex w-full items-center justify-end"
603
+ });
604
+ }
605
+ }], $ = Pe(), oe = Je(), S = Oe($), M = v(!1), J = v(), O = v();
606
+ function W(e) {
607
+ const l = e.isRestricted;
608
+ return l && $.open({
609
+ message: i("hr.employee.cannotUpdateMasterUser", {
610
+ name: e.name
611
+ }),
612
+ type: "error"
613
+ }), l;
614
+ }
615
+ const Z = (e) => {
616
+ var a;
617
+ e && W(e) || (a = O.value) == null || a.trigger(e);
618
+ }, {
619
+ breakpoints: Q
620
+ } = We(), re = (e) => {
621
+ W(e) || oe.open({
622
+ title: i("hr.employee.remove.title"),
623
+ message: i("hr.employee.remove.message", {
624
+ name: e.name
625
+ }),
626
+ minWidth: Q.value.lg ? 588 : 0,
627
+ primaryActions: {
628
+ text: i("common.remove"),
629
+ close: !1,
630
+ variant: "destructive",
631
+ isLoading: M
632
+ },
633
+ secondaryActions: {
634
+ text: i("common.cancel"),
635
+ close: !0
636
+ }
637
+ }).onPrimary(async () => {
638
+ if (M.value) return;
639
+ const a = e.isMasterUser ? f.deleteMasterEmployee : f.deleteEmployee;
640
+ await S.minor(async () => {
641
+ await a(e), await _();
642
+ }, {
643
+ isLoading: M,
644
+ successMessage: i("hr.employee.remove.successMessage", {
645
+ name: e.name
646
+ })
647
+ }).catch(() => {
648
+ }), oe.close();
649
+ });
650
+ }, ne = v("");
651
+ function _e() {
652
+ var e;
653
+ (e = O.value) == null || e.trigger();
654
+ }
655
+ const r = k(() => we().roles.value.map((e) => ({
656
+ label: e.name,
657
+ value: e._id
658
+ }))), t = v();
659
+ async function d() {
660
+ try {
661
+ await f.syncUsersMeta(), await _(), $.open({
662
+ message: i("hr.employee.sync.successMessage"),
663
+ type: "success"
664
+ });
665
+ } catch (e) {
666
+ console.error("Error syncing users:", e), $.open({
667
+ message: i("hr.employee.sync.errorMessage"),
668
+ type: "error"
669
+ });
670
+ }
671
+ }
672
+ async function y(e = s.value) {
673
+ var l, a;
674
+ try {
675
+ await f.readEmployeesPage({
676
+ limit: Y,
677
+ offset: (e - 1) * Y,
678
+ search: q.value.trim() || void 0,
679
+ restaurantIds: (l = E.value) != null && l.length ? E.value : void 0,
680
+ roleIds: (a = t.value) != null && a.length ? t.value : void 0
681
+ });
682
+ } catch (u) {
683
+ console.error("Failed to load employees:", u), $.open({
684
+ message: u instanceof Error ? u.message : String(u),
685
+ type: "error"
686
+ });
687
+ }
688
+ }
689
+ async function _() {
690
+ var l;
691
+ if (!((l = D.value) != null && l._id)) return;
692
+ await y(s.value);
693
+ const e = Math.max(1, Math.ceil(F.value / Y));
694
+ s.value > e && (s.value = e, await y(s.value));
695
+ }
696
+ async function x() {
697
+ var e, l;
698
+ return await f.readAllEmployeesPage({
699
+ search: q.value.trim() || void 0,
700
+ restaurantIds: (e = E.value) != null && e.length ? E.value : void 0,
701
+ roleIds: (l = t.value) != null && l.length ? t.value : void 0
702
+ }, F.value);
703
+ }
704
+ const C = sa(w, () => {
705
+ q.value = w.value;
706
+ }, 300);
707
+ Ge(C);
708
+ let L = !1;
709
+ async function A({
710
+ pageIndex: e
711
+ }) {
712
+ var l;
713
+ if ((l = D.value) != null && l._id && !L && !(e === 0 && s.value === 1 && H.value.length > 0)) {
714
+ L = !0, s.value = e + 1;
715
+ try {
716
+ await y(s.value);
717
+ } finally {
718
+ L = !1;
719
+ }
720
+ }
721
+ }
722
+ return X(V, async () => {
723
+ var e;
724
+ s.value = 1, z.value = !1, (e = D.value) != null && e._id && (await y(1), z.value = !0);
725
+ }, {
726
+ immediate: !0
727
+ }), X(() => J.value && J.value.restaurants, (e) => {
728
+ e && e.length > 0 && (ne.value = "");
729
+ }), me({
730
+ create: _e,
731
+ filteredEmployees: H,
732
+ exportEmployees: x
733
+ }), (e, l) => {
734
+ var xe, Ie;
735
+ const a = g("FmButton"), u = g("FmTooltip"), I = g("FmSearch"), ie = g("FmTable"), Ke = g("FmListItem"), Be = g("FmList");
736
+ return h(), P(de, null, [n(wa, {
737
+ ref_key: "employeeFormRef",
738
+ ref: O,
739
+ modelValue: J.value,
740
+ "onUpdate:modelValue": l[0] || (l[0] = (p) => J.value = p),
741
+ "role-error-message": ne.value,
742
+ class: "gap-8",
743
+ onSubmitted: _
744
+ }, null, 8, ["modelValue", "role-error-message"]), m("div", xa, [o(Q).xs ? (h(), P("div", Fa, [m("div", Va, [n(I, {
745
+ modelValue: o(w),
746
+ "onUpdate:modelValue": l[4] || (l[4] = (p) => Ee(w) ? w.value = p : null),
747
+ placeholder: o(i)("hr.employee.search.placeholder")
748
+ }, null, 8, ["modelValue", "placeholder"])]), n(ea), m("div", Sa, [n(ce, {
749
+ modelValue: E.value,
750
+ "onUpdate:modelValue": l[5] || (l[5] = (p) => E.value = p),
751
+ multiple: "",
752
+ items: T.value,
753
+ variant: "dark",
754
+ "selected-prefix": o(i)("hr.role.columns.restaurants"),
755
+ placeholder: o(i)("hr.role.columns.restaurants"),
756
+ class: "!w-auto"
757
+ }, null, 8, ["modelValue", "items", "selected-prefix", "placeholder"]), n(ce, {
758
+ modelValue: t.value,
759
+ "onUpdate:modelValue": l[6] || (l[6] = (p) => t.value = p),
760
+ multiple: "",
761
+ items: r.value,
762
+ variant: "dark",
763
+ "selected-prefix": o(i)("hr.employee.filter.selected_role_prefix"),
764
+ placeholder: o(i)("hr.employee.filter.role_placeholder")
765
+ }, null, 8, ["modelValue", "items", "selected-prefix", "placeholder"])])])) : (h(), P("div", Ia, [m("div", ka, [n(ce, {
766
+ modelValue: E.value,
767
+ "onUpdate:modelValue": l[1] || (l[1] = (p) => E.value = p),
768
+ multiple: "",
769
+ items: T.value,
770
+ variant: "dark",
771
+ "selected-prefix": o(i)("hr.role.columns.restaurants"),
772
+ placeholder: o(i)("hr.role.columns.restaurants"),
773
+ class: "!w-auto"
774
+ }, null, 8, ["modelValue", "items", "selected-prefix", "placeholder"]), n(ce, {
775
+ modelValue: t.value,
776
+ "onUpdate:modelValue": l[2] || (l[2] = (p) => t.value = p),
777
+ multiple: "",
778
+ variant: "dark",
779
+ items: r.value,
780
+ "selected-prefix": o(i)("hr.employee.filter.selected_role_prefix"),
781
+ placeholder: o(i)("hr.employee.filter.role_placeholder")
782
+ }, null, 8, ["modelValue", "items", "selected-prefix", "placeholder"])]), m("div", Ea, [(xe = o(fe)) != null && xe.role.isAdmin ? (h(), j(u, {
783
+ key: 0,
784
+ content: o(i)("hr.employee.sync.tooltip")
785
+ }, {
786
+ default: b(() => [n(a, {
787
+ icon: "refresh",
788
+ label: o(i)("hr.employee.sync.tooltip"),
789
+ variant: "tertiary",
790
+ onClick: d
791
+ }, null, 8, ["label"])]),
792
+ _: 1
793
+ }, 8, ["content"])) : G("", !0), n(I, {
794
+ modelValue: o(w),
795
+ "onUpdate:modelValue": l[3] || (l[3] = (p) => Ee(w) ? w.value = p : null),
796
+ autofocus: "",
797
+ class: "pl-4 w-[320px]",
798
+ placeholder: o(i)("hr.employee.search.placeholder")
799
+ }, null, 8, ["modelValue", "placeholder"])])])), (Ie = o(D)) != null && Ie._id ? (h(), j(Ye, {
800
+ key: 2
801
+ }, {
802
+ default: b(() => [m("div", Ca, [!z.value && o(f).isLoading.value ? (h(), j(Ze, {
803
+ key: 0
804
+ })) : !z.value || F.value === 0 ? (h(), j(o(la), {
805
+ key: 1,
806
+ title: o(i)("hr.employee.noData.title"),
807
+ subtitle: o(i)("hr.employee.noData.subtitle")
808
+ }, null, 8, ["title", "subtitle"])) : G("", !0), z.value ? (h(), j(ie, {
809
+ key: V.value,
810
+ class: Le(["xs:hidden employee-list-table min-h-0 flex-1", {
811
+ "employee-list-table--pagination-loading": te.value
812
+ }]),
813
+ "column-defs": ge,
814
+ "row-data": H.value,
815
+ "page-size": Y,
816
+ "page-count": Math.ceil(F.value / Y),
817
+ "row-count": F.value,
818
+ "fetch-fn": A,
819
+ "hide-footer": F.value <= Y,
820
+ loading: o(f).isLoading.value,
821
+ virtual: !1,
822
+ "pin-header-row": "",
823
+ onRowClick: l[7] || (l[7] = (p) => Z(p.original))
824
+ }, null, 8, ["class", "row-data", "page-count", "row-count", "hide-footer", "loading"])) : G("", !0), m("div", Ra, [n(Be, {
825
+ separator: ""
826
+ }, {
827
+ default: b(() => [(h(!0), P(de, null, Me(H.value, (p) => (h(), j(Ke, {
828
+ key: p._id,
829
+ class: "py-12 px-16 items-center justify-between",
830
+ onClick: (be) => Z(p)
831
+ }, {
832
+ default: b(() => [m("div", Ua, [m("p", $a, [p.code ? (h(), P("span", Ma, K(p.code) + ".", 1)) : G("", !0), qe(K(p.name), 1)]), m("div", La, [m("p", null, K(o(i)("hr.employee.restaurants", {
833
+ restaurants: p.restaurants.map((be) => le(be)).join(", ")
834
+ })), 1), m("p", null, " Since: " + K(p.since), 1)])]), n(a, {
835
+ icon: "delete",
836
+ variant: "tertiary",
837
+ "text-color": "neutral-gray-400",
838
+ onClick: ee((be) => re(p), ["stop"])
839
+ }, null, 8, ["onClick"])]),
840
+ _: 2
841
+ }, 1032, ["onClick"]))), 128))]),
842
+ _: 1
843
+ })])])]),
844
+ _: 1
845
+ })) : G("", !0)])], 64);
846
+ };
847
+ }
848
+ }), Za = /* @__PURE__ */ Qe(Aa, [["__scopeId", "data-v-cefb09f9"]]);
849
+ export {
850
+ Za as default
851
+ };