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