@feedmepos/mf-hrm-portal 2.0.20-dev.1 → 2.0.20-dev.2

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