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