@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
@@ -1,887 +0,0 @@
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-CcCcPbyB.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 { _ 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-CLgrXpmZ.js";
12
- import { u as Oe } from "./restaurant-DiYb0pCm.js";
13
- import { l as ia } from "./lodash-CKzaMa7f.js";
14
- import { _ as $e } from "./FormSection.vue_vue_type_script_setup_true_lang-DknXTYiK.js";
15
- import { u as Be } from "./useLoading-CvgqVDbF.js";
16
- import { u as Ee } from "./role-BZr8zzeq.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(), U = Ke(), ye = Ne(), P = Be(ye), ge = u, { t: c } = De(), C = 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, V.value = [], t.value.passcode && (V.value = t.value.passcode.split(""), T.value = !0), A.value = !o, C.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 S(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, R, G;
96
- const n = ((b = t.value.restaurants[o]) == null ? void 0 : b.roleId) ?? "", h = re(l, n), _ = ((R = h.find((F) => F.value === n && !F.disabled)) == null ? void 0 : R.value) ?? ((G = h.find((F) => !F.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 (!S(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
- }), V = v([]), T = v(!1);
132
- function Y() {
133
- T.value && (T.value = !1, V.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, V.value = o.split("");
141
- } finally {
142
- j.value = !1;
143
- }
144
- }
145
- const D = ta(
146
- () => !ia.isEqual(t.value, I.value),
147
- () => {
148
- C.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 U.createMasterEmployee(o) : (delete o.user.code, await U.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 U.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((R) => ({
186
- restaurantId: R.restaurantId,
187
- roleId: R.roleId
188
- }))
189
- };
190
- I.value.isMasterUser ? await U.updateMasterEmployee(l, b) : await U.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"), C.value = !1;
211
- }
212
- return ae(
213
- () => C.value,
214
- (o) => {
215
- }
216
- ), ve({
217
- show: C,
218
- trigger: te
219
- }), (o, l) => {
220
- const n = w("FmIcon"), h = w("FmSwitch"), _ = w("FmTextField"), b = w("FmPinField"), R = w("FmFormGroup"), G = w("FmButton"), F = 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
- modelValue: C.value,
226
- "onUpdate:modelValue": l[7] || (l[7] = (e) => C.value = e),
227
- "is-container": s(ze).FmForm,
228
- "is-container-props": {
229
- onValidationSuccess: ce,
230
- blameFormChildOnValidationFailed: !0
231
- },
232
- "max-width": 960,
233
- "close-button": !1,
234
- "onOn:clickedAway": s(D)
235
- }, {
236
- "side-sheet-header": g(() => [
237
- d("div", ua, [
238
- d("p", ca, L(J.value), 1),
239
- i(n, {
240
- name: "close",
241
- size: "md",
242
- class: "cursor-pointer",
243
- onClick: s(D)
244
- }, null, 8, ["onClick"])
245
- ])
246
- ]),
247
- "side-sheet-footer": g(() => [
248
- d("div", xa, [
249
- i(de, {
250
- label: W.value,
251
- size: "lg",
252
- type: "submit",
253
- variant: "primary",
254
- disabled: $.value
255
- }, null, 8, ["label", "disabled"]),
256
- i(de, {
257
- label: s(c)("common.cancel"),
258
- size: "lg",
259
- variant: "tertiary",
260
- disabled: $.value,
261
- onClick: s(D)
262
- }, null, 8, ["label", "disabled", "onClick"])
263
- ])
264
- ]),
265
- default: g(() => [
266
- d("div", da, [
267
- i($e, {
268
- title: s(c)("hr.employee.form.employeeSetting")
269
- }, {
270
- default: g(() => [
271
- i(Re, {
272
- label: s(c)("hr.employee.form.masterUserConfig")
273
- }, {
274
- default: g(() => [
275
- i(h, {
276
- modelValue: t.value.isMasterUser,
277
- "onUpdate:modelValue": l[0] || (l[0] = (e) => t.value.isMasterUser = e),
278
- value: "masterUser",
279
- label: s(c)("hr.employee.form.masterUser"),
280
- sublabel: s(c)("hr.employee.form.masterUserSublabel"),
281
- "label-placement": "right"
282
- }, null, 8, ["modelValue", "label", "sublabel"])
283
- ]),
284
- _: 1
285
- }, 8, ["label"]),
286
- d("div", ma, [
287
- t.value.isMasterUser ? (y(), M(_, {
288
- key: 0,
289
- modelValue: t.value.code,
290
- "onUpdate:modelValue": l[1] || (l[1] = (e) => t.value.code = e),
291
- label: s(c)("hr.employee.form.code")
292
- }, null, 8, ["modelValue", "label"])) : H("", !0),
293
- i(_, {
294
- modelValue: t.value.name,
295
- "onUpdate:modelValue": l[2] || (l[2] = (e) => t.value.name = e),
296
- class: "w-full",
297
- label: s(c)("hr.employee.form.name"),
298
- rules: [(e) => !!e || s(c)("hr.employee.form.required")]
299
- }, null, 8, ["modelValue", "label", "rules"])
300
- ]),
301
- i(Re, {
302
- label: s(c)("hr.employee.form.passcode")
303
- }, {
304
- default: g(() => [
305
- d("div", pa, [
306
- i(R, {
307
- modelValue: V.value,
308
- "onUpdate:modelValue": l[5] || (l[5] = (e) => V.value = e),
309
- rules: [
310
- (e) => (e == null ? void 0 : e.filter((a) => !!a).length) !== Pe ? s(c)("hr.employee.form.passcodeRequired") : !0
311
- ]
312
- }, {
313
- default: g(() => [
314
- i(b, {
315
- modelValue: V.value,
316
- "onUpdate:modelValue": l[3] || (l[3] = (e) => V.value = e),
317
- length: Pe,
318
- masked: T.value,
319
- onComplete: l[4] || (l[4] = (e) => t.value.passcode = e),
320
- onFocus: Y
321
- }, null, 8, ["modelValue", "masked"])
322
- ]),
323
- _: 1
324
- }, 8, ["modelValue", "rules"]),
325
- i(G, {
326
- variant: "secondary",
327
- "text-color": "primary",
328
- "border-color": "primary",
329
- label: s(c)("hr.employee.form.passcodeGenerate"),
330
- size: "md",
331
- loading: j.value,
332
- onClick: ie
333
- }, null, 8, ["label", "loading"])
334
- ])
335
- ]),
336
- _: 1
337
- }, 8, ["label"])
338
- ]),
339
- _: 1
340
- }, 8, ["title"]),
341
- i($e, null, {
342
- default: g(() => [
343
- i(R, {
344
- modelValue: t.value.restaurants,
345
- "onUpdate:modelValue": l[6] || (l[6] = (e) => t.value.restaurants = e),
346
- tag: "div",
347
- rules: [
348
- (e) => e.length > 0 || s(c)("hr.employee.form.atLeastOneRestaurant"),
349
- (e) => e.every((a) => a.restaurantId && a.roleId) || s(c)("hr.employee.form.roleRequired")
350
- ]
351
- }, {
352
- default: g(() => [
353
- d("div", fa, [
354
- d("div", va, L(s(c)("hr.employee.form.assignmentSection")), 1),
355
- d("div", ya, [
356
- d("div", ga, [
357
- d("div", ha, L(s(c)("hr.employee.columns.restaurants")), 1),
358
- d("div", _a, L(s(c)("hr.employee.form.role")), 1),
359
- l[8] || (l[8] = d("div", null, null, -1))
360
- ]),
361
- (y(!0), N(ke, null, qe(t.value.restaurants, (e, a) => (y(), N("div", {
362
- key: `${e.restaurantId || "new"}-${a}`,
363
- class: "grid grid-cols-[minmax(0,1fr)_minmax(0,1fr)_auto] items-center gap-16"
364
- }, [
365
- i(F, {
366
- class: "min-w-0",
367
- "model-value": e.restaurantId,
368
- items: oe(e.restaurantId),
369
- multiselect: !1,
370
- searchable: "",
371
- "search-debounce": 300,
372
- placeholder: s(c)("hr.employee.columns.restaurants"),
373
- disabled: S(e.restaurantId),
374
- "onUpdate:modelValue": (r) => _e(a, r)
375
- }, null, 8, ["model-value", "items", "placeholder", "disabled", "onUpdate:modelValue"]),
376
- i(F, {
377
- class: "min-w-0",
378
- "model-value": e.roleId,
379
- items: re(e.restaurantId, e.roleId),
380
- multiselect: !1,
381
- placeholder: s(c)("hr.employee.form.role"),
382
- disabled: !e.restaurantId || S(e.restaurantId),
383
- "onUpdate:modelValue": (r) => be(a, r)
384
- }, null, 8, ["model-value", "items", "placeholder", "disabled", "onUpdate:modelValue"]),
385
- d("div", ba, [
386
- t.value.restaurants.length > 1 ? (y(), N("div", {
387
- key: 0,
388
- role: "button",
389
- tabindex: S(e.restaurantId) ? -1 : 0,
390
- "aria-disabled": S(e.restaurantId),
391
- 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", {
392
- "cursor-pointer": !S(e.restaurantId),
393
- "pointer-events-none": S(e.restaurantId)
394
- }]),
395
- "aria-label": s(c)("common.remove"),
396
- onClick: le((r) => Q(a), ["stop"]),
397
- onKeydown: [
398
- Ce(le((r) => Q(a), ["prevent", "stop"]), ["enter"]),
399
- Ce(le((r) => Q(a), ["prevent", "stop"]), ["space"])
400
- ]
401
- }, [
402
- i(n, {
403
- name: "delete",
404
- size: "md"
405
- })
406
- ], 42, wa)) : H("", !0)
407
- ])
408
- ]))), 128))
409
- ]),
410
- i(G, {
411
- type: "button",
412
- variant: "secondary",
413
- "text-color": "primary",
414
- "border-color": "primary",
415
- "prepend-icon": "add",
416
- label: s(c)("hr.employee.form.addAnother"),
417
- size: "md",
418
- disabled: !B.value,
419
- onClick: le(ne, ["stop"])
420
- }, null, 8, ["label", "disabled"])
421
- ])
422
- ]),
423
- _: 1
424
- }, 8, ["modelValue", "rules"])
425
- ]),
426
- _: 1
427
- })
428
- ])
429
- ]),
430
- _: 1
431
- }, 8, ["modelValue", "is-container", "is-container-props", "onOn:clickedAway"])
432
- ], 64);
433
- };
434
- }
435
- }), Ia = {
436
- class: "space-y-8"
437
- }, Ea = {
438
- key: 0,
439
- class: "flex w-full items-start justify-between"
440
- }, Va = {
441
- class: "flex items-start gap-8"
442
- }, Fa = {
443
- class: "flex"
444
- }, Ca = {
445
- key: 1,
446
- class: "space-y-4"
447
- }, Sa = {
448
- class: "px-16"
449
- }, Ra = {
450
- class: "px-16 flex items-start gap-8"
451
- }, Ua = {
452
- class: "flex h-full flex-col overflow-auto"
453
- }, $a = {
454
- class: "space-y-4"
455
- }, Ma = {
456
- class: "fm-typo-en-body-lg-600"
457
- }, La = {
458
- key: 0,
459
- class: "mr-4"
460
- }, Pa = {
461
- class: "text-fm-color-typo-secondary"
462
- }, Aa = {
463
- class: "line-clamp-2"
464
- }, Da = {
465
- class: "font-bold"
466
- }, q = 200, Na = /* @__PURE__ */ Ae({
467
- __name: "EmployeeList",
468
- setup(z, {
469
- expose: ve
470
- }) {
471
- const {
472
- t: u
473
- } = De(), E = v(), p = Ke(), U = Oe(), ye = We(), {
474
- currentBusiness: P,
475
- sessionUser: ge
476
- } = ye, c = Ee(), C = x(() => U.isLoading.value), A = v(c.roles.value.length === 0);
477
- ae(U.restaurants, (e) => {
478
- if (e.length > 0 && p.listEmployees.value.length > 0) {
479
- const a = new Map(e.map((r) => [r._id, r]));
480
- p.listEmployees.value = p.listEmployees.value.map((r) => ({
481
- ...r,
482
- restaurants: r.restaurants.map((f) => {
483
- var X, ee;
484
- return {
485
- ...f,
486
- restaurantName: ((X = a.get(f.restaurantId)) == null ? void 0 : X.profile.name) || f.restaurantName,
487
- restaurantCode: ((ee = a.get(f.restaurantId)) == null ? void 0 : ee.profile.code) ?? void 0
488
- };
489
- })
490
- }));
491
- }
492
- });
493
- const K = x(() => U.restaurants.value.map((e) => ({
494
- label: `${e.profile.code ? `${e.profile.code} - ` : ""}${e.profile.name}`,
495
- value: e._id
496
- }))), he = ae(c.roles, (e) => {
497
- if (e.length > 0) {
498
- if (A.value = !1, p.listEmployees.value.length > 0) {
499
- const a = new Map(e.map((r) => [r._id, r.name]));
500
- p.listEmployees.value = p.listEmployees.value.map((r) => ({
501
- ...r,
502
- restaurants: r.restaurants.map((f) => ({
503
- ...f,
504
- roleName: a.get(f.roleId) || f.roleName
505
- }))
506
- }));
507
- }
508
- he();
509
- }
510
- }), te = x(() => p.listEmployees.value), {
511
- searchKey: k
512
- } = aa(), J = v(""), W = x(() => te.value), I = x(() => p.totalEmployees.value), t = v(1), se = x(() => p.isLoading.value), O = v(!1), S = x(() => {
513
- var e;
514
- return JSON.stringify({
515
- businessId: ((e = P.value) == null ? void 0 : e._id) ?? "",
516
- search: J.value.trim(),
517
- restaurantIds: [...E.value ?? []].sort(),
518
- roleIds: [...n.value ?? []].sort()
519
- });
520
- }), oe = (e) => {
521
- const a = e.restaurantCode, r = e.restaurantName;
522
- return a ? `${a} - ${r}` : r;
523
- }, re = (e) => e.roleName || "-";
524
- function _e(e) {
525
- return [{
526
- label: u("hr.employee.form.update"),
527
- onClick: () => D(e)
528
- }, {
529
- label: u("hr.employee.remove.title"),
530
- onClick: () => ue(e),
531
- itemClass: "text-fm-color-typo-error"
532
- }];
533
- }
534
- const be = ({
535
- employee: e,
536
- className: a = ""
537
- }) => i("div", {
538
- class: a,
539
- onClick: (r) => {
540
- r.stopPropagation();
541
- }
542
- }, [i(sa, {
543
- items: _e(e)
544
- }, null)]), ne = [{
545
- accessorKey: "code",
546
- size: 100,
547
- header: () => u("hr.employee.columns.code")
548
- }, {
549
- accessorKey: "name",
550
- header: () => u("hr.employee.columns.name"),
551
- enableSorting: !1,
552
- cell(e) {
553
- const a = e.row.original;
554
- return i("div", {
555
- class: "flex items-center gap-8"
556
- }, [i(ze.FmAvatar, {
557
- name: a.name,
558
- size: "sm",
559
- class: "shrink-0"
560
- }, null), i("span", {
561
- class: "truncate"
562
- }, [a.name])]);
563
- }
564
- }, {
565
- accessorKey: "restaurants",
566
- align: "center",
567
- header: () => u("hr.employee.columns.restaurants"),
568
- enableSorting: !1,
569
- cell(e) {
570
- return C.value || A.value ? pe(Ue) : e.row.original.restaurants.map((a, r) => {
571
- const f = oe(a);
572
- return pe("div", {
573
- key: a.restaurantId || r
574
- }, (r ? `
575
- ` : "") + f);
576
- });
577
- }
578
- }, {
579
- accessorKey: "assignedRole",
580
- align: "center",
581
- header: () => u("hr.employee.columns.assignedRole"),
582
- enableSorting: !1,
583
- cell(e) {
584
- return C.value || A.value ? pe(Ue, {
585
- width: "120px"
586
- }) : e.row.original.restaurants.map((a, r) => {
587
- const f = re(a);
588
- return pe("div", {
589
- key: a.restaurantId || r
590
- }, (r ? `
591
- ` : "") + f);
592
- });
593
- }
594
- }, {
595
- accessorKey: "since",
596
- header: () => u("hr.employee.columns.since"),
597
- enableSorting: !1
598
- }, {
599
- id: "action",
600
- size: 52,
601
- meta: {
602
- cellClass: "pl-16",
603
- headerContentClass: "-mx-16"
604
- },
605
- cell(e) {
606
- return be({
607
- employee: e.row.original,
608
- className: "flex w-full items-center justify-end"
609
- });
610
- }
611
- }], Q = ({
612
- employee: e
613
- }) => i("div", {
614
- class: "flex flex-col gap-4 grow p-8"
615
- }, [ne.map((a, r) => i("div", {
616
- key: a.id ?? a.accessorKey ?? r,
617
- class: "fm-typo-en-body-md-400 line-clamp-2 w-full"
618
- }, [a.cell ? a.cell({
619
- row: {
620
- original: e
621
- }
622
- }) : e[a.accessorKey]]))]), B = Ne(), V = Qe(), T = Be(B), Y = v(!1), $ = v(), j = v();
623
- function ie(e) {
624
- const a = e.isRestricted;
625
- return a && B.open({
626
- message: u("hr.employee.cannotUpdateMasterUser", {
627
- name: e.name
628
- }),
629
- type: "error"
630
- }), a;
631
- }
632
- const D = (e) => {
633
- var r;
634
- e && ie(e) || (r = j.value) == null || r.trigger(e);
635
- }, {
636
- breakpoints: Z
637
- } = Ye(), ue = (e) => {
638
- ie(e) || V.open({
639
- title: u("hr.employee.remove.title"),
640
- message: u("hr.employee.remove.message", {
641
- name: e.name
642
- }),
643
- minWidth: Z.value.lg ? 588 : 0,
644
- primaryActions: {
645
- text: u("common.remove"),
646
- close: !1,
647
- variant: "destructive",
648
- isLoading: Y
649
- },
650
- secondaryActions: {
651
- text: u("common.cancel"),
652
- close: !0
653
- }
654
- }).onPrimary(async () => {
655
- if (Y.value) return;
656
- const r = e.isMasterUser ? p.deleteMasterEmployee : p.deleteEmployee;
657
- await T.minor(async () => {
658
- await r(e), await b();
659
- }, {
660
- isLoading: Y,
661
- successMessage: u("hr.employee.remove.successMessage", {
662
- name: e.name
663
- })
664
- }).catch(() => {
665
- }), V.close();
666
- });
667
- }, ce = v("");
668
- function o() {
669
- var e;
670
- (e = j.value) == null || e.trigger();
671
- }
672
- const l = x(() => Ee().roles.value.map((e) => ({
673
- label: e.name,
674
- value: e._id
675
- }))), n = v();
676
- async function h() {
677
- try {
678
- await p.syncUsersMeta(), await b(), B.open({
679
- message: u("hr.employee.sync.successMessage"),
680
- type: "success"
681
- });
682
- } catch (e) {
683
- console.error("Error syncing users:", e), B.open({
684
- message: u("hr.employee.sync.errorMessage"),
685
- type: "error"
686
- });
687
- }
688
- }
689
- async function _(e = t.value) {
690
- var a, r;
691
- try {
692
- await p.readEmployeesPage({
693
- limit: q,
694
- offset: (e - 1) * q,
695
- search: J.value.trim() || void 0,
696
- restaurantIds: (a = E.value) != null && a.length ? E.value : void 0,
697
- roleIds: (r = n.value) != null && r.length ? n.value : void 0
698
- });
699
- } catch (f) {
700
- console.error("Failed to load employees:", f), B.open({
701
- message: f instanceof Error ? f.message : String(f),
702
- type: "error"
703
- });
704
- }
705
- }
706
- async function b() {
707
- var a;
708
- if (!((a = P.value) != null && a._id)) return;
709
- await _(t.value);
710
- const e = Math.max(1, Math.ceil(I.value / q));
711
- t.value > e && (t.value = e, await _(t.value));
712
- }
713
- async function R() {
714
- var e, a;
715
- return await p.readAllEmployeesPage({
716
- search: J.value.trim() || void 0,
717
- restaurantIds: (e = E.value) != null && e.length ? E.value : void 0,
718
- roleIds: (a = n.value) != null && a.length ? n.value : void 0
719
- }, I.value);
720
- }
721
- const G = ra(k, () => {
722
- J.value = k.value;
723
- }, 300);
724
- He(G);
725
- let F = !1;
726
- async function de({
727
- pageIndex: e
728
- }) {
729
- var a;
730
- if ((a = P.value) != null && a._id && !F && !(e === 0 && t.value === 1 && W.value.length > 0)) {
731
- F = !0, t.value = e + 1;
732
- try {
733
- await _(t.value);
734
- } finally {
735
- F = !1;
736
- }
737
- }
738
- }
739
- ae(S, async () => {
740
- var e;
741
- t.value = 1, O.value = !1, (e = P.value) != null && e._id && (await _(1), O.value = !0);
742
- }, {
743
- immediate: !0
744
- }), ae(() => $.value && $.value.restaurants, (e) => {
745
- e && e.length > 0 && (ce.value = "");
746
- });
747
- const we = x(() => I.value > q);
748
- return ve({
749
- create: o,
750
- filteredEmployees: W,
751
- exportEmployees: R,
752
- getHasPaginationFooter: () => we.value
753
- }), (e, a) => {
754
- var Ve, Fe;
755
- const r = w("FmButton"), f = w("FmTooltip"), X = w("FmSearch"), ee = w("FmListItem"), Te = w("FmTable");
756
- return y(), N(ke, null, [i(ka, {
757
- ref_key: "employeeFormRef",
758
- ref: j,
759
- modelValue: $.value,
760
- "onUpdate:modelValue": a[0] || (a[0] = (m) => $.value = m),
761
- "role-error-message": ce.value,
762
- class: "gap-8",
763
- onSubmitted: b
764
- }, null, 8, ["modelValue", "role-error-message"]), d("div", Ia, [s(Z).xs ? (y(), N("div", Ca, [d("div", Sa, [i(X, {
765
- modelValue: s(k),
766
- "onUpdate:modelValue": a[4] || (a[4] = (m) => Se(k) ? k.value = m : null),
767
- placeholder: s(u)("hr.employee.search.placeholder")
768
- }, null, 8, ["modelValue", "placeholder"])]), i(la), d("div", Ra, [i(fe, {
769
- modelValue: E.value,
770
- "onUpdate:modelValue": a[5] || (a[5] = (m) => E.value = m),
771
- multiple: "",
772
- items: K.value,
773
- variant: "dark",
774
- "selected-prefix": s(u)("hr.role.columns.restaurants"),
775
- placeholder: s(u)("hr.role.columns.restaurants"),
776
- class: "!w-auto"
777
- }, null, 8, ["modelValue", "items", "selected-prefix", "placeholder"]), i(fe, {
778
- modelValue: n.value,
779
- "onUpdate:modelValue": a[6] || (a[6] = (m) => n.value = m),
780
- multiple: "",
781
- items: l.value,
782
- variant: "dark",
783
- "selected-prefix": s(u)("hr.employee.filter.selected_role_prefix"),
784
- placeholder: s(u)("hr.employee.filter.role_placeholder")
785
- }, null, 8, ["modelValue", "items", "selected-prefix", "placeholder"])])])) : (y(), N("div", Ea, [d("div", Va, [i(fe, {
786
- modelValue: E.value,
787
- "onUpdate:modelValue": a[1] || (a[1] = (m) => E.value = m),
788
- multiple: "",
789
- items: K.value,
790
- variant: "dark",
791
- "selected-prefix": s(u)("hr.role.columns.restaurants"),
792
- placeholder: s(u)("hr.role.columns.restaurants"),
793
- class: "!w-auto"
794
- }, null, 8, ["modelValue", "items", "selected-prefix", "placeholder"]), i(fe, {
795
- modelValue: n.value,
796
- "onUpdate:modelValue": a[2] || (a[2] = (m) => n.value = m),
797
- multiple: "",
798
- variant: "dark",
799
- items: l.value,
800
- "selected-prefix": s(u)("hr.employee.filter.selected_role_prefix"),
801
- placeholder: s(u)("hr.employee.filter.role_placeholder")
802
- }, null, 8, ["modelValue", "items", "selected-prefix", "placeholder"])]), d("div", Fa, [(Ve = s(ge)) != null && Ve.role.isAdmin ? (y(), M(f, {
803
- key: 0,
804
- content: s(u)("hr.employee.sync.tooltip")
805
- }, {
806
- default: g(() => [i(r, {
807
- icon: "refresh",
808
- label: s(u)("hr.employee.sync.tooltip"),
809
- variant: "tertiary",
810
- onClick: h
811
- }, null, 8, ["label"])]),
812
- _: 1
813
- }, 8, ["content"])) : H("", !0), i(X, {
814
- modelValue: s(k),
815
- "onUpdate:modelValue": a[3] || (a[3] = (m) => Se(k) ? k.value = m : null),
816
- autofocus: "",
817
- class: "pl-4 w-[320px]",
818
- placeholder: s(u)("hr.employee.search.placeholder")
819
- }, null, 8, ["modelValue", "placeholder"])])])), (Fe = s(P)) != null && Fe._id ? (y(), M(Xe, {
820
- key: 2
821
- }, {
822
- default: g(() => [d("div", Ua, [!O.value && s(p).isLoading.value ? (y(), M(ea, {
823
- key: 0
824
- })) : H("", !0), O.value ? (y(), M(oa, {
825
- key: 1,
826
- "is-loading": s(p).isLoading.value,
827
- "is-empty": I.value === 0,
828
- title: s(u)("hr.employee.noData.title"),
829
- subtitle: s(u)("hr.employee.noData.subtitle")
830
- }, {
831
- default: g(() => [(y(), M(Te, {
832
- key: S.value,
833
- class: Ie(["employee-list-table h-full", {
834
- "employee-list-table--pagination-loading": se.value
835
- }]),
836
- "column-defs": ne,
837
- "row-data": W.value,
838
- "page-size": q,
839
- "page-count": Math.ceil(I.value / q),
840
- "row-count": I.value,
841
- "fetch-fn": de,
842
- "hide-footer": I.value <= q,
843
- loading: s(p).isLoading.value,
844
- virtual: !1,
845
- "pin-header-row": "",
846
- onRowClick: a[7] || (a[7] = (m) => D(m.original))
847
- }, {
848
- "list-row": g((m) => [s(Z).xs ? (y(), M(ee, {
849
- key: 0,
850
- class: Ie(["py-12 px-16 items-center justify-between", {
851
- "border-t border-fm-color-neutral-gray-100": m.index > 0
852
- }]),
853
- onClick: (me) => D(m.original)
854
- }, {
855
- 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", {
856
- class: "font-bold"
857
- }, "Since:", -1)), xe(" " + L(m.original.since), 1)])])]), i(r, {
858
- icon: "delete",
859
- variant: "tertiary",
860
- "text-color": "neutral-gray-400",
861
- onClick: le((me) => ue(m.original), ["stop"])
862
- }, null, 8, ["onClick"])]),
863
- _: 2
864
- }, 1032, ["class", "onClick"])) : (y(), M(ee, {
865
- key: 1,
866
- style: {
867
- padding: "0"
868
- },
869
- onClick: (me) => D(m.original)
870
- }, {
871
- default: g(() => [(y(), M(Je(Q), {
872
- employee: m.original
873
- }, null, 8, ["employee"]))]),
874
- _: 2
875
- }, 1032, ["onClick"]))]),
876
- _: 1
877
- }, 8, ["class", "row-data", "page-count", "row-count", "hide-footer", "loading"]))]),
878
- _: 1
879
- }, 8, ["is-loading", "is-empty", "title", "subtitle"])) : H("", !0)])]),
880
- _: 1
881
- })) : H("", !0)])], 64);
882
- };
883
- }
884
- }), ll = /* @__PURE__ */ Ze(Na, [["__scopeId", "data-v-9cf34375"]]);
885
- export {
886
- ll as default
887
- };