@feedmepos/mf-hrm-portal 2.2.4 → 2.2.5-dev

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