@feedmepos/mf-hrm-portal 2.0.17-dev.4 → 2.0.17-dev.5

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