@feedmepos/mf-hrm-portal 2.0.17 → 2.0.18-dev.2

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