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