@feedmepos/mf-hrm-portal 2.0.16 → 2.0.17-dev.3

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