@feedmepos/mf-hrm-portal 2.1.1-dev.5 → 2.1.1-dev.7

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