@feedmepos/mf-hrm-portal 2.0.16-dev.1 → 2.0.17-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 (48) hide show
  1. package/dist/AuditLogList-DQOiwup5.js +954 -0
  2. package/dist/CollapsibleWrapper.vue_vue_type_script_setup_true_lang-BLJlmPVa.js +58 -0
  3. package/dist/EmployeeList-oERrzrAd.js +828 -0
  4. package/dist/FormItem.vue_vue_type_script_setup_true_lang-CoorkndT.js +34 -0
  5. package/dist/FormSection.vue_vue_type_script_setup_true_lang-DknXTYiK.js +49 -0
  6. package/dist/{Main-DAWaIqp9.js → Main-2uJvk5L7.js} +15 -14
  7. package/dist/{Main-CWilH1zx.js → Main-5nIpv-Sp.js} +9 -9
  8. package/dist/{Main-BNFGDNdT.js → Main-C8ja5xs6.js} +8 -8
  9. package/dist/PermissionSetList-CtpaWlVM.js +323 -0
  10. package/dist/PortalPermissionEditor.vue_vue_type_script_setup_true_lang-B-hvBqE0.js +3439 -0
  11. package/dist/ResponsiveContextMenu.vue_vue_type_script_setup_true_lang-mSJFKo7r.js +132 -0
  12. package/dist/RoleList-CDBP2W5v.js +544 -0
  13. package/dist/TeamMemberList-DSzNjP4y.js +996 -0
  14. package/dist/{TimesheetList-DDaK0iJU.js → TimesheetList-D1ByiuwP.js} +6 -6
  15. package/dist/{app-BlFL6W1C.js → app-hS6MBhCw.js} +211 -163
  16. package/dist/app.js +1 -1
  17. package/dist/{dayjs.min-B81EyB1J.js → dayjs.min-DFcH-XYr.js} +1 -1
  18. package/dist/{employee-BaOat18O.js → employee-fBtBUEwZ.js} +3 -3
  19. package/dist/{iteration-Cuw1W-W9.js → iteration-D23fqAQH.js} +1 -1
  20. package/dist/{lodash-BtkvPA8j.js → lodash-Cqc7y4P5.js} +1 -1
  21. package/dist/{rule-8ylgGfvp.js → rule-BBJzenE1.js} +2 -2
  22. package/dist/src/components/CheckboxInput.vue.d.ts +1 -1
  23. package/dist/src/components/CollapsibleWrapper.vue.d.ts +2 -0
  24. package/dist/src/composables/useBasePermission.d.ts +1 -0
  25. package/dist/src/views/hr/locales/index.d.ts +16 -0
  26. package/dist/src/views/team/components/BasePermission.vue.d.ts +2 -6
  27. package/dist/src/views/team/components/PosRolePermission.vue.d.ts +2 -2
  28. package/dist/src/views/team/locales/index.d.ts +32 -0
  29. package/dist/src/views/team/member/AddMemberForm.vue.d.ts +3 -3
  30. package/dist/style.css +1 -1
  31. package/dist/team-Dq3VcGNH.js +33 -0
  32. package/dist/{timesheet-BpHPcIrb.js → timesheet-OfLQjuvO.js} +2 -2
  33. package/dist/tsconfig.app.tsbuildinfo +1 -1
  34. package/dist/{useAppStore-Bs9JwLL8.js → useAppStore-Du6PRBq0.js} +1 -1
  35. package/dist/{useLoading-ZHDY--I6.js → useLoading-DkTCR5A7.js} +1 -1
  36. package/dist/{useReportPermissions-CNhcwQO7.js → useReportPermissions-DhhjBwPs.js} +3 -3
  37. package/dist/useSearch-BAPEUu1R.js +15 -0
  38. package/package.json +1 -1
  39. package/dist/AuditLogList-BZPpMthp.js +0 -976
  40. package/dist/EmployeeList-DvWJ0QUc.js +0 -736
  41. package/dist/FormSection.vue_vue_type_script_setup_true_lang-BVb8c4YU.js +0 -71
  42. package/dist/HorizontalSplitter-o860F4xM.js +0 -12
  43. package/dist/PermissionSetList-BkRtZkAZ.js +0 -334
  44. package/dist/PortalPermissionEditor.vue_vue_type_script_setup_true_lang-CGYLUF1m.js +0 -3476
  45. package/dist/RoleList-D26aCQ4A.js +0 -528
  46. package/dist/TeamMemberList-Dh3AlL0Q.js +0 -1108
  47. package/dist/useDebounce-B8ZPVS5C.js +0 -15
  48. package/dist/useSearch-B6WK1LBB.js +0 -15
@@ -1,736 +0,0 @@
1
- import { toRaw as De, defineComponent as Ie, ref as p, computed as w, watch as le, resolveComponent as h, createElementBlock as Y, openBlock as g, Fragment as se, renderSlot as Oe, createVNode as d, unref as n, withCtx as V, createElementVNode as v, createBlock as L, createCommentVNode as K, isRef as _e, renderList as Ue, toDisplayString as te, onUnmounted as Be, h as pe, normalizeClass as Te, createTextVNode as Ae, withModifiers as ze } from "vue";
2
- import { useCoreStore as Re, useI18n as Ce, RestaurantSelector as Ve } from "@feedmepos/mf-common";
3
- import { useSnackbar as Me, components as Le, useDialog as Ke, useBreakpoints as Ge, FmButtonVariant as je } from "@feedmepos/ui-library";
4
- import { S as we, _ as We } from "./SelectFilter-DUj7GBtT.js";
5
- import { _ as qe, a as He } from "./app-BlFL6W1C.js";
6
- import { H as Je } from "./HorizontalSplitter-o860F4xM.js";
7
- import { _ as Qe } from "./index.vue_vue_type_script_setup_true_lang-Vc5ARO29.js";
8
- import { u as Pe } from "./useSearch-B6WK1LBB.js";
9
- import { u as Ye } from "./useDebounce-B8ZPVS5C.js";
10
- import { u as $e, E as Ze } from "./employee-BaOat18O.js";
11
- import { l as Xe } from "./lodash-BtkvPA8j.js";
12
- import { _ as Fe, a as Ee } from "./FormSection.vue_vue_type_script_setup_true_lang-BVb8c4YU.js";
13
- import { u as ea } from "./useDiscardConfirm-BHni0LNu.js";
14
- import { u as Ne } from "./useLoading-ZHDY--I6.js";
15
- import { u as be } from "./useAppStore-Bs9JwLL8.js";
16
- /* empty css */
17
- function xe(P) {
18
- return JSON.parse(JSON.stringify(P));
19
- }
20
- function Se(P) {
21
- if (typeof structuredClone > "u")
22
- return xe(P);
23
- try {
24
- return structuredClone(De(P));
25
- } catch {
26
- return xe(P);
27
- }
28
- }
29
- const aa = { class: "fm-typo-en-title-md-600" }, la = { class: "space-y-40" }, ta = { class: "flex flex-row gap-16" }, sa = { class: "space-y-16" }, oa = { class: "flex gap-8 items-center justify-start" }, ke = 4, na = /* @__PURE__ */ Ie({
30
- __name: "EmployeeForm",
31
- props: {
32
- roleErrorMessage: {
33
- type: String,
34
- default: ""
35
- }
36
- },
37
- emits: ["submitted"],
38
- setup(P, { expose: ve, emit: m }) {
39
- const F = be(), f = Re(), U = $e(), $ = Me(), oe = Ne($), ne = m, { t: c } = Ce(), E = p(!1), G = p(!0), re = (t) => {
40
- s.value = t ? Se(t) : Z(), R.value = Se(s.value), S.value = [], x.value = s.value.restaurants.map((l) => l.restaurantId), s.value.passcode && (S.value = s.value.passcode.split(""), T.value = !0), G.value = !t, E.value = !0;
41
- };
42
- function Z() {
43
- return {
44
- code: "",
45
- isMasterUser: !1,
46
- name: "",
47
- passcode: "",
48
- restaurants: []
49
- };
50
- }
51
- const I = w(() => G.value ? c("hr.employee.form.add") : c("hr.employee.form.update")), j = w(() => G.value ? c("common.create") : c("common.update")), R = p(Z()), s = p(Z()), { searchKey: _, filter: fe } = Pe(), N = w(() => {
52
- const t = {};
53
- return F.roles.value.forEach((l) => {
54
- t[l._id] = l.name;
55
- }), t;
56
- });
57
- function ue(t) {
58
- const l = D(t) ?? "";
59
- return N.value[l] || "";
60
- }
61
- const C = w(() => f.restaurants.value.filter(({ _id: l, profile: u, managable: b }) => b ? fe([u.code, u.name, ue(l)]) : x.value.includes(l)).map(({ _id: l, profile: u, managable: b }) => {
62
- const e = F.roles.value.filter((a) => a.restaurants.some((r) => r.id == l)).map((a) => ({
63
- label: a.name,
64
- value: a._id,
65
- disabled: !a.isUsable
66
- }));
67
- return {
68
- value: l,
69
- label: `${u.code ? u.code + "-" : ""}${u.name}`,
70
- roleOptions: e,
71
- disabled: !b
72
- };
73
- })), ye = w(() => {
74
- const t = {};
75
- return s.value.restaurants.forEach((l) => {
76
- t[l.restaurantId] = l.roleId;
77
- }), t;
78
- }), D = (t) => ye.value[t] ?? null, ie = (t, l) => {
79
- s.value.restaurants = [
80
- ...s.value.restaurants.filter((u) => u.restaurantId !== t),
81
- {
82
- restaurantId: t,
83
- roleId: l
84
- }
85
- ];
86
- }, x = p(s.value.restaurants.map((t) => t.restaurantId)), O = w(
87
- () => x.value.filter(
88
- (t) => C.value.some((l) => l.value === t && !l.disabled)
89
- )
90
- ), B = w(() => {
91
- const t = C.value.filter((l) => !l.disabled).length;
92
- return t > 0 && t === O.value.length;
93
- }), X = () => {
94
- const t = x.value.filter((l) => !O.value.includes(l));
95
- if (B.value === !0)
96
- W(t);
97
- else {
98
- const l = C.value.filter((u) => !u.disabled).map((u) => u.value);
99
- W([...l, ...t]);
100
- }
101
- }, W = (t) => {
102
- x.value = t, s.value.restaurants = t.map((l) => {
103
- var e, a;
104
- const u = C.value.find((r) => r.value === l);
105
- if (u != null && u.disabled)
106
- return s.value.restaurants.find((r) => r.restaurantId === l) ?? {
107
- restaurantId: l,
108
- roleId: ""
109
- };
110
- const b = ((e = u == null ? void 0 : u.roleOptions.find((r) => !r.disabled)) == null ? void 0 : e.value) || "";
111
- return {
112
- restaurantId: l,
113
- roleId: ((a = s.value.restaurants.find((r) => r.restaurantId === l)) == null ? void 0 : a.roleId) || b
114
- };
115
- });
116
- }, S = p([]), T = p(!1);
117
- function de() {
118
- T.value && (T.value = !1, S.value = []);
119
- }
120
- const A = p(!1), ee = p(!1);
121
- async function me() {
122
- ee.value = !0;
123
- try {
124
- const t = await Ze.generateEmployeePasscode();
125
- T.value = !1, S.value = t.split("");
126
- } finally {
127
- ee.value = !1;
128
- }
129
- }
130
- const k = ea(
131
- () => !Xe.isEqual(s.value, R.value),
132
- () => {
133
- E.value = !1;
134
- }
135
- );
136
- async function he() {
137
- const t = {
138
- user: {
139
- name: s.value.name,
140
- passcode: s.value.passcode,
141
- code: s.value.code
142
- },
143
- roles: s.value.restaurants
144
- };
145
- s.value.isMasterUser ? await U.createMasterEmployee(t) : (delete t.user.code, await U.createEmployee(t));
146
- }
147
- async function q() {
148
- var u, b;
149
- const t = R.value, l = {
150
- user: {
151
- name: s.value.name,
152
- passcode: s.value.passcode
153
- },
154
- roles: s.value.restaurants,
155
- previousRoles: (u = t.restaurants) == null ? void 0 : u.map((e) => ({
156
- restaurantId: e.restaurantId,
157
- roleId: e.roleId
158
- }))
159
- };
160
- if (!s.value.isMasterUser)
161
- await U.updateEmployee(t._id, l);
162
- else {
163
- const e = {
164
- user: {
165
- name: s.value.name,
166
- passcode: s.value.passcode,
167
- code: s.value.code
168
- },
169
- roles: s.value.restaurants,
170
- previousRoles: (b = t.restaurants) == null ? void 0 : b.map((a) => ({
171
- restaurantId: a.restaurantId,
172
- roleId: a.roleId
173
- }))
174
- };
175
- R.value.isMasterUser ? await U.updateMasterEmployee(t._id, e) : await U.migrateToMasterUser(t._id, e);
176
- }
177
- }
178
- async function ae() {
179
- G.value ? await oe.minor(
180
- async () => {
181
- await he();
182
- },
183
- {
184
- successMessage: c("hr.employee.create.successMessage"),
185
- isLoading: A
186
- }
187
- ) : await oe.minor(
188
- async () => {
189
- await q();
190
- },
191
- {
192
- successMessage: c("hr.employee.update.successMessage"),
193
- isLoading: A
194
- }
195
- ), ne("submitted"), E.value = !1;
196
- }
197
- return le(
198
- () => E.value,
199
- (t) => {
200
- }
201
- ), ve({
202
- show: E,
203
- trigger: re
204
- }), (t, l) => {
205
- const u = h("FmSwitch"), b = h("FmTextField"), e = h("FmPinField"), a = h("FmFormGroup"), r = h("FmButton"), y = h("FmSearch"), M = h("FmCheckbox"), H = h("FmSelect"), ce = h("fm-button"), ge = h("fm-side-sheet");
206
- return g(), Y(se, null, [
207
- Oe(t.$slots, "default", { trigger: re }),
208
- d(ge, {
209
- id: "unit-form",
210
- modelValue: E.value,
211
- "onUpdate:modelValue": l[9] || (l[9] = (o) => E.value = o),
212
- "is-container": n(Le).FmForm,
213
- "is-container-props": {
214
- onValidationSuccess: ae,
215
- blameFormChildOnValidationFailed: !0
216
- },
217
- "max-width": 560,
218
- "onOn:clickedAway": n(k)
219
- }, {
220
- "side-sheet-header": V(() => [
221
- v("p", aa, te(I.value), 1)
222
- ]),
223
- "side-sheet-footer": V(() => [
224
- v("div", oa, [
225
- d(ce, {
226
- label: j.value,
227
- size: "lg",
228
- type: "submit",
229
- variant: "primary",
230
- disabled: A.value
231
- }, null, 8, ["label", "disabled"]),
232
- d(ce, {
233
- label: n(c)("common.cancel"),
234
- size: "lg",
235
- variant: "tertiary",
236
- disabled: A.value,
237
- onClick: l[8] || (l[8] = () => E.value = !1)
238
- }, null, 8, ["label", "disabled"])
239
- ])
240
- ]),
241
- default: V(() => [
242
- v("div", la, [
243
- d(Fe, {
244
- title: n(c)("hr.employee.form.employeeSetting")
245
- }, {
246
- default: V(() => [
247
- d(Ee, {
248
- label: n(c)("hr.employee.form.masterUserConfig")
249
- }, {
250
- default: V(() => [
251
- d(u, {
252
- modelValue: s.value.isMasterUser,
253
- "onUpdate:modelValue": l[0] || (l[0] = (o) => s.value.isMasterUser = o),
254
- value: "masterUser",
255
- label: n(c)("hr.employee.form.masterUser"),
256
- sublabel: n(c)("hr.employee.form.masterUserSublabel"),
257
- "label-placement": "right"
258
- }, null, 8, ["modelValue", "label", "sublabel"])
259
- ]),
260
- _: 1
261
- }, 8, ["label"]),
262
- v("div", ta, [
263
- s.value.isMasterUser ? (g(), L(b, {
264
- key: 0,
265
- modelValue: s.value.code,
266
- "onUpdate:modelValue": l[1] || (l[1] = (o) => s.value.code = o),
267
- label: n(c)("hr.employee.form.code")
268
- }, null, 8, ["modelValue", "label"])) : K("", !0),
269
- d(b, {
270
- modelValue: s.value.name,
271
- "onUpdate:modelValue": l[2] || (l[2] = (o) => s.value.name = o),
272
- class: "w-full",
273
- label: n(c)("hr.employee.form.name"),
274
- rules: [(o) => !!o || n(c)("hr.employee.form.required")]
275
- }, null, 8, ["modelValue", "label", "rules"])
276
- ]),
277
- d(Ee, {
278
- label: n(c)("hr.employee.form.passcode")
279
- }, {
280
- default: V(() => [
281
- v("div", sa, [
282
- d(a, {
283
- modelValue: S.value,
284
- "onUpdate:modelValue": l[5] || (l[5] = (o) => S.value = o),
285
- rules: [
286
- (o) => (o == null ? void 0 : o.filter((J) => !!J).length) !== ke ? n(c)("hr.employee.form.passcodeRequired") : !0
287
- ]
288
- }, {
289
- default: V(() => [
290
- d(e, {
291
- modelValue: S.value,
292
- "onUpdate:modelValue": l[3] || (l[3] = (o) => S.value = o),
293
- length: ke,
294
- masked: T.value,
295
- onComplete: l[4] || (l[4] = (o) => s.value.passcode = o),
296
- onFocus: de
297
- }, null, 8, ["modelValue", "masked"])
298
- ]),
299
- _: 1
300
- }, 8, ["modelValue", "rules"]),
301
- d(r, {
302
- variant: "secondary",
303
- "text-color": "primary",
304
- "border-color": "primary",
305
- label: n(c)("hr.employee.form.passcodeGenerate"),
306
- size: "md",
307
- loading: ee.value,
308
- onClick: me
309
- }, null, 8, ["label", "loading"])
310
- ])
311
- ]),
312
- _: 1
313
- }, 8, ["label"])
314
- ]),
315
- _: 1
316
- }, 8, ["title"]),
317
- d(Fe, {
318
- title: n(c)("hr.employee.form.role")
319
- }, {
320
- default: V(() => [
321
- d(y, {
322
- modelValue: n(_),
323
- "onUpdate:modelValue": l[6] || (l[6] = (o) => _e(_) ? _.value = o : null),
324
- placeholder: n(c)("hr.restaurant.search.placeholder")
325
- }, null, 8, ["modelValue", "placeholder"]),
326
- d(a, {
327
- modelValue: x.value,
328
- "onUpdate:modelValue": l[7] || (l[7] = (o) => x.value = o),
329
- rules: [(o) => o.length > 0 || n(c)("hr.employee.form.atLeastOneRestaurant")]
330
- }, {
331
- default: V(() => [
332
- d(M, {
333
- "model-value": B.value,
334
- label: n(c)("hr.employee.form.all"),
335
- value: "1",
336
- indeterminate: O.value.length > 0,
337
- "onUpdate:modelValue": X
338
- }, null, 8, ["model-value", "label", "indeterminate"]),
339
- (g(!0), Y(se, null, Ue(C.value, (o, J) => {
340
- var i;
341
- return g(), Y(se, { key: J }, [
342
- d(M, {
343
- "model-value": x.value,
344
- label: o.label,
345
- value: o.value,
346
- disabled: o.disabled,
347
- "onUpdate:modelValue": W
348
- }, null, 8, ["model-value", "label", "value", "disabled"]),
349
- x.value.includes(o.value) ? (g(), L(H, {
350
- key: 0,
351
- class: "ml-32 mr-8",
352
- items: o.roleOptions,
353
- "model-value": D(o.value),
354
- multiselect: !1,
355
- placeholder: ((i = o.roleOptions.find((z) => !z.disabled) ?? o.roleOptions[0]) == null ? void 0 : i.label) ?? "",
356
- disabled: o.disabled,
357
- "onUpdate:modelValue": (z) => ie(o.value, z)
358
- }, null, 8, ["items", "model-value", "placeholder", "disabled", "onUpdate:modelValue"])) : K("", !0)
359
- ], 64);
360
- }), 128))
361
- ]),
362
- _: 1
363
- }, 8, ["modelValue", "rules"])
364
- ]),
365
- _: 1
366
- }, 8, ["title"])
367
- ])
368
- ]),
369
- _: 1
370
- }, 8, ["modelValue", "is-container", "is-container-props", "onOn:clickedAway"])
371
- ], 64);
372
- };
373
- }
374
- }), ra = {
375
- class: "space-y-8"
376
- }, ua = {
377
- class: "xs:hidden flex w-full items-start justify-between"
378
- }, ia = {
379
- class: "flex items-start gap-8"
380
- }, da = {
381
- class: "flex"
382
- }, ma = {
383
- class: "space-y-4 sm:hidden md:hidden lg:hidden"
384
- }, ca = {
385
- class: "px-16"
386
- }, pa = {
387
- class: "px-16 flex items-start gap-8"
388
- }, va = {
389
- class: "flex h-full flex-col overflow-auto"
390
- }, fa = {
391
- class: "pb-64 sm:hidden md:hidden lg:hidden"
392
- }, ya = {
393
- class: "space-y-4"
394
- }, ha = {
395
- class: "fm-typo-en-body-lg-600"
396
- }, ga = {
397
- key: 0,
398
- class: "mr-4"
399
- }, _a = {
400
- class: "text-fm-color-typo-secondary"
401
- }, Q = 200, ba = /* @__PURE__ */ Ie({
402
- __name: "EmployeeList",
403
- setup(P, {
404
- expose: ve
405
- }) {
406
- const {
407
- t: m
408
- } = Ce(), F = p(), f = $e(), U = Re(), {
409
- currentBusiness: $,
410
- sessionUser: oe
411
- } = U, ne = be(), c = p(U.restaurants.value.length === 0), E = p(ne.roles.value.length === 0), G = le(U.restaurants, (e) => {
412
- if (e.length > 0) {
413
- if (c.value = !1, f.listEmployees.value.length > 0) {
414
- const a = new Map(e.map((r) => [r._id, r]));
415
- f.listEmployees.value = f.listEmployees.value.map((r) => ({
416
- ...r,
417
- restaurants: r.restaurants.map((y) => {
418
- var M, H;
419
- return {
420
- ...y,
421
- restaurantName: ((M = a.get(y.restaurantId)) == null ? void 0 : M.profile.name) || y.restaurantName,
422
- restaurantCode: ((H = a.get(y.restaurantId)) == null ? void 0 : H.profile.code) ?? void 0
423
- };
424
- })
425
- }));
426
- }
427
- G();
428
- }
429
- }), re = le(ne.roles, (e) => {
430
- if (e.length > 0) {
431
- if (E.value = !1, f.listEmployees.value.length > 0) {
432
- const a = new Map(e.map((r) => [r._id, r.name]));
433
- f.listEmployees.value = f.listEmployees.value.map((r) => ({
434
- ...r,
435
- restaurants: r.restaurants.map((y) => ({
436
- ...y,
437
- roleName: a.get(y.roleId) || y.roleName
438
- }))
439
- }));
440
- }
441
- re();
442
- }
443
- }), Z = w(() => f.listEmployees.value), {
444
- searchKey: I
445
- } = Pe(""), j = p(""), R = w(() => Z.value), s = w(() => f.totalEmployees.value), _ = p(1), fe = w(() => f.isLoading.value), N = p(!1), ue = w(() => {
446
- var e;
447
- return JSON.stringify({
448
- businessId: ((e = $.value) == null ? void 0 : e._id) ?? "",
449
- search: j.value.trim(),
450
- restaurantIds: [...F.value ?? []].sort(),
451
- roleIds: [...k.value ?? []].sort()
452
- });
453
- }), C = (e) => {
454
- const a = e.restaurantCode;
455
- let y = e.restaurantName;
456
- return e.roleName && (y = `${a ? a + " - " : ""}${y} (${e.roleName})`), y;
457
- }, ye = [{
458
- accessorKey: "code",
459
- size: 100,
460
- header: () => m("hr.employee.columns.code")
461
- }, {
462
- accessorKey: "name",
463
- header: () => m("hr.employee.columns.name"),
464
- enableSorting: !1
465
- }, {
466
- accessorKey: "restaurants",
467
- align: "center",
468
- header: () => m("hr.employee.columns.restaurants"),
469
- enableSorting: !1,
470
- cell(e) {
471
- return c.value || E.value ? pe("div", {
472
- class: "h-16 w-[160px] animate-pulse rounded bg-fm-color-neutral-gray-200"
473
- }) : e.row.original.restaurants.map((a, r) => {
474
- const y = C(a);
475
- return pe("div", (r ? `
476
- ` : "") + y);
477
- });
478
- }
479
- }, {
480
- accessorKey: "since",
481
- header: () => m("hr.employee.columns.since"),
482
- enableSorting: !1
483
- }, {
484
- id: "action",
485
- size: 52,
486
- meta: {
487
- cellClass: "pl-16",
488
- headerContentClass: "-mx-16"
489
- },
490
- cell: (e) => pe("div", {
491
- class: "w-full flex justify-end items-center"
492
- }, [pe(Le.FmButton, {
493
- prependIcon: "delete",
494
- variant: je.Tertiary,
495
- textColor: "neutral-gray-400",
496
- onClick: (a) => {
497
- a.stopPropagation(), de(e.row.original);
498
- }
499
- })])
500
- }], D = Me(), ie = Ke(), x = Ne(D), O = p(!1), B = p(), X = p();
501
- function W(e) {
502
- const a = e.isRestricted;
503
- return a && D.open({
504
- message: m("hr.employee.cannotUpdateMasterUser", {
505
- name: e.name
506
- }),
507
- type: "error"
508
- }), a;
509
- }
510
- const S = (e) => {
511
- var r;
512
- e && W(e) || (r = X.value) == null || r.trigger(e);
513
- }, {
514
- breakpoints: T
515
- } = Ge(), de = (e) => {
516
- W(e) || ie.open({
517
- title: m("hr.employee.remove.title"),
518
- message: m("hr.employee.remove.message", {
519
- name: e.name
520
- }),
521
- minWidth: T.value.lg ? 588 : 0,
522
- primaryActions: {
523
- text: m("common.remove"),
524
- close: !1,
525
- variant: "destructive",
526
- isLoading: O
527
- },
528
- secondaryActions: {
529
- text: m("common.cancel"),
530
- close: !0
531
- }
532
- }).onPrimary(async () => {
533
- if (O.value) return;
534
- const r = e.isMasterUser ? f.deleteMasterEmployee : f.deleteEmployee;
535
- await x.minor(async () => {
536
- await r(e), await ae();
537
- }, {
538
- isLoading: O,
539
- successMessage: m("hr.employee.remove.successMessage", {
540
- name: e.name
541
- })
542
- }).catch(() => {
543
- }), ie.close();
544
- });
545
- }, A = p("");
546
- function ee() {
547
- var e;
548
- (e = X.value) == null || e.trigger();
549
- }
550
- const me = w(() => be().roles.value.map((e) => ({
551
- label: e.name,
552
- value: e._id
553
- }))), k = p();
554
- async function he() {
555
- try {
556
- await f.syncUsersMeta(), await ae(), D.open({
557
- message: m("hr.employee.sync.successMessage"),
558
- type: "success"
559
- });
560
- } catch (e) {
561
- console.error("Error syncing users:", e), D.open({
562
- message: m("hr.employee.sync.errorMessage"),
563
- type: "error"
564
- });
565
- }
566
- }
567
- async function q(e = _.value) {
568
- var a, r;
569
- await f.readEmployeesPage({
570
- limit: Q,
571
- offset: (e - 1) * Q,
572
- search: j.value.trim() || void 0,
573
- restaurantIds: (a = F.value) != null && a.length ? F.value : void 0,
574
- roleIds: (r = k.value) != null && r.length ? k.value : void 0
575
- });
576
- }
577
- async function ae() {
578
- var a;
579
- if (!((a = $.value) != null && a._id)) return;
580
- await q(_.value);
581
- const e = Math.max(1, Math.ceil(s.value / Q));
582
- _.value > e && (_.value = e, await q(_.value));
583
- }
584
- async function t() {
585
- var e, a;
586
- return await f.readAllEmployeesPage({
587
- search: j.value.trim() || void 0,
588
- restaurantIds: (e = F.value) != null && e.length ? F.value : void 0,
589
- roleIds: (a = k.value) != null && a.length ? k.value : void 0
590
- }, s.value);
591
- }
592
- const l = Ye(I, () => {
593
- j.value = I.value;
594
- }, 300);
595
- Be(l);
596
- let u = !1;
597
- async function b({
598
- pageIndex: e
599
- }) {
600
- var a;
601
- if ((a = $.value) != null && a._id && !u && !(e === 0 && _.value === 1 && R.value.length > 0)) {
602
- u = !0, _.value = e + 1;
603
- try {
604
- await q(_.value);
605
- } finally {
606
- u = !1;
607
- }
608
- }
609
- }
610
- return le(ue, async () => {
611
- var e;
612
- _.value = 1, N.value = !1, (e = $.value) != null && e._id && (await q(1), N.value = !0);
613
- }, {
614
- immediate: !0
615
- }), le(() => B.value && B.value.restaurants, (e) => {
616
- e && e.length > 0 && (A.value = "");
617
- }), ve({
618
- create: ee,
619
- filteredEmployees: R,
620
- exportEmployees: t
621
- }), (e, a) => {
622
- var o, J;
623
- const r = h("FmButton"), y = h("FmTooltip"), M = h("FmSearch"), H = h("FmTable"), ce = h("FmListItem"), ge = h("FmList");
624
- return g(), Y(se, null, [d(na, {
625
- ref_key: "employeeFormRef",
626
- ref: X,
627
- modelValue: B.value,
628
- "onUpdate:modelValue": a[0] || (a[0] = (i) => B.value = i),
629
- "role-error-message": A.value,
630
- class: "gap-8",
631
- onSubmitted: ae
632
- }, null, 8, ["modelValue", "role-error-message"]), v("div", ra, [v("div", ua, [v("div", ia, [d(n(Ve), {
633
- modelValue: F.value,
634
- "onUpdate:modelValue": a[1] || (a[1] = (i) => F.value = i),
635
- "managable-only": !1,
636
- multiple: "",
637
- variant: "dark",
638
- class: "!w-auto"
639
- }, null, 8, ["modelValue"]), d(we, {
640
- modelValue: k.value,
641
- "onUpdate:modelValue": a[2] || (a[2] = (i) => k.value = i),
642
- multiple: "",
643
- variant: "dark",
644
- items: me.value,
645
- "selected-prefix": n(m)("hr.employee.filter.selected_role_prefix"),
646
- placeholder: n(m)("hr.employee.filter.role_placeholder")
647
- }, null, 8, ["modelValue", "items", "selected-prefix", "placeholder"])]), v("div", da, [(o = n(oe)) != null && o.role.isAdmin ? (g(), L(y, {
648
- key: 0,
649
- content: n(m)("hr.employee.sync.tooltip")
650
- }, {
651
- default: V(() => [d(r, {
652
- icon: "refresh",
653
- label: n(m)("hr.employee.sync.tooltip"),
654
- variant: "tertiary",
655
- onClick: he
656
- }, null, 8, ["label"])]),
657
- _: 1
658
- }, 8, ["content"])) : K("", !0), d(M, {
659
- modelValue: n(I),
660
- "onUpdate:modelValue": a[3] || (a[3] = (i) => _e(I) ? I.value = i : null),
661
- autofocus: "",
662
- class: "pl-4 w-[320px]",
663
- placeholder: n(m)("hr.employee.search.placeholder")
664
- }, null, 8, ["modelValue", "placeholder"])])]), v("div", ma, [v("div", ca, [d(M, {
665
- modelValue: n(I),
666
- "onUpdate:modelValue": a[4] || (a[4] = (i) => _e(I) ? I.value = i : null),
667
- autofocus: "",
668
- placeholder: n(m)("hr.employee.search.placeholder")
669
- }, null, 8, ["modelValue", "placeholder"])]), d(Je), v("div", pa, [d(n(Ve), {
670
- modelValue: F.value,
671
- "onUpdate:modelValue": a[5] || (a[5] = (i) => F.value = i),
672
- "managable-only": !1,
673
- multiple: "",
674
- variant: "dark",
675
- class: "!w-auto"
676
- }, null, 8, ["modelValue"]), d(we, {
677
- modelValue: k.value,
678
- "onUpdate:modelValue": a[6] || (a[6] = (i) => k.value = i),
679
- multiple: "",
680
- items: me.value,
681
- variant: "dark",
682
- "selected-prefix": n(m)("hr.employee.filter.selected_role_prefix"),
683
- placeholder: n(m)("hr.employee.filter.role_placeholder")
684
- }, null, 8, ["modelValue", "items", "selected-prefix", "placeholder"])])]), (J = n($)) != null && J._id ? (g(), L(qe, {
685
- key: 0
686
- }, {
687
- default: V(() => [v("div", va, [!N.value && n(f).isLoading.value ? (g(), L(He, {
688
- key: 0
689
- })) : !N.value || s.value === 0 ? (g(), L(n(Qe), {
690
- key: 1,
691
- title: n(m)("hr.employee.noData.title"),
692
- subtitle: n(m)("hr.employee.noData.subtitle")
693
- }, null, 8, ["title", "subtitle"])) : K("", !0), N.value ? (g(), L(H, {
694
- key: ue.value,
695
- class: Te(["xs:hidden employee-list-table min-h-0 flex-1", {
696
- "employee-list-table--pagination-loading": fe.value
697
- }]),
698
- "column-defs": ye,
699
- "row-data": R.value,
700
- "page-size": Q,
701
- "page-count": Math.ceil(s.value / Q),
702
- "row-count": s.value,
703
- "fetch-fn": b,
704
- "hide-footer": s.value <= Q,
705
- loading: n(f).isLoading.value,
706
- virtual: !1,
707
- "pin-header-row": "",
708
- onRowClick: a[7] || (a[7] = (i) => S(i.original))
709
- }, null, 8, ["class", "row-data", "page-count", "row-count", "hide-footer", "loading"])) : K("", !0), v("div", fa, [d(ge, {
710
- separator: ""
711
- }, {
712
- default: V(() => [(g(!0), Y(se, null, Ue(R.value, (i) => (g(), L(ce, {
713
- key: i._id,
714
- class: "py-12 px-16 items-center justify-between",
715
- onClick: (z) => S(i)
716
- }, {
717
- default: V(() => [v("div", ya, [v("p", ha, [i.code ? (g(), Y("span", ga, te(i.code) + ".", 1)) : K("", !0), Ae(te(i.name), 1)]), v("div", _a, [v("p", null, te(n(m)("hr.employee.restaurants", {
718
- restaurants: i.restaurants.map((z) => C(z)).join(", ")
719
- })), 1), v("p", null, " Since: " + te(i.since), 1)])]), d(r, {
720
- icon: "delete",
721
- variant: "tertiary",
722
- "text-color": "neutral-gray-400",
723
- onClick: ze((z) => de(i), ["stop"])
724
- }, null, 8, ["onClick"])]),
725
- _: 2
726
- }, 1032, ["onClick"]))), 128))]),
727
- _: 1
728
- })])])]),
729
- _: 1
730
- })) : K("", !0)])], 64);
731
- };
732
- }
733
- }), Da = /* @__PURE__ */ We(ba, [["__scopeId", "data-v-48cb3903"]]);
734
- export {
735
- Da as default
736
- };