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