@feedmepos/mf-hrm-portal 1.1.6-dev → 2.0.1-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 (98) hide show
  1. package/dist/AuditLogList-DZENrFVl.js +474 -0
  2. package/dist/EmployeeList-DJ-Lx4RI.js +626 -0
  3. package/dist/{main-C370wsCl.js → Main-BiTy1HOn.js} +1502 -1531
  4. package/dist/Main-Dp5EpNkO.js +86 -0
  5. package/dist/{PageLayout.vue_vue_type_script_setup_true_lang-DuwNwJDM.js → PageLayout.vue_vue_type_script_setup_true_lang-HKK4cbW8.js} +2 -2
  6. package/dist/PermissionSetList-_pXwG00F.js +323 -0
  7. package/dist/PortalPermissionEditor.vue_vue_type_script_setup_true_lang-DrU4O0ww.js +3092 -0
  8. package/dist/ResponsiveFabButton.vue_vue_type_script_setup_true_lang-Cn-3MRBO.js +38 -0
  9. package/dist/RoleList-Ky-QqbsY.js +497 -0
  10. package/dist/{useSearch-C25VELOk.js → SelectFilter-NbXrJ4iH.js} +90 -101
  11. package/dist/TeamMemberList-DRrHuY31.js +973 -0
  12. package/dist/{TimesheetList-qaolOL4w.js → TimesheetList-BHHH42rb.js} +31 -29
  13. package/dist/api/audit-log/index.d.ts +14 -0
  14. package/dist/api/index.d.ts +5 -0
  15. package/dist/api/permission-assignment/index.d.ts +10 -0
  16. package/dist/api/permission-set/index.d.ts +8 -0
  17. package/dist/api/report-query/index.d.ts +5 -0
  18. package/dist/api/team/index.d.ts +2 -1
  19. package/dist/app-BA8Bg7Fs.js +3286 -0
  20. package/dist/app.js +1 -1
  21. package/dist/components/AppForm.vue.d.ts +3 -2
  22. package/dist/components/CheckboxInput.vue.d.ts +10 -4
  23. package/dist/components/CollapsibleWrapper.vue.d.ts +3 -2
  24. package/dist/components/form/SelectFilter.vue.d.ts +3 -2
  25. package/dist/components/layout/FormColumn.vue.d.ts +6 -3
  26. package/dist/components/layout/FormItem.vue.d.ts +2 -1
  27. package/dist/components/layout/FormSection.vue.d.ts +2 -1
  28. package/dist/components/layout/FullWrapper.vue.d.ts +6 -3
  29. package/dist/components/layout/PageLayout.vue.d.ts +2 -1
  30. package/dist/components/menu/BottomSheetMenu.vue.d.ts +2 -1
  31. package/dist/components/menu/BottomSheetMenuItem.vue.d.ts +6 -3
  32. package/dist/components/table/EmptyDataTemplate/index.vue.d.ts +6 -3
  33. package/dist/composables/useAppStore.d.ts +6 -6
  34. package/dist/composables/useDateRange.d.ts +1 -1
  35. package/dist/composables/useReportPermissions.d.ts +14 -0
  36. package/dist/composables/useRestaurantMap.d.ts +4 -8
  37. package/dist/composables/useSheet.d.ts +1 -1
  38. package/dist/dayjs.min-CEZE1nhx.js +282 -0
  39. package/dist/employee-pAypR6MP.js +144 -0
  40. package/dist/helpers/permission-set.d.ts +69 -0
  41. package/dist/helpers/portal-user.d.ts +8 -0
  42. package/dist/helpers/rule.d.ts +5 -4
  43. package/dist/index-C-bqkIkl.js +827 -0
  44. package/dist/index-bp5uff_3.js +10340 -0
  45. package/dist/{empty-placeholder-ey8LJtN1.js → index.vue_vue_type_script_setup_true_lang-Vc5ARO29.js} +43 -2
  46. package/dist/{lodash-B5BTJU4_.js → lodash-D4y44Bjw.js} +326 -343
  47. package/dist/router/shared.d.ts +4 -1
  48. package/dist/stores/employee.d.ts +4 -4
  49. package/dist/stores/permission-assignment.d.ts +277 -0
  50. package/dist/stores/permission-set.d.ts +265 -0
  51. package/dist/stores/role.d.ts +4 -4
  52. package/dist/stores/team.d.ts +300 -0
  53. package/dist/stores/timesheet.d.ts +19 -19
  54. package/dist/style.css +1 -1
  55. package/dist/team-DcE1JQXZ.js +33 -0
  56. package/dist/{timesheet-Cy-jSzje.js → timesheet-DLosZfP0.js} +14 -14
  57. package/dist/tsconfig.app.tsbuildinfo +1 -1
  58. package/dist/types/audit-log.d.ts +1 -0
  59. package/dist/types/permission-assignment.d.ts +20 -0
  60. package/dist/types/permission-set.d.ts +24 -0
  61. package/dist/types/report-query.d.ts +6 -0
  62. package/dist/types/team.d.ts +13 -3
  63. package/dist/useAppStore-BMisdZ57.js +168 -0
  64. package/dist/useLoading-JdhZp_cM.js +99 -0
  65. package/dist/useReportPermissions-OjM-nHtC.js +65 -0
  66. package/dist/{useRestaurantMap-CpS9-OSq.js → useRestaurantMap-D5BNPLKh.js} +7 -7
  67. package/dist/useSearch-B6WK1LBB.js +15 -0
  68. package/dist/views/audit-log/locales/index.d.ts +295 -0
  69. package/dist/views/hr/employee/{components/EmployeeForm.vue.d.ts → EmployeeForm.vue.d.ts} +10 -7
  70. package/dist/views/team/Main.vue.d.ts +2 -0
  71. package/dist/views/team/components/BasePermission.vue.d.ts +64 -0
  72. package/dist/views/team/components/{TeamMemberConditionPermission.vue.d.ts → ConditionPermission.vue.d.ts} +14 -1
  73. package/dist/views/team/components/InheritPermissionTooltip.vue.d.ts +14 -0
  74. package/dist/views/team/components/PermissionWithTooltip.vue.d.ts +14 -0
  75. package/dist/views/team/components/PortalPermissionEditor.vue.d.ts +68 -28
  76. package/dist/views/team/components/{TeamMemberRolePermission.vue.d.ts → PosRolePermission.vue.d.ts} +14 -1
  77. package/dist/views/team/locales/index.d.ts +200 -4
  78. package/dist/views/team/{components → member}/AddMemberForm.vue.d.ts +1 -0
  79. package/dist/views/team/member/TeamMemberList.vue.d.ts +4 -0
  80. package/dist/views/team/member/TeamMemberMasterUser.vue.d.ts +55 -0
  81. package/dist/views/team/permission-set/PermissionSetForm.vue.d.ts +19 -0
  82. package/dist/views/team/permission-set/PermissionSetList.vue.d.ts +5 -0
  83. package/package.json +15 -8
  84. package/dist/EmployeeList-CP42mLpi.js +0 -605
  85. package/dist/RoleList-CsctaXlu.js +0 -492
  86. package/dist/TeamMemberList-DtXoUa5K.js +0 -1508
  87. package/dist/app-G_Dbs0OJ.js +0 -1202
  88. package/dist/employee-BTWpYxn5.js +0 -449
  89. package/dist/index-8ift6lz3.js +0 -57
  90. package/dist/rule-CM7JgjNr.js +0 -142112
  91. package/dist/types/permission.d.ts +0 -4
  92. package/dist/useAppStore-zINIo0LR.js +0 -93
  93. package/dist/useLoading-CWBRIBiy.js +0 -141
  94. package/dist/views/team/components/TeamMemberBasePermission.vue.d.ts +0 -36
  95. package/dist/views/team/components/TeamMemberMasterUser.vue.d.ts +0 -718
  96. /package/dist/views/{hr/main.vue.d.ts → audit-log/AuditLogList.vue.d.ts} +0 -0
  97. /package/dist/views/{team/TeamMemberList.vue.d.ts → hr/Main.vue.d.ts} +0 -0
  98. /package/dist/views/team/{components → member}/MemberInfo.vue.d.ts +0 -0
@@ -0,0 +1,626 @@
1
+ import { createElementBlock as $, openBlock as g, createElementVNode as m, toRaw as Me, defineComponent as _e, ref as _, computed as w, watch as be, resolveComponent as p, Fragment as G, renderSlot as Ie, createVNode as u, unref as o, withCtx as h, createBlock as D, createCommentVNode as Q, isRef as ne, renderList as Ve, toDisplayString as K, onMounted as $e, h as re, createTextVNode as Oe, withModifiers as Le } from "vue";
2
+ import { useCoreStore as Fe, useI18n as we, RestaurantSelector as ce } from "@feedmepos/mf-common";
3
+ import { useSnackbar as xe, components as Ue, useDialog as Ne, useBreakpoints as Be, FmButtonVariant as De } from "@feedmepos/ui-library";
4
+ import { _ as Pe, S as pe } from "./SelectFilter-NbXrJ4iH.js";
5
+ import { _ as Te } from "./app-BA8Bg7Fs.js";
6
+ import { _ as ze } from "./index.vue_vue_type_script_setup_true_lang-Vc5ARO29.js";
7
+ import { u as ke } from "./useSearch-B6WK1LBB.js";
8
+ import { u as Se, E as Ae } from "./employee-pAypR6MP.js";
9
+ import { l as je } from "./lodash-D4y44Bjw.js";
10
+ import { u as Ke, _ as ve, a as fe, b as Ge } from "./useRestaurantMap-D5BNPLKh.js";
11
+ import { u as qe } from "./useLoading-JdhZp_cM.js";
12
+ import { u as ue } from "./useAppStore-BMisdZ57.js";
13
+ const He = {};
14
+ function Je(S, O) {
15
+ return g(), $("div", null, [...O[0] || (O[0] = [
16
+ m("div", { class: "h-px w-full bg-fm-color-neutral-gray-100" }, null, -1)
17
+ ])]);
18
+ }
19
+ const We = /* @__PURE__ */ Pe(He, [["render", Je]]);
20
+ function ye(S) {
21
+ return JSON.parse(JSON.stringify(S));
22
+ }
23
+ function he(S) {
24
+ if (typeof structuredClone > "u")
25
+ return ye(S);
26
+ try {
27
+ return structuredClone(Me(S));
28
+ } catch {
29
+ return ye(S);
30
+ }
31
+ }
32
+ const Qe = { class: "fm-typo-en-title-md-600" }, Xe = { class: "space-y-40" }, Ye = { class: "flex flex-row gap-16" }, Ze = { class: "space-y-16" }, el = { class: "flex gap-8 items-center justify-start" }, ge = 4, ll = /* @__PURE__ */ _e({
33
+ __name: "EmployeeForm",
34
+ props: {
35
+ roleErrorMessage: {
36
+ type: String,
37
+ default: ""
38
+ }
39
+ },
40
+ setup(S, { expose: O }) {
41
+ const i = ue(), E = Fe(), c = Se(), q = xe(), H = qe(q), { t: d } = we(), v = _(!1), L = _(!0), R = (l) => {
42
+ s.value = l ? he(l) : P(), x.value = he(s.value), a.value = [], b.value = s.value.restaurants.map((e) => e.restaurantId), s.value.passcode && (a.value = s.value.passcode.split(""), t.value = !0), L.value = !l, v.value = !0;
43
+ };
44
+ function P() {
45
+ return {
46
+ code: "",
47
+ isMasterUser: !1,
48
+ name: "",
49
+ passcode: "",
50
+ restaurants: []
51
+ };
52
+ }
53
+ const T = w(() => L.value ? d("hr.employee.form.add") : d("hr.employee.form.update")), X = w(() => L.value ? d("common.create") : d("common.update")), x = _(P()), s = _(P()), { searchKey: C, filter: z } = ke(), Y = w(() => {
54
+ const l = {};
55
+ return i.roles.value.forEach((e) => {
56
+ l[e._id] = e.name;
57
+ }), l;
58
+ });
59
+ function J(l) {
60
+ const e = A(l) ?? "";
61
+ return Y.value[e] || "";
62
+ }
63
+ const M = w(() => E.restaurants.value.filter(({ _id: e, profile: n, managable: I }) => I ? z([n.code, n.name, J(e)]) : b.value.includes(e)).map(({ _id: e, profile: n, managable: I }) => {
64
+ const B = i.roles.value.filter((V) => V.restaurants.some((F) => F.id == e)).map((V) => ({
65
+ label: V.name,
66
+ value: V._id,
67
+ disabled: !V.isUsable
68
+ }));
69
+ return {
70
+ value: e,
71
+ label: `${n.code ? n.code + "-" : ""}${n.name}`,
72
+ roleOptions: B,
73
+ disabled: !I
74
+ };
75
+ })), Z = w(() => {
76
+ const l = {};
77
+ return s.value.restaurants.forEach((e) => {
78
+ l[e.restaurantId] = e.roleId;
79
+ }), l;
80
+ }), A = (l) => Z.value[l] ?? null, W = (l, e) => {
81
+ s.value.restaurants = [
82
+ ...s.value.restaurants.filter((n) => n.restaurantId !== l),
83
+ {
84
+ restaurantId: l,
85
+ roleId: e
86
+ }
87
+ ];
88
+ }, b = _(s.value.restaurants.map((l) => l.restaurantId)), N = w(
89
+ () => b.value.filter(
90
+ (l) => M.value.some((e) => e.value === l && !e.disabled)
91
+ )
92
+ ), k = w(() => {
93
+ const l = M.value.filter((e) => !e.disabled).length;
94
+ return l > 0 && l === N.value.length;
95
+ }), ee = () => {
96
+ const l = b.value.filter((e) => !N.value.includes(e));
97
+ if (k.value === !0)
98
+ j(l);
99
+ else {
100
+ const e = M.value.filter((n) => !n.disabled).map((n) => n.value);
101
+ j([...e, ...l]);
102
+ }
103
+ }, j = (l) => {
104
+ b.value = l, s.value.restaurants = l.map((e) => {
105
+ var B, V;
106
+ const n = M.value.find((F) => F.value === e);
107
+ if (n != null && n.disabled)
108
+ return s.value.restaurants.find((F) => F.restaurantId === e) ?? {
109
+ restaurantId: e,
110
+ roleId: ""
111
+ };
112
+ const I = ((B = n == null ? void 0 : n.roleOptions.find((F) => !F.disabled)) == null ? void 0 : B.value) || "";
113
+ return {
114
+ restaurantId: e,
115
+ roleId: ((V = s.value.restaurants.find((F) => F.restaurantId === e)) == null ? void 0 : V.roleId) || I
116
+ };
117
+ });
118
+ }, a = _([]), t = _(!1);
119
+ function f() {
120
+ t.value && (t.value = !1, a.value = []);
121
+ }
122
+ async function U() {
123
+ const l = await Ae.generateEmployeePasscode();
124
+ t.value = !1, a.value = l.split("");
125
+ }
126
+ const y = Ke(
127
+ () => !je.isEqual(s.value, x.value),
128
+ () => {
129
+ v.value = !1;
130
+ }
131
+ );
132
+ async function le() {
133
+ const l = {
134
+ user: {
135
+ name: s.value.name,
136
+ passcode: s.value.passcode,
137
+ code: s.value.code
138
+ },
139
+ roles: s.value.restaurants
140
+ };
141
+ s.value.isMasterUser ? await c.createMasterEmployee(l) : (delete l.user.code, await c.createEmployee(l));
142
+ }
143
+ async function ae() {
144
+ const l = x.value, e = {
145
+ user: {
146
+ name: s.value.name,
147
+ passcode: s.value.passcode
148
+ },
149
+ roles: s.value.restaurants
150
+ };
151
+ if (!s.value.isMasterUser)
152
+ await c.updateEmployee(l._id, e);
153
+ else {
154
+ const n = {
155
+ user: {
156
+ name: s.value.name,
157
+ passcode: s.value.passcode,
158
+ code: s.value.code
159
+ },
160
+ roles: s.value.restaurants
161
+ };
162
+ x.value.isMasterUser ? await c.updateMasterEmployee(l._id, n) : await c.migrateToMasterUser(l._id, n);
163
+ }
164
+ }
165
+ async function te() {
166
+ L.value ? await H.minor(
167
+ async () => {
168
+ await le();
169
+ },
170
+ {
171
+ successMessage: d("hr.employee.create.successMessage")
172
+ }
173
+ ) : await H.minor(
174
+ async () => {
175
+ await ae();
176
+ },
177
+ {
178
+ successMessage: d("hr.employee.update.successMessage")
179
+ }
180
+ ), v.value = !1;
181
+ }
182
+ return be(
183
+ () => v.value,
184
+ (l) => {
185
+ }
186
+ ), O({
187
+ show: v,
188
+ trigger: R
189
+ }), (l, e) => {
190
+ const n = p("FmSwitch"), I = p("FmTextField"), B = p("FmPinField"), V = p("FmFormGroup"), F = p("FmButton"), Ee = p("FmSearch"), ie = p("FmCheckbox"), Re = p("FmSelect"), de = p("fm-button"), Ce = p("fm-side-sheet");
191
+ return g(), $(G, null, [
192
+ Ie(l.$slots, "default", { trigger: R }),
193
+ u(Ce, {
194
+ id: "unit-form",
195
+ modelValue: v.value,
196
+ "onUpdate:modelValue": e[9] || (e[9] = (r) => v.value = r),
197
+ "is-container": o(Ue).FmForm,
198
+ "is-container-props": {
199
+ onValidationSuccess: te,
200
+ blameFormChildOnValidationFailed: !0
201
+ },
202
+ "max-width": 560,
203
+ "onOn:clickedAway": o(y)
204
+ }, {
205
+ "side-sheet-header": h(() => [
206
+ m("p", Qe, K(T.value), 1)
207
+ ]),
208
+ "side-sheet-footer": h(() => [
209
+ m("div", el, [
210
+ u(de, {
211
+ label: X.value,
212
+ size: "lg",
213
+ type: "submit",
214
+ variant: "primary"
215
+ }, null, 8, ["label"]),
216
+ u(de, {
217
+ label: o(d)("common.cancel"),
218
+ size: "lg",
219
+ variant: "tertiary",
220
+ onClick: e[8] || (e[8] = () => v.value = !1)
221
+ }, null, 8, ["label"])
222
+ ])
223
+ ]),
224
+ default: h(() => [
225
+ m("div", Xe, [
226
+ u(ve, {
227
+ title: o(d)("hr.employee.form.employeeSetting")
228
+ }, {
229
+ default: h(() => [
230
+ u(fe, {
231
+ label: o(d)("hr.employee.form.masterUserConfig")
232
+ }, {
233
+ default: h(() => [
234
+ u(n, {
235
+ modelValue: s.value.isMasterUser,
236
+ "onUpdate:modelValue": e[0] || (e[0] = (r) => s.value.isMasterUser = r),
237
+ value: "masterUser",
238
+ label: o(d)("hr.employee.form.masterUser"),
239
+ sublabel: o(d)("hr.employee.form.masterUserSublabel"),
240
+ "label-placement": "right"
241
+ }, null, 8, ["modelValue", "label", "sublabel"])
242
+ ]),
243
+ _: 1
244
+ }, 8, ["label"]),
245
+ m("div", Ye, [
246
+ s.value.isMasterUser ? (g(), D(I, {
247
+ key: 0,
248
+ modelValue: s.value.code,
249
+ "onUpdate:modelValue": e[1] || (e[1] = (r) => s.value.code = r),
250
+ label: o(d)("hr.employee.form.code")
251
+ }, null, 8, ["modelValue", "label"])) : Q("", !0),
252
+ u(I, {
253
+ modelValue: s.value.name,
254
+ "onUpdate:modelValue": e[2] || (e[2] = (r) => s.value.name = r),
255
+ class: "w-full",
256
+ label: o(d)("hr.employee.form.name"),
257
+ rules: [(r) => !!r || o(d)("hr.employee.form.required")]
258
+ }, null, 8, ["modelValue", "label", "rules"])
259
+ ]),
260
+ u(fe, {
261
+ label: o(d)("hr.employee.form.passcode")
262
+ }, {
263
+ default: h(() => [
264
+ m("div", Ze, [
265
+ u(V, {
266
+ modelValue: a.value,
267
+ "onUpdate:modelValue": e[5] || (e[5] = (r) => a.value = r),
268
+ rules: [
269
+ (r) => (r == null ? void 0 : r.filter((oe) => !!oe).length) !== ge ? o(d)("hr.employee.form.passcodeRequired") : !0
270
+ ]
271
+ }, {
272
+ default: h(() => [
273
+ u(B, {
274
+ modelValue: a.value,
275
+ "onUpdate:modelValue": e[3] || (e[3] = (r) => a.value = r),
276
+ length: ge,
277
+ masked: t.value,
278
+ onComplete: e[4] || (e[4] = (r) => s.value.passcode = r),
279
+ onFocus: f
280
+ }, null, 8, ["modelValue", "masked"])
281
+ ]),
282
+ _: 1
283
+ }, 8, ["modelValue", "rules"]),
284
+ u(F, {
285
+ variant: "secondary",
286
+ "text-color": "primary",
287
+ "border-color": "primary",
288
+ label: o(d)("hr.employee.form.passcodeGenerate"),
289
+ size: "md",
290
+ onClick: U
291
+ }, null, 8, ["label"])
292
+ ])
293
+ ]),
294
+ _: 1
295
+ }, 8, ["label"])
296
+ ]),
297
+ _: 1
298
+ }, 8, ["title"]),
299
+ u(ve, {
300
+ title: o(d)("hr.employee.form.role")
301
+ }, {
302
+ default: h(() => [
303
+ u(Ee, {
304
+ modelValue: o(C),
305
+ "onUpdate:modelValue": e[6] || (e[6] = (r) => ne(C) ? C.value = r : null),
306
+ placeholder: o(d)("hr.restaurant.search.placeholder")
307
+ }, null, 8, ["modelValue", "placeholder"]),
308
+ u(V, {
309
+ modelValue: b.value,
310
+ "onUpdate:modelValue": e[7] || (e[7] = (r) => b.value = r),
311
+ rules: [(r) => r.length > 0 || o(d)("hr.employee.form.atLeastOneRestaurant")]
312
+ }, {
313
+ default: h(() => [
314
+ u(ie, {
315
+ "model-value": k.value,
316
+ label: o(d)("hr.employee.form.all"),
317
+ value: "1",
318
+ indeterminate: N.value.length > 0,
319
+ "onUpdate:modelValue": ee
320
+ }, null, 8, ["model-value", "label", "indeterminate"]),
321
+ (g(!0), $(G, null, Ve(M.value, (r, oe) => {
322
+ var me;
323
+ return g(), $(G, { key: oe }, [
324
+ u(ie, {
325
+ "model-value": b.value,
326
+ label: r.label,
327
+ value: r.value,
328
+ disabled: r.disabled,
329
+ "onUpdate:modelValue": j
330
+ }, null, 8, ["model-value", "label", "value", "disabled"]),
331
+ b.value.includes(r.value) ? (g(), D(Re, {
332
+ key: 0,
333
+ class: "ml-32 mr-8",
334
+ items: r.roleOptions,
335
+ "model-value": A(r.value),
336
+ multiselect: !1,
337
+ placeholder: ((me = r.roleOptions.find((se) => !se.disabled) ?? r.roleOptions[0]) == null ? void 0 : me.label) ?? "",
338
+ disabled: r.disabled,
339
+ "onUpdate:modelValue": (se) => W(r.value, se)
340
+ }, null, 8, ["items", "model-value", "placeholder", "disabled", "onUpdate:modelValue"])) : Q("", !0)
341
+ ], 64);
342
+ }), 128))
343
+ ]),
344
+ _: 1
345
+ }, 8, ["modelValue", "rules"])
346
+ ]),
347
+ _: 1
348
+ }, 8, ["title"])
349
+ ])
350
+ ]),
351
+ _: 1
352
+ }, 8, ["modelValue", "is-container", "is-container-props", "onOn:clickedAway"])
353
+ ], 64);
354
+ };
355
+ }
356
+ }), al = {
357
+ class: "space-y-8"
358
+ }, tl = {
359
+ class: "xs:hidden flex w-full items-start justify-between"
360
+ }, ol = {
361
+ class: "flex items-start gap-8"
362
+ }, sl = {
363
+ class: "flex"
364
+ }, rl = {
365
+ class: "space-y-4 sm:hidden md:hidden lg:hidden"
366
+ }, nl = {
367
+ class: "px-16"
368
+ }, ul = {
369
+ class: "px-16 flex items-start gap-8"
370
+ }, il = {
371
+ class: "pb-64 sm:hidden md:hidden lg:hidden"
372
+ }, dl = {
373
+ class: "space-y-4"
374
+ }, ml = {
375
+ class: "fm-typo-en-body-lg-600"
376
+ }, cl = {
377
+ key: 0,
378
+ class: "mr-4"
379
+ }, pl = {
380
+ class: "text-fm-color-typo-secondary"
381
+ }, kl = /* @__PURE__ */ _e({
382
+ __name: "EmployeeList",
383
+ setup(S, {
384
+ expose: O
385
+ }) {
386
+ const {
387
+ t: i
388
+ } = we(), E = _(), c = Se(), q = ue(), {
389
+ sessionUser: H
390
+ } = Fe(), d = w(() => c.employees.value), {
391
+ searchKey: v,
392
+ filter: L
393
+ } = ke(""), R = w(() => {
394
+ var a;
395
+ return (a = d.value) == null ? void 0 : a.filter((t) => {
396
+ const f = !E.value || t.restaurants.some((y) => E.value.includes(y.restaurantId)), U = !k.value || t.restaurants.some((y) => y.roleId && k.value.includes(y.roleId));
397
+ return f && U && L([t.code, t.name, `${t.restaurants.map((y) => T(y)).join(" ")}`]);
398
+ });
399
+ }), P = Ge(), T = (a) => {
400
+ const t = P.value[a.restaurantId], f = t == null ? void 0 : t.profile.code;
401
+ let y = a.restaurantName || (t == null ? void 0 : t.profile.name) || "";
402
+ return a.roleName && (y = `${f ? f + " - " : ""}${y} (${a.roleName})`), y;
403
+ }, X = [{
404
+ accessorKey: "code",
405
+ size: 100,
406
+ header: () => i("hr.employee.columns.code")
407
+ }, {
408
+ accessorKey: "name",
409
+ header: () => i("hr.employee.columns.name"),
410
+ enableSorting: !1
411
+ }, {
412
+ accessorKey: "restaurants",
413
+ align: "center",
414
+ header: () => i("hr.employee.columns.restaurants"),
415
+ enableSorting: !1,
416
+ cell(a) {
417
+ return a.row.original.restaurants.map((t, f) => {
418
+ const U = T(t);
419
+ return re("div", (f ? `
420
+ ` : "") + U);
421
+ });
422
+ }
423
+ }, {
424
+ accessorKey: "since",
425
+ header: () => i("hr.employee.columns.since"),
426
+ enableSorting: !1
427
+ }, {
428
+ id: "action",
429
+ size: 52,
430
+ meta: {
431
+ cellClass: "pl-16",
432
+ headerContentClass: "-mx-16"
433
+ },
434
+ cell: (a) => re("div", {
435
+ class: "w-full flex justify-end items-center"
436
+ }, [re(Ue.FmButton, {
437
+ prependIcon: "delete",
438
+ variant: De.Tertiary,
439
+ textColor: "neutral-gray-400",
440
+ onClick: (t) => {
441
+ t.stopPropagation(), A(a.row.original);
442
+ }
443
+ })])
444
+ }], x = xe(), s = Ne(), C = _(), z = _(), Y = w(() => c.restrictEmployeeIds.value);
445
+ function J(a) {
446
+ const t = Y.value.includes(a._id);
447
+ return t && x.open({
448
+ message: i("hr.employee.cannotUpdateMasterUser", {
449
+ name: a.name
450
+ }),
451
+ type: "error"
452
+ }), t;
453
+ }
454
+ const M = (a) => {
455
+ var f;
456
+ a && J(a) || (f = z.value) == null || f.trigger(a);
457
+ }, {
458
+ breakpoints: Z
459
+ } = Be(), A = (a) => {
460
+ J(a) || s.open({
461
+ title: i("hr.employee.remove.title"),
462
+ message: i("hr.employee.remove.message", {
463
+ name: a.name
464
+ }),
465
+ minWidth: Z.value.lg ? 588 : 0,
466
+ primaryActions: {
467
+ text: i("common.remove"),
468
+ close: !1,
469
+ variant: "destructive"
470
+ },
471
+ secondaryActions: {
472
+ text: i("common.cancel"),
473
+ close: !0
474
+ }
475
+ }).onPrimary(async () => {
476
+ await (a.isMasterUser ? c.deleteMasterEmployee : c.deleteEmployee)(a).then(() => x.open({
477
+ message: i("hr.employee.remove.successMessage", {
478
+ name: a.name
479
+ }),
480
+ type: "success"
481
+ })).catch((U) => x.open({
482
+ message: U,
483
+ type: "error"
484
+ })), s.close();
485
+ });
486
+ }, W = _("");
487
+ be(() => C.value && C.value.restaurants, (a) => {
488
+ a && a.length > 0 && (W.value = "");
489
+ });
490
+ function b() {
491
+ var a;
492
+ (a = z.value) == null || a.trigger();
493
+ }
494
+ const N = w(() => ue().roles.value.map((a) => ({
495
+ label: a.name,
496
+ value: a._id
497
+ }))), k = _();
498
+ async function ee() {
499
+ try {
500
+ await c.syncUsersMeta(), await c.readEmployees(), x.open({
501
+ message: i("hr.employee.sync.successMessage"),
502
+ type: "success"
503
+ });
504
+ } catch (a) {
505
+ console.error("Error syncing users:", a), x.open({
506
+ message: i("hr.employee.sync.errorMessage"),
507
+ type: "error"
508
+ });
509
+ }
510
+ }
511
+ async function j() {
512
+ q.roles.value.length === 0 && await q.readRoles(), c.employees.value.length === 0 && await c.readEmployees();
513
+ }
514
+ return $e(() => {
515
+ j();
516
+ }), O({
517
+ create: b,
518
+ filteredEmployees: R
519
+ }), (a, t) => {
520
+ var l;
521
+ const f = p("FmButton"), U = p("FmTooltip"), y = p("FmSearch"), le = p("FmTable"), ae = p("FmListItem"), te = p("FmList");
522
+ return g(), $(G, null, [u(ll, {
523
+ ref_key: "employeeFormRef",
524
+ ref: z,
525
+ modelValue: C.value,
526
+ "onUpdate:modelValue": t[0] || (t[0] = (e) => C.value = e),
527
+ "role-error-message": W.value,
528
+ class: "gap-8"
529
+ }, null, 8, ["modelValue", "role-error-message"]), m("div", al, [m("div", tl, [m("div", ol, [u(o(ce), {
530
+ modelValue: E.value,
531
+ "onUpdate:modelValue": t[1] || (t[1] = (e) => E.value = e),
532
+ "managable-only": !1,
533
+ multiple: "",
534
+ variant: "dark",
535
+ class: "!w-auto"
536
+ }, null, 8, ["modelValue"]), u(pe, {
537
+ modelValue: k.value,
538
+ "onUpdate:modelValue": t[2] || (t[2] = (e) => k.value = e),
539
+ multiple: "",
540
+ variant: "dark",
541
+ items: N.value,
542
+ "selected-prefix": o(i)("hr.employee.filter.selected_role_prefix"),
543
+ placeholder: o(i)("hr.employee.filter.role_placeholder")
544
+ }, null, 8, ["modelValue", "items", "selected-prefix", "placeholder"])]), m("div", sl, [(l = o(H)) != null && l.role.isAdmin ? (g(), D(U, {
545
+ key: 0,
546
+ content: o(i)("hr.employee.sync.tooltip")
547
+ }, {
548
+ default: h(() => [u(f, {
549
+ icon: "refresh",
550
+ label: o(i)("hr.employee.sync.tooltip"),
551
+ variant: "tertiary",
552
+ onClick: ee
553
+ }, null, 8, ["label"])]),
554
+ _: 1
555
+ }, 8, ["content"])) : Q("", !0), u(y, {
556
+ modelValue: o(v),
557
+ "onUpdate:modelValue": t[3] || (t[3] = (e) => ne(v) ? v.value = e : null),
558
+ autofocus: "",
559
+ class: "pl-4 w-[320px]",
560
+ placeholder: o(i)("hr.employee.search.placeholder")
561
+ }, null, 8, ["modelValue", "placeholder"])])]), m("div", rl, [m("div", nl, [u(y, {
562
+ modelValue: o(v),
563
+ "onUpdate:modelValue": t[4] || (t[4] = (e) => ne(v) ? v.value = e : null),
564
+ autofocus: "",
565
+ placeholder: o(i)("hr.employee.search.placeholder")
566
+ }, null, 8, ["modelValue", "placeholder"])]), u(We), m("div", ul, [u(o(ce), {
567
+ modelValue: E.value,
568
+ "onUpdate:modelValue": t[5] || (t[5] = (e) => E.value = e),
569
+ "managable-only": !1,
570
+ multiple: "",
571
+ variant: "dark",
572
+ class: "!w-auto"
573
+ }, null, 8, ["modelValue"]), u(pe, {
574
+ modelValue: k.value,
575
+ "onUpdate:modelValue": t[6] || (t[6] = (e) => k.value = e),
576
+ multiple: "",
577
+ items: N.value,
578
+ variant: "dark",
579
+ "selected-prefix": o(i)("hr.employee.filter.selected_role_prefix"),
580
+ placeholder: o(i)("hr.employee.filter.role_placeholder")
581
+ }, null, 8, ["modelValue", "items", "selected-prefix", "placeholder"])])]), o(c).employees.value.length > 0 || o(c).isLoading.value ? (g(), D(Te, {
582
+ key: 0,
583
+ class: "overflow-auto"
584
+ }, {
585
+ default: h(() => [u(le, {
586
+ class: "xs:hidden",
587
+ "column-defs": X,
588
+ "row-data": R.value,
589
+ "page-size": R.value.length,
590
+ loading: o(c).isLoading.value,
591
+ virtual: R.value.length > 0,
592
+ "pin-header-row": "",
593
+ "hide-footer": "",
594
+ onRowClick: t[7] || (t[7] = (e) => M(e.original))
595
+ }, null, 8, ["row-data", "page-size", "loading", "virtual"]), m("div", il, [u(te, {
596
+ separator: ""
597
+ }, {
598
+ default: h(() => [(g(!0), $(G, null, Ve(R.value, (e) => (g(), D(ae, {
599
+ key: e._id,
600
+ class: "py-12 px-16 items-center justify-between",
601
+ onClick: (n) => M(e)
602
+ }, {
603
+ default: h(() => [m("div", dl, [m("p", ml, [e.code ? (g(), $("span", cl, K(e.code) + ".", 1)) : Q("", !0), Oe(K(e.name), 1)]), m("div", pl, [m("p", null, K(o(i)("hr.employee.restaurants", {
604
+ restaurants: e.restaurants.map((n) => T(n)).join(", ")
605
+ })), 1), m("p", null, " Since: " + K(e.since), 1)])]), u(f, {
606
+ icon: "delete",
607
+ variant: "tertiary",
608
+ "text-color": "neutral-gray-400",
609
+ onClick: Le((n) => A(e), ["stop"])
610
+ }, null, 8, ["onClick"])]),
611
+ _: 2
612
+ }, 1032, ["onClick"]))), 128))]),
613
+ _: 1
614
+ })])]),
615
+ _: 1
616
+ })) : (g(), D(o(ze), {
617
+ key: 1,
618
+ title: o(i)("hr.employee.noData.title"),
619
+ subtitle: o(i)("hr.employee.noData.subtitle")
620
+ }, null, 8, ["title", "subtitle"]))])], 64);
621
+ };
622
+ }
623
+ });
624
+ export {
625
+ kl as default
626
+ };