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