@feedmepos/mf-hrm-portal 2.0.17-dev.3 → 2.0.17-dev.5

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 (41) hide show
  1. package/dist/AuditLogList-Dl3Nmf00.js +1011 -0
  2. package/dist/EmployeeList-DBd_rVW2.js +831 -0
  3. package/dist/{Main-Dkr5lzbv.js → Main-CQ3KwxDY.js} +1368 -1371
  4. package/dist/{Main--tejoyEP.js → Main-pTgqNncY.js} +125 -125
  5. package/dist/{Main-BNXKItvX.js → Main-w0XUUaBp.js} +6 -6
  6. package/dist/PermissionSetList-B8qNOWH6.js +347 -0
  7. package/dist/{PortalPermissionEditor.vue_vue_type_script_setup_true_lang-BBsaxaXu.js → PortalPermissionEditor.vue_vue_type_script_setup_true_lang-C9VUjAu_.js} +1064 -1060
  8. package/dist/{RoleList-SZCgvYvC.js → RoleList-DMFJsUZv.js} +202 -200
  9. package/dist/Skeleton.vue_vue_type_script_setup_true_lang-B4PxNMwq.js +16 -0
  10. package/dist/TeamMemberList-BLRTfKLz.js +1031 -0
  11. package/dist/{TimesheetList-D-3k0Uad.js → TimesheetList-Bwp9_xHe.js} +6 -6
  12. package/dist/{app-BjXuSCis.js → app-COJbSNM4.js} +1975 -1440
  13. package/dist/app.js +1 -1
  14. package/dist/{dayjs.min-z-vrgFCL.js → dayjs.min-CcBi6N-K.js} +1 -1
  15. package/dist/{employee-DAqAMupR.js → employee-xiV0LfnL.js} +3 -3
  16. package/dist/{iteration-Cp1eSTJA.js → iteration-JOKbtlLf.js} +1 -1
  17. package/dist/{lodash-CXLZQQp8.js → lodash-D5xlVzib.js} +1 -1
  18. package/dist/rule-3sXHiW0y.js +994 -0
  19. package/dist/src/api/audit-log/index.d.ts +9 -0
  20. package/dist/src/api/report-query/index.d.ts +2 -2
  21. package/dist/src/components/Skeleton.vue.d.ts +7 -0
  22. package/dist/src/composables/useBasePermission.d.ts +1 -0
  23. package/dist/src/stores/team.d.ts +6 -6
  24. package/dist/src/types/team.d.ts +1 -1
  25. package/dist/src/views/hr/locales/index.d.ts +172 -0
  26. package/dist/src/views/team/components/BasePermission.vue.d.ts +1 -1
  27. package/dist/src/views/team/locales/index.d.ts +312 -0
  28. package/dist/style.css +1 -1
  29. package/dist/{team-CnQ_rIx2.js → team-CyNektSD.js} +1 -1
  30. package/dist/{timesheet-BlPhOifI.js → timesheet-DkD3AysG.js} +2 -2
  31. package/dist/tsconfig.app.tsbuildinfo +1 -1
  32. package/dist/{useAppStore-BVnrWyPF.js → useAppStore-CvmsaYSG.js} +1 -1
  33. package/dist/{useLoading-7ia-Bps7.js → useLoading-4TNmhm5N.js} +1 -1
  34. package/dist/useReportPermissions-CWMFFb8E.js +70 -0
  35. package/package.json +2 -2
  36. package/dist/AuditLogList-C6qAeY5g.js +0 -954
  37. package/dist/EmployeeList-COtXtTqG.js +0 -827
  38. package/dist/PermissionSetList-B_Sdvbu7.js +0 -340
  39. package/dist/TeamMemberList-Dk5HeFfQ.js +0 -1008
  40. package/dist/rule-vBxopbM_.js +0 -990
  41. package/dist/useReportPermissions-C8HMek35.js +0 -60
@@ -1,954 +0,0 @@
1
- import { defineComponent as Ae, ref as h, computed as w, onMounted as ft, onBeforeUnmount as vt, watch as Q, resolveComponent as C, createElementBlock as b, openBlock as c, createBlock as oe, createCommentVNode as V, createElementVNode as l, Fragment as ee, renderList as se, withCtx as N, createVNode as u, toDisplayString as i, unref as n, nextTick as pt } from "vue";
2
- import { d as y } from "./dayjs.min-z-vrgFCL.js";
3
- import { useI18n as Ee, useCoreStore as gt } from "@feedmepos/mf-common";
4
- import { f as Ve, _ as bt } from "./app-BjXuSCis.js";
5
- import { components as Oe } from "@feedmepos/ui-library";
6
- import { g as ht, b as yt } from "./iteration-Cp1eSTJA.js";
7
- import { S as ce } from "./SelectFilter-DUj7GBtT.js";
8
- import { _ as _t } from "./PageLayout.vue_vue_type_script_setup_true_lang-HKK4cbW8.js";
9
- import { _ as xt } from "./index.vue_vue_type_script_setup_true_lang-Vc5ARO29.js";
10
- import { p as Pe } from "./rule-vBxopbM_.js";
11
- import { u as Lt } from "./team-CnQ_rIx2.js";
12
- const be = [
13
- { key: "all", label: "All", subjectPrefixes: [] },
14
- { key: "inventory", label: "Inventory", subjectPrefixes: ["business::inventory", "inventory"] },
15
- { key: "report", label: "Report", subjectPrefixes: ["business::report", "report"] },
16
- { key: "hrm", label: "HRM", subjectPrefixes: ["business::hrm", "hrm"] },
17
- { key: "payment", label: "Payment", subjectPrefixes: ["business::payment", "payment"] },
18
- { key: "menu", label: "Menu", subjectPrefixes: ["business::menu", "menu"] },
19
- { key: "crm", label: "CRM", subjectPrefixes: ["business::crm", "crm"] }
20
- // Add more as modules are revamped with new actionguard:
21
- // { key: 'restaurantOperation', label: 'Restaurant Operation', subjectPrefixes: ['restaurant'] },
22
- ], St = "/audit-logs", je = {
23
- async read(s) {
24
- var x, O, E, T, M;
25
- const a = {
26
- limit: (s == null ? void 0 : s.limit) ?? 100,
27
- offset: (s == null ? void 0 : s.offset) ?? 0,
28
- ...s != null && s.from ? { from: s.from } : {},
29
- ...s != null && s.to ? { to: s.to } : {},
30
- ...(x = s == null ? void 0 : s.userIds) != null && x.length ? { userIds: s.userIds } : {},
31
- ...(O = s == null ? void 0 : s.subjects) != null && O.length ? { subjects: s.subjects } : {},
32
- ...(E = s == null ? void 0 : s.subjectPrefixes) != null && E.length ? { subjectPrefixes: s.subjectPrefixes } : {},
33
- ...(T = s == null ? void 0 : s.actions) != null && T.length ? { actions: s.actions } : {},
34
- ...(M = s == null ? void 0 : s.outcomes) != null && M.length ? { outcomes: s.outcomes } : {}
35
- };
36
- return console.log("[AuditLogAPI] request params:", a), ht(
37
- await yt().get(St, {
38
- params: a,
39
- // Serialize arrays as repeated params: key=val1&key=val2
40
- // (NestJS @Query expects this; axios default adds brackets which break matching)
41
- paramsSerializer: (o) => {
42
- const I = new URLSearchParams();
43
- for (const [Y, p] of Object.entries(o))
44
- if (Array.isArray(p))
45
- for (const P of p) I.append(Y, String(P));
46
- else p != null && I.append(Y, String(p));
47
- return console.log("[AuditLogAPI] serialized query string:", I.toString()), I.toString();
48
- }
49
- })
50
- );
51
- }
52
- }, kt = { class: "flex h-[46px] items-center gap-8 rounded-sm px-16 hover:bg-fm-color-opacity-sm" }, wt = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, Mt = {
53
- "data-more-measure": "",
54
- class: "flex h-[46px] items-center gap-8 rounded-sm px-16"
55
- }, Ft = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, Dt = /* @__PURE__ */ Ae({
56
- __name: "AuditLogModuleTabs",
57
- props: {
58
- modelValue: {},
59
- items: {}
60
- },
61
- emits: ["update:modelValue"],
62
- setup(s, { emit: a }) {
63
- const x = s, O = a, { t: E } = Ee(), T = h(!1), M = h(null), o = h(null), I = h([]), Y = h(0), p = h(0);
64
- let P = null;
65
- async function F() {
66
- if (await pt(), !o.value) return;
67
- const m = o.value.querySelectorAll("[data-tab-measure]");
68
- I.value = Array.from(m).map((S) => S.offsetWidth);
69
- const f = o.value.querySelector("[data-more-measure]");
70
- Y.value = (f == null ? void 0 : f.offsetWidth) ?? 0;
71
- }
72
- const J = w(() => {
73
- const m = x.items.length;
74
- if (m === 0) return 0;
75
- if (!p.value || I.value.length !== m) return m;
76
- const f = I.value;
77
- if (f.reduce((r, B) => r + B, 0) <= p.value) return m;
78
- const k = Y.value;
79
- let z = 0, U = 0;
80
- for (let r = 0; r < m && !(z + f[r] + k > p.value); r++)
81
- z += f[r], U++;
82
- return U;
83
- }), te = w(() => {
84
- const m = J.value, f = x.items.length;
85
- if (m >= f) return [...x.items];
86
- const S = x.items.slice(0, m), k = x.items.find((g) => g.value === x.modelValue);
87
- if (!k || S.some((g) => g.value === k.value)) return S;
88
- if (m === 0) return [k];
89
- const z = x.items.findIndex((g) => g.value === k.value), U = I.value, r = Y.value, B = U[z] ?? 0;
90
- let H = m, ne = U.slice(0, H - 1).reduce((g, ae) => g + ae, 0);
91
- for (; H > 1 && ne + B + r > p.value; )
92
- H--, ne = U.slice(0, H - 1).reduce((g, ae) => g + ae, 0);
93
- return [...x.items.slice(0, Math.max(H - 1, 0)), k];
94
- }), $ = w(() => {
95
- const m = new Set(te.value.map((f) => f.value));
96
- return x.items.filter((f) => !m.has(f.value));
97
- });
98
- function R(m) {
99
- T.value = !1, O("update:modelValue", m);
100
- }
101
- return ft(async () => {
102
- await F(), M.value && (p.value = M.value.clientWidth, P = new ResizeObserver(() => {
103
- M.value && (p.value = M.value.clientWidth);
104
- }), P.observe(M.value));
105
- }), vt(() => {
106
- P == null || P.disconnect(), P = null;
107
- }), Q(
108
- () => x.items,
109
- () => {
110
- F();
111
- },
112
- { deep: !0 }
113
- ), (m, f) => {
114
- const S = C("FmTab"), k = C("FmIcon"), z = C("FmMenuItem"), U = C("FmMenu");
115
- return c(), b("div", {
116
- ref_key: "containerRef",
117
- ref: M,
118
- class: "relative flex w-full flex-row items-center"
119
- }, [
120
- (c(!0), b(ee, null, se(te.value, (r) => (c(), oe(S, {
121
- key: r.value,
122
- "model-value": s.modelValue,
123
- label: r.label,
124
- badge: r.badge,
125
- disabled: r.disabled,
126
- value: r.value,
127
- "onUpdate:modelValue": R
128
- }, null, 8, ["model-value", "label", "badge", "disabled", "value"]))), 128)),
129
- $.value.length > 0 ? (c(), oe(U, {
130
- key: 0,
131
- "show-menu": T.value,
132
- class: "max-w-[360px] min-w-[90px] rounded-sm",
133
- placement: "bottom-start",
134
- onMenuChanged: f[0] || (f[0] = (r) => T.value = r)
135
- }, {
136
- "menu-button": N(() => [
137
- l("div", kt, [
138
- u(k, { name: "more_vert" }),
139
- l("span", wt, i(n(E)("auditLog.modules.more")), 1)
140
- ])
141
- ]),
142
- default: N(() => [
143
- (c(!0), b(ee, null, se($.value, (r) => (c(), oe(z, {
144
- key: r.value,
145
- "model-value": s.modelValue === r.value,
146
- label: r.label,
147
- disabled: r.disabled,
148
- onClick: (B) => R(r.value)
149
- }, null, 8, ["model-value", "label", "disabled", "onClick"]))), 128))
150
- ]),
151
- _: 1
152
- }, 8, ["show-menu"])) : V("", !0),
153
- l("div", {
154
- ref_key: "measurerRef",
155
- ref: o,
156
- "aria-hidden": "true",
157
- class: "pointer-events-none invisible absolute -left-[9999px] -top-[9999px] flex flex-row items-center"
158
- }, [
159
- (c(!0), b(ee, null, se(s.items, (r) => (c(), b("div", {
160
- key: `measure-${r.value}`,
161
- "data-tab-measure": ""
162
- }, [
163
- u(S, {
164
- "model-value": s.modelValue,
165
- label: r.label,
166
- badge: r.badge,
167
- disabled: r.disabled,
168
- value: r.value
169
- }, null, 8, ["model-value", "label", "badge", "disabled", "value"])
170
- ]))), 128)),
171
- l("div", Mt, [
172
- u(k, { name: "more_vert" }),
173
- l("span", Ft, i(n(E)("auditLog.modules.more")), 1)
174
- ])
175
- ], 512)
176
- ], 512);
177
- };
178
- }
179
- }), Tt = {
180
- class: "flex flex-col gap-4 p-12 w-[260px]"
181
- }, It = {
182
- class: "text-xs font-semibold text-fm-color-typo-secondary mb-4"
183
- }, Vt = {
184
- class: "flex min-h-0 flex-1 flex-col gap-16"
185
- }, Ot = {
186
- class: "space-y-16"
187
- }, Pt = {
188
- class: "flex flex-wrap items-center gap-8"
189
- }, jt = {
190
- class: "w-fit"
191
- }, Ct = {
192
- key: 0,
193
- class: "w-fit"
194
- }, At = {
195
- class: "w-fit"
196
- }, Et = {
197
- class: "w-fit"
198
- }, Rt = {
199
- class: "flex h-full flex-col"
200
- }, Ut = {
201
- key: 0,
202
- class: "flex shrink-0 items-center justify-end border-t border-fm-color-border-default py-4"
203
- }, $t = {
204
- class: "text-sm text-fm-color-typo-secondary"
205
- }, Nt = {
206
- key: 0,
207
- class: "space-y-12 p-4 text-sm"
208
- }, Yt = {
209
- class: "flex items-start justify-between gap-8 rounded-lg border border-fm-color-border-default p-12"
210
- }, zt = {
211
- class: "min-w-0 flex-1"
212
- }, Bt = {
213
- class: "audit-log-operation-label-detail text-base font-bold leading-snug text-fm-color-typo-primary"
214
- }, Kt = {
215
- class: "rounded-lg border border-fm-color-border-default p-12"
216
- }, qt = {
217
- class: "space-y-12"
218
- }, Ht = {
219
- class: "text-xs text-fm-color-typo-secondary"
220
- }, Wt = {
221
- class: "font-semibold"
222
- }, Jt = {
223
- class: "text-xs text-fm-color-typo-secondary"
224
- }, Gt = {
225
- class: "font-semibold"
226
- }, Xt = {
227
- class: "text-xs text-fm-color-typo-secondary"
228
- }, Zt = {
229
- class: "break-all font-semibold"
230
- }, Qt = {
231
- class: "text-xs text-fm-color-typo-secondary"
232
- }, ea = {
233
- class: "font-semibold"
234
- }, ta = {
235
- key: 0
236
- }, aa = {
237
- class: "text-xs text-fm-color-typo-secondary"
238
- }, la = {
239
- class: "break-all font-mono text-xs font-semibold"
240
- }, oa = {
241
- class: "text-xs text-fm-color-typo-secondary"
242
- }, sa = {
243
- class: "break-all font-mono text-xs font-semibold"
244
- }, na = {
245
- class: "text-xs text-fm-color-typo-secondary"
246
- }, ia = {
247
- class: "font-semibold"
248
- }, ra = {
249
- key: 0,
250
- class: "rounded-lg border border-fm-color-border-default"
251
- }, ua = {
252
- class: "p-12"
253
- }, da = {
254
- class: "text-base font-bold text-fm-color-typo-primary"
255
- }, ca = {
256
- class: "space-y-12 p-12"
257
- }, ma = {
258
- class: "text-xs text-fm-color-typo-secondary"
259
- }, fa = {
260
- class: "font-semibold"
261
- }, va = {
262
- class: "rounded-lg border border-fm-color-border-default"
263
- }, pa = {
264
- class: "p-12"
265
- }, ga = {
266
- class: "text-base font-bold text-fm-color-typo-primary"
267
- }, ba = {
268
- class: "space-y-12 p-12"
269
- }, ha = {
270
- class: "text-xs text-fm-color-typo-secondary"
271
- }, ya = {
272
- class: "font-semibold"
273
- }, _a = {
274
- key: 0
275
- }, xa = {
276
- class: "text-xs text-fm-color-typo-secondary"
277
- }, La = {
278
- key: 0,
279
- class: "font-semibold"
280
- }, Sa = {
281
- key: 1,
282
- class: "break-all font-mono text-xs text-fm-color-typo-secondary"
283
- }, ka = {
284
- key: 1
285
- }, wa = {
286
- class: "text-xs text-fm-color-typo-secondary"
287
- }, Ma = {
288
- class: "font-semibold whitespace-pre-line"
289
- }, Fa = {
290
- class: "text-xs text-fm-color-typo-secondary"
291
- }, Da = {
292
- class: "font-semibold"
293
- }, Ta = {
294
- class: "text-xs text-fm-color-typo-secondary"
295
- }, Ia = {
296
- class: "break-all font-mono text-xs font-semibold"
297
- }, Va = {
298
- key: 2
299
- }, Oa = {
300
- class: "text-xs text-fm-color-typo-secondary"
301
- }, Pa = {
302
- class: "mt-4 space-y-4"
303
- }, ja = {
304
- class: "flex h-16 w-16 shrink-0 items-center justify-center rounded-full bg-fm-color-primary-default text-xs font-bold text-white"
305
- }, Ca = {
306
- class: "text-xs font-semibold"
307
- }, Aa = {
308
- key: 0,
309
- class: "text-fm-color-typo-secondary"
310
- }, Ea = {
311
- key: 3
312
- }, Ra = {
313
- class: "text-xs text-fm-color-typo-secondary"
314
- }, Ua = {
315
- class: "mt-4 max-h-[400px] overflow-auto rounded bg-gray-100 p-8 font-mono text-xs leading-relaxed shadow-inner whitespace-pre-wrap break-all"
316
- }, he = 100, ye = 1e3, $a = "YYYY-MM-DD HH:mm", D = "YYYY-MM-DD", Ce = "audit-log-export-fields", el = /* @__PURE__ */ Ae({
317
- __name: "AuditLogList",
318
- setup(s) {
319
- const {
320
- t: a
321
- } = Ee(), x = gt(), O = Lt(), E = h(!1), T = h(!1), M = h([]), o = h(null), I = h(!1);
322
- async function Y(e) {
323
- const t = Uint8Array.from(atob(e), (_) => _.charCodeAt(0)), v = new DecompressionStream("gzip"), L = v.writable.getWriter();
324
- return await L.write(t), await L.close(), new Response(v.readable).text();
325
- }
326
- const p = h("");
327
- let P = 0;
328
- Q(() => {
329
- var e, t;
330
- return (t = (e = o.value) == null ? void 0 : e.metadata) == null ? void 0 : t.requestBody;
331
- }, async (e) => {
332
- const t = ++P;
333
- if (!e) {
334
- p.value = "";
335
- return;
336
- }
337
- if (typeof e == "object") {
338
- p.value = JSON.stringify(e, null, 2);
339
- return;
340
- }
341
- if (e.startsWith("gzip:")) {
342
- try {
343
- const v = await Y(e.slice(5));
344
- if (t !== P) return;
345
- p.value = JSON.stringify(JSON.parse(v), null, 2);
346
- } catch {
347
- if (t !== P) return;
348
- p.value = e;
349
- }
350
- return;
351
- }
352
- try {
353
- p.value = JSON.stringify(JSON.parse(e), null, 2);
354
- } catch {
355
- p.value = e;
356
- }
357
- }, {
358
- immediate: !0
359
- });
360
- const F = h(1), J = h(!1), te = y().format("YYYY-MM-DD"), $ = h({
361
- startDate: `${te} 00:00`,
362
- endDate: `${te} 23:59`
363
- }), R = h(), m = h(), f = h(), S = h(), k = h("all");
364
- function z(e) {
365
- return typeof e == "string" ? [e] : Array.isArray(e) ? e.filter((t) => typeof t == "string") : [];
366
- }
367
- const U = w(() => be.map(({
368
- key: e
369
- }) => ({
370
- label: a(`auditLog.modules.${e}`),
371
- value: e
372
- }))), r = w(() => be.find((e) => e.key === k.value) ?? be[0]), B = w(() => k.value === "all"), H = w(() => O.members.map((e) => ({
373
- label: e.name,
374
- value: e.doc.userId
375
- }))), ne = w(() => {
376
- const e = Pe.flatMap((_) => z(_.subject).map((A) => ({
377
- label: _.label,
378
- value: A
379
- }))), t = Object.entries(Ve).map(([_, A]) => ({
380
- label: A,
381
- value: _
382
- })), v = /* @__PURE__ */ new Set(), L = [];
383
- for (const _ of [...e, ...t])
384
- v.has(_.value) || (v.add(_.value), L.push(_));
385
- return L;
386
- });
387
- function _e(e, t) {
388
- const v = t.toLowerCase();
389
- return e.label.toLowerCase().includes(v) || e.value.replace(/^business::/, "").toLowerCase().includes(v) ? !0 : e.value.toLowerCase().includes(v);
390
- }
391
- const g = w(() => ({
392
- manage: a("auditLog.action.manage"),
393
- create: a("auditLog.action.create"),
394
- read: a("auditLog.action.read"),
395
- update: a("auditLog.action.update"),
396
- delete: a("auditLog.action.delete")
397
- })), ae = w(() => [{
398
- label: g.value.manage,
399
- value: "manage"
400
- }, {
401
- label: g.value.create,
402
- value: "create"
403
- }, {
404
- label: g.value.read,
405
- value: "read"
406
- }, {
407
- label: g.value.update,
408
- value: "update"
409
- }, {
410
- label: g.value.delete,
411
- value: "delete"
412
- }]), ie = w(() => ({
413
- allowed: a("auditLog.outcome.success"),
414
- denied: a("auditLog.outcome.failed"),
415
- skipped: a("auditLog.outcome.skipped")
416
- })), Re = w(() => [{
417
- label: ie.value.allowed,
418
- value: "allowed"
419
- }, {
420
- label: ie.value.denied,
421
- value: "denied"
422
- }, {
423
- label: ie.value.skipped,
424
- value: "skipped"
425
- }]), Ue = w(() => ({
426
- admin: a("auditLog.detail.resolvedFromValue.admin"),
427
- staff: a("auditLog.detail.resolvedFromValue.staff"),
428
- permissionSet: a("auditLog.detail.resolvedFromValue.permissionSet"),
429
- systemPermissionSet: a("auditLog.detail.resolvedFromValue.systemPermissionSet"),
430
- custom: a("auditLog.detail.resolvedFromValue.custom"),
431
- "no-match": a("auditLog.detail.resolvedFromValue.noMatch"),
432
- unknown: a("auditLog.detail.resolvedFromValue.unknown")
433
- })), $e = w(() => ({
434
- GET: g.value.read,
435
- POST: g.value.create,
436
- PUT: g.value.update,
437
- PATCH: g.value.update,
438
- DELETE: g.value.delete
439
- })), xe = {
440
- allowed: "success",
441
- denied: "critical",
442
- skipped: "warning"
443
- }, Ne = w(() => {
444
- const {
445
- startDate: e,
446
- endDate: t
447
- } = $.value;
448
- return e && t ? `${e} – ${t}` : e || t || a("auditLog.dateRange.placeholder");
449
- }), Ye = w(() => [{
450
- label: a("date.predefinedRanges.today"),
451
- value: {
452
- startDate: y().format(D),
453
- endDate: y().format(D)
454
- }
455
- }, {
456
- label: a("date.predefinedRanges.yesterday"),
457
- value: {
458
- startDate: y().subtract(1, "day").format(D),
459
- endDate: y().subtract(1, "day").format(D)
460
- }
461
- }, {
462
- label: a("date.predefinedRanges.thisWeek"),
463
- value: {
464
- startDate: y().startOf("week").format(D),
465
- endDate: y().endOf("week").format(D)
466
- }
467
- }, {
468
- label: a("date.predefinedRanges.lastWeek"),
469
- value: {
470
- startDate: y().subtract(1, "week").startOf("week").format(D),
471
- endDate: y().subtract(1, "week").endOf("week").format(D)
472
- }
473
- }, {
474
- label: a("date.predefinedRanges.last7Days"),
475
- value: {
476
- startDate: y().subtract(7, "day").format(D),
477
- endDate: y().subtract(1, "day").format(D)
478
- }
479
- }, {
480
- label: a("date.predefinedRanges.thisMonth"),
481
- value: {
482
- startDate: y().startOf("month").format(D),
483
- endDate: y().endOf("month").format(D)
484
- }
485
- }, {
486
- label: a("date.predefinedRanges.lastMonth"),
487
- value: {
488
- startDate: y().subtract(1, "month").startOf("month").format(D),
489
- endDate: y().subtract(1, "month").endOf("month").format(D)
490
- }
491
- }]);
492
- function me(e) {
493
- var t;
494
- return ((t = Pe.find((v) => v.subject === e)) == null ? void 0 : t.label) ?? Ve[e];
495
- }
496
- function re(e) {
497
- return O.userIdToName[e.userId] || e.userId;
498
- }
499
- function Le(e) {
500
- return O.userIdToPhone[e.userId] || "-";
501
- }
502
- function ze(e) {
503
- return O.userIdToEmail[e.userId] || "-";
504
- }
505
- function Se(e) {
506
- return y(e).format("DD MMM YYYY, HH:mm");
507
- }
508
- function Be(e) {
509
- return y(e).format("DD MMM YYYY, HH:mm:ss").toUpperCase();
510
- }
511
- function ke(e) {
512
- return g.value[e] ?? e;
513
- }
514
- function fe(e) {
515
- return e.metadata.operationLabel ?? ke(e.action);
516
- }
517
- function ve(e) {
518
- return ie.value[e];
519
- }
520
- function Ke(e) {
521
- return Ue.value[e] ?? e;
522
- }
523
- function qe(e) {
524
- return e.metadata.requestMethod ? $e.value[e.metadata.requestMethod] ?? e.metadata.requestMethod : ke(e.action);
525
- }
526
- function we(e) {
527
- const t = String(e ?? "");
528
- return `"${(/^[=+\-@\t\r]/.test(t) ? `'${t}` : t).replace(/"/g, '""')}"`;
529
- }
530
- const pe = [{
531
- key: "timestamp",
532
- labelKey: "auditLog.exportFields.timestamp",
533
- getValue: (e) => Se(e.timestamp),
534
- defaultSelected: !0
535
- }, {
536
- key: "userName",
537
- labelKey: "auditLog.exportFields.userName",
538
- getValue: (e) => re(e),
539
- defaultSelected: !0
540
- }, {
541
- key: "userPhone",
542
- labelKey: "auditLog.exportFields.userPhone",
543
- getValue: (e) => Le(e),
544
- defaultSelected: !0
545
- }, {
546
- key: "subject",
547
- labelKey: "auditLog.exportFields.subject",
548
- getValue: (e) => me(e.subject) ?? e.subject,
549
- defaultSelected: !0
550
- }, {
551
- key: "action",
552
- labelKey: "auditLog.exportFields.action",
553
- getValue: (e) => e.action,
554
- defaultSelected: !0
555
- }, {
556
- key: "operation",
557
- labelKey: "auditLog.exportFields.operation",
558
- getValue: (e) => fe(e),
559
- defaultSelected: !0
560
- }, {
561
- key: "outcome",
562
- labelKey: "auditLog.exportFields.outcome",
563
- getValue: (e) => ve(e.outcome),
564
- defaultSelected: !0
565
- }, {
566
- key: "businessId",
567
- labelKey: "auditLog.exportFields.businessId",
568
- getValue: (e) => e.businessId,
569
- defaultSelected: !1
570
- }, {
571
- key: "restaurantId",
572
- labelKey: "auditLog.exportFields.restaurantId",
573
- getValue: (e) => e.restaurantId,
574
- defaultSelected: !1
575
- }, {
576
- key: "country",
577
- labelKey: "auditLog.exportFields.country",
578
- getValue: (e) => e.country,
579
- defaultSelected: !1
580
- }, {
581
- key: "resolvedFrom",
582
- labelKey: "auditLog.exportFields.resolvedFrom",
583
- getValue: (e) => {
584
- var t;
585
- return (t = e.metadata) == null ? void 0 : t.resolvedFrom;
586
- },
587
- defaultSelected: !1
588
- }, {
589
- key: "requestMethod",
590
- labelKey: "auditLog.exportFields.requestMethod",
591
- getValue: (e) => {
592
- var t;
593
- return (t = e.metadata) == null ? void 0 : t.requestMethod;
594
- },
595
- defaultSelected: !1
596
- }, {
597
- key: "requestPath",
598
- labelKey: "auditLog.exportFields.requestPath",
599
- getValue: (e) => {
600
- var t;
601
- return (t = e.metadata) == null ? void 0 : t.requestPath;
602
- },
603
- defaultSelected: !1
604
- }];
605
- function He() {
606
- try {
607
- const e = localStorage.getItem(Ce);
608
- if (e) {
609
- const t = JSON.parse(e);
610
- if (Array.isArray(t) && t.length > 0) return new Set(t);
611
- }
612
- } catch {
613
- }
614
- return new Set(pe.filter((e) => e.defaultSelected).map((e) => e.key));
615
- }
616
- const G = h(He());
617
- function We(e) {
618
- const t = new Set(G.value);
619
- if (t.has(e)) {
620
- if (t.size <= 1) return;
621
- t.delete(e);
622
- } else
623
- t.add(e);
624
- G.value = t;
625
- try {
626
- localStorage.setItem(Ce, JSON.stringify([...t]));
627
- } catch {
628
- }
629
- }
630
- async function Je() {
631
- var e, t, v, L, _, A;
632
- if (!T.value) {
633
- T.value = !0;
634
- try {
635
- const {
636
- startDate: K,
637
- endDate: q
638
- } = $.value, W = r.value.subjectPrefixes, de = (/* @__PURE__ */ new Date()).toISOString().slice(0, 19).replace("T", " "), d = q ? ue(q) : null, Z = d && d < de ? d : de, tt = {
639
- ...K ? {
640
- from: ue(K)
641
- } : {},
642
- to: Z,
643
- ...(e = R.value) != null && e.length ? {
644
- userIds: R.value
645
- } : {},
646
- ...B.value && ((t = m.value) != null && t.length) ? {
647
- subjects: m.value
648
- } : {},
649
- ...W.length ? {
650
- subjectPrefixes: [...W]
651
- } : {},
652
- ...(v = S.value) != null && v.length ? {
653
- actions: S.value
654
- } : {},
655
- ...(L = f.value) != null && L.length ? {
656
- outcomes: f.value
657
- } : {}
658
- }, Me = [];
659
- let Fe = 0;
660
- for (; ; ) {
661
- const j = await je.read({
662
- ...tt,
663
- limit: ye,
664
- offset: Fe
665
- });
666
- if (Me.push(...j), j.length < ye) break;
667
- Fe += ye;
668
- }
669
- const De = pe.filter((j) => G.value.has(j.key)), at = De.map((j) => a(j.labelKey)), lt = Me.map((j) => De.map((mt) => mt.getValue(j) ?? "")), ge = -(/* @__PURE__ */ new Date()).getTimezoneOffset(), ot = ge >= 0 ? "+" : "-", st = String(Math.floor(Math.abs(ge) / 60)).padStart(2, "0"), nt = String(Math.abs(ge) % 60).padStart(2, "0"), it = `UTC${ot}${st}:${nt}`, Te = ((_ = x.currentBusiness.value) == null ? void 0 : _.name) || "", rt = [K, q].filter(Boolean).join(" – "), ut = [...[[a("auditLog.title")], [`${a("auditLog.frontMatter.date")}: ${rt}`], ...Te ? [[`${a("auditLog.frontMatter.business")}: ${Te}`]] : [], [`${a("auditLog.frontMatter.generatedBy")}: ${y().format("DD MMM YYYY, HH:mm")} (${it})`], []].map((j) => j.map(we).join(",")), ...[at, ...lt].map((j) => j.map(we).join(","))].join(`
670
- `), dt = `audit-log_${(((A = x.currentBusiness.value) == null ? void 0 : A.name) || "business").replace(/[^a-z0-9_-]+/gi, "_")}_${y().format("YYYYMMDD_HHmmss")}.csv`, ct = new Blob([`\uFEFF${ut}`], {
671
- type: "text/csv;charset=utf-8;"
672
- }), Ie = window.URL.createObjectURL(ct), le = document.createElement("a");
673
- le.href = Ie, le.download = dt, document.body.appendChild(le), le.click(), le.remove(), window.URL.revokeObjectURL(Ie);
674
- } finally {
675
- T.value = !1;
676
- }
677
- }
678
- }
679
- const Ge = [{
680
- accessorKey: "timestamp",
681
- header: () => a("auditLog.columns.timestamp"),
682
- cell(e) {
683
- return Se(e.row.original.timestamp);
684
- }
685
- }, {
686
- accessorKey: "userId",
687
- header: () => a("auditLog.columns.user"),
688
- enableSorting: !1,
689
- size: 220,
690
- cell(e) {
691
- const t = e.row.original;
692
- return u("div", {
693
- class: "flex items-center gap-8"
694
- }, [u(Oe.FmAvatar, {
695
- initials: re(t),
696
- size: "sm",
697
- class: "shrink-0"
698
- }, null), u("div", {
699
- class: "min-w-0"
700
- }, [u("p", {
701
- class: "truncate font-semibold"
702
- }, [re(t)]), u("p", {
703
- class: "truncate text-fm-color-typo-secondary"
704
- }, [Le(t)])])]);
705
- }
706
- }, {
707
- accessorKey: "subject",
708
- header: () => a("auditLog.columns.role"),
709
- meta: {
710
- cellClass: "text-left"
711
- },
712
- cell(e) {
713
- const t = e.row.original;
714
- return u("div", {
715
- class: "text-left"
716
- }, [me(t.subject) ?? t.subject]);
717
- }
718
- }, {
719
- accessorKey: "action",
720
- header: () => a("auditLog.columns.action"),
721
- enableSorting: !1,
722
- size: 280,
723
- meta: {
724
- cellSpanClass: "audit-log-action-label"
725
- },
726
- cell(e) {
727
- return fe(e.row.original);
728
- }
729
- }, {
730
- accessorKey: "outcome",
731
- header: () => a("auditLog.columns.outcome"),
732
- enableSorting: !1,
733
- cell(e) {
734
- const t = e.row.original;
735
- return u(Oe.FmChip, {
736
- variant: xe[t.outcome] ?? "neutral",
737
- label: ve(t.outcome),
738
- compact: !0
739
- }, null);
740
- }
741
- }];
742
- function ue(e) {
743
- const t = y(e, $a);
744
- return new Date(t.year(), t.month(), t.date(), t.hour(), t.minute(), 0).toISOString().slice(0, 19).replace("T", " ");
745
- }
746
- async function X() {
747
- var e, t, v, L;
748
- E.value = !0;
749
- try {
750
- const {
751
- startDate: _,
752
- endDate: A
753
- } = $.value, K = (F.value - 1) * he, q = r.value.subjectPrefixes, W = await je.read({
754
- limit: he,
755
- offset: K,
756
- ..._ ? {
757
- from: ue(_)
758
- } : {},
759
- ...A ? {
760
- to: ue(A)
761
- } : {},
762
- ...(e = R.value) != null && e.length ? {
763
- userIds: R.value
764
- } : {},
765
- ...B.value && ((t = m.value) != null && t.length) ? {
766
- subjects: m.value
767
- } : {},
768
- ...q.length ? {
769
- subjectPrefixes: [...q]
770
- } : {},
771
- ...(v = S.value) != null && v.length ? {
772
- actions: S.value
773
- } : {},
774
- ...(L = f.value) != null && L.length ? {
775
- outcomes: f.value
776
- } : {}
777
- });
778
- M.value = W, J.value = W.length === he;
779
- } finally {
780
- E.value = !1;
781
- }
782
- }
783
- Q($, () => {
784
- F.value = 1, X();
785
- }), Q([R, m, f, S], () => {
786
- F.value = 1, X();
787
- }), Q(k, () => {
788
- F.value = 1, X();
789
- });
790
- async function Xe() {
791
- F.value > 1 && (F.value--, await X());
792
- }
793
- async function Ze() {
794
- J.value && (F.value++, await X());
795
- }
796
- function Qe(e) {
797
- o.value = e, I.value = !0;
798
- }
799
- function et() {
800
- I.value = !1, o.value = null;
801
- }
802
- return Q(x.currentBusiness, (e) => {
803
- e && (F.value = 1, O.readTeamMembers(), X());
804
- }, {
805
- immediate: !0
806
- }), (e, t) => {
807
- const v = C("FmSpacer"), L = C("FmButton"), _ = C("FmMenuItem"), A = C("FmMenu"), K = C("FmChip"), q = C("FmDateRangePicker"), W = C("FmTable"), de = C("FmSideSheet");
808
- return c(), b(ee, null, [u(_t, {
809
- heading: n(a)("auditLog.title")
810
- }, {
811
- "append-heading": N(() => [u(v), u(L, {
812
- variant: "primary",
813
- "prepend-icon": "upload",
814
- label: n(a)("auditLog.export"),
815
- disabled: M.value.length === 0 || T.value || n(O).isLoading || n(O).members.length === 0,
816
- loading: T.value,
817
- onClick: Je
818
- }, null, 8, ["label", "disabled", "loading"]), u(A, {
819
- "close-on-click": !1,
820
- "z-index": 50
821
- }, {
822
- "menu-button": N(() => [u(L, {
823
- variant: "tertiary",
824
- icon: "settings",
825
- "aria-label": n(a)("auditLog.exportSettings.title"),
826
- disabled: T.value
827
- }, null, 8, ["aria-label", "disabled"])]),
828
- default: N(() => [l("div", Tt, [l("p", It, i(n(a)("auditLog.exportSettings.title")), 1), (c(), b(ee, null, se(pe, (d) => u(_, {
829
- key: d.key,
830
- label: n(a)(d.labelKey),
831
- "has-checkbox": "",
832
- "model-value": G.value.has(d.key),
833
- disabled: G.value.has(d.key) && G.value.size === 1,
834
- onClick: (Z) => We(d.key)
835
- }, null, 8, ["label", "model-value", "disabled", "onClick"])), 64))])]),
836
- _: 1
837
- })]),
838
- default: N(() => [l("div", Vt, [l("div", Ot, [u(Dt, {
839
- modelValue: k.value,
840
- "onUpdate:modelValue": t[0] || (t[0] = (d) => k.value = d),
841
- items: U.value
842
- }, null, 8, ["modelValue", "items"]), l("div", Pt, [u(q, {
843
- modelValue: $.value,
844
- "onUpdate:modelValue": t[1] || (t[1] = (d) => $.value = d),
845
- "show-predefined-range": "",
846
- "show-time": "",
847
- "predefined-range": Ye.value
848
- }, {
849
- "trigger-button": N(() => [u(K, {
850
- label: Ne.value,
851
- icon: "calendar_month"
852
- }, null, 8, ["label"])]),
853
- _: 1
854
- }, 8, ["modelValue", "predefined-range"]), l("div", jt, [u(ce, {
855
- modelValue: R.value,
856
- "onUpdate:modelValue": t[2] || (t[2] = (d) => R.value = d),
857
- items: H.value,
858
- multiple: "",
859
- variant: "dark",
860
- placeholder: n(a)("auditLog.filter.user_placeholder"),
861
- "selected-prefix": n(a)("auditLog.filter.selected_user_prefix"),
862
- "chip-icon": "account_circle"
863
- }, null, 8, ["modelValue", "items", "placeholder", "selected-prefix"])]), B.value ? (c(), b("div", Ct, [u(ce, {
864
- modelValue: m.value,
865
- "onUpdate:modelValue": t[3] || (t[3] = (d) => m.value = d),
866
- items: ne.value,
867
- "filter-fn": _e,
868
- multiple: "",
869
- variant: "dark",
870
- placeholder: n(a)("auditLog.filter.subject_placeholder"),
871
- "selected-prefix": n(a)("auditLog.filter.selected_subject_prefix"),
872
- "chip-icon": "badge"
873
- }, null, 8, ["modelValue", "items", "placeholder", "selected-prefix"])])) : V("", !0), l("div", At, [u(ce, {
874
- modelValue: S.value,
875
- "onUpdate:modelValue": t[4] || (t[4] = (d) => S.value = d),
876
- items: ae.value,
877
- multiple: "",
878
- variant: "dark",
879
- placeholder: n(a)("auditLog.filter.action_placeholder"),
880
- "selected-prefix": n(a)("auditLog.filter.selected_action_prefix"),
881
- searchable: !1
882
- }, null, 8, ["modelValue", "items", "placeholder", "selected-prefix"])]), l("div", Et, [u(ce, {
883
- modelValue: f.value,
884
- "onUpdate:modelValue": t[5] || (t[5] = (d) => f.value = d),
885
- items: Re.value,
886
- multiple: "",
887
- variant: "dark",
888
- placeholder: n(a)("auditLog.filter.status_placeholder"),
889
- "selected-prefix": n(a)("auditLog.filter.selected_status_prefix"),
890
- searchable: !1,
891
- "chip-icon": "check_circle"
892
- }, null, 8, ["modelValue", "items", "placeholder", "selected-prefix"])])])]), !E.value && M.value.length === 0 ? (c(), oe(n(xt), {
893
- key: 0,
894
- title: n(a)("auditLog.noData.title"),
895
- subtitle: n(a)("auditLog.noData.subtitle")
896
- }, null, 8, ["title", "subtitle"])) : (c(), oe(bt, {
897
- key: 1
898
- }, {
899
- default: N(() => [l("div", Rt, [u(W, {
900
- "column-defs": Ge,
901
- "row-data": M.value,
902
- "page-size": M.value.length,
903
- loading: E.value,
904
- "pin-header-row": "",
905
- "hide-footer": "",
906
- class: "min-h-0 flex-1 cursor-pointer",
907
- onRowClick: t[6] || (t[6] = (d) => Qe(d.original))
908
- }, null, 8, ["row-data", "page-size", "loading"]), F.value > 1 || J.value ? (c(), b("div", Ut, [u(L, {
909
- variant: "tertiary",
910
- icon: "chevron_left",
911
- disabled: F.value === 1,
912
- "aria-label": n(a)("auditLog.pagination.prevPage"),
913
- onClick: Xe
914
- }, null, 8, ["disabled", "aria-label"]), l("span", $t, i(n(a)("auditLog.pagination.page", {
915
- page: F.value
916
- })), 1), u(L, {
917
- variant: "tertiary",
918
- icon: "chevron_right",
919
- disabled: !J.value,
920
- "aria-label": n(a)("auditLog.pagination.nextPage"),
921
- onClick: Ze
922
- }, null, 8, ["disabled", "aria-label"])])) : V("", !0)])]),
923
- _: 1
924
- }))])]),
925
- _: 1
926
- }, 8, ["heading"]), u(de, {
927
- header: n(a)("auditLog.detail.header"),
928
- "model-value": I.value,
929
- "max-width": 480,
930
- "dismiss-away": "",
931
- "onUpdate:modelValue": t[7] || (t[7] = (d) => {
932
- d || et();
933
- })
934
- }, {
935
- default: N(() => [o.value ? (c(), b("div", Nt, [l("div", Yt, [l("div", zt, [l("p", Bt, i(fe(o.value)), 1)]), u(K, {
936
- variant: xe[o.value.outcome] ?? "neutral",
937
- label: ve(o.value.outcome),
938
- compact: ""
939
- }, null, 8, ["variant", "label"])]), l("div", Kt, [l("div", qt, [l("div", null, [l("p", Ht, i(n(a)("auditLog.detail.date")), 1), l("p", Wt, i(Be(o.value.timestamp)), 1)]), l("div", null, [l("p", Jt, i(n(a)("auditLog.detail.user")), 1), l("p", Gt, i(re(o.value)), 1)]), l("div", null, [l("p", Xt, i(n(a)("auditLog.detail.email")), 1), l("p", Zt, i(ze(o.value)), 1)]), l("div", null, [l("p", Qt, i(n(a)("auditLog.detail.role")), 1), l("p", ea, i(me(o.value.subject) || o.value.subject), 1)]), o.value.field ? (c(), b("div", ta, [l("p", aa, i(n(a)("auditLog.detail.field")), 1), l("p", la, i(o.value.field), 1)])) : V("", !0), l("div", null, [l("p", oa, i(n(a)("auditLog.detail.business")), 1), l("p", sa, i(o.value.businessId || "-"), 1)]), l("div", null, [l("p", na, i(n(a)("auditLog.detail.restaurant")), 1), l("p", ia, i(o.value.restaurantId || "-"), 1)])])]), o.value.metadata.operationLabel ? (c(), b("div", ra, [l("div", ua, [l("p", da, i(n(a)("auditLog.detail.changeDetails")), 1)]), t[8] || (t[8] = l("hr", {
940
- class: "border-fm-color-border-default"
941
- }, null, -1)), l("div", ca, [l("div", null, [l("p", ma, i(n(a)("auditLog.detail.eventType")), 1), l("p", fa, i(o.value.metadata.operationLabel), 1)])])])) : V("", !0), l("div", va, [l("div", pa, [l("p", ga, i(n(a)("auditLog.detail.metadata")), 1)]), t[9] || (t[9] = l("hr", {
942
- class: "border-fm-color-border-default"
943
- }, null, -1)), l("div", ba, [l("div", null, [l("p", ha, i(n(a)("auditLog.detail.resolvedFrom")), 1), l("p", ya, i(Ke(o.value.metadata.resolvedFrom)), 1)]), (o.value.metadata.resolvedFrom === "permissionSet" || o.value.metadata.resolvedFrom === "systemPermissionSet") && (o.value.metadata.permissionSetName || o.value.metadata.permissionSetId) ? (c(), b("div", _a, [l("p", xa, i(n(a)("auditLog.detail.permissionSet")), 1), o.value.metadata.permissionSetName ? (c(), b("p", La, i(o.value.metadata.permissionSetName), 1)) : V("", !0), o.value.metadata.permissionSetId ? (c(), b("p", Sa, i(o.value.metadata.permissionSetId), 1)) : V("", !0)])) : V("", !0), o.value.metadata.reason ? (c(), b("div", ka, [l("p", wa, i(n(a)("auditLog.detail.reason")), 1), l("p", Ma, i(o.value.metadata.reason), 1)])) : V("", !0), l("div", null, [l("p", Fa, i(n(a)("auditLog.detail.requestMethod")), 1), l("p", Da, i(qe(o.value)), 1)]), l("div", null, [l("p", Ta, i(n(a)("auditLog.detail.requestPath")), 1), l("p", Ia, i(o.value.metadata.requestPath || "-"), 1)]), o.value.metadata.trace && o.value.metadata.trace.length > 0 ? (c(), b("div", Va, [l("p", Oa, i(n(a)("auditLog.detail.permissionTrace")), 1), l("ol", Pa, [(c(!0), b(ee, null, se(o.value.metadata.trace, (d, Z) => (c(), b("li", {
944
- key: Z,
945
- class: "flex items-center gap-6"
946
- }, [l("span", ja, i(Z + 1), 1), l("span", Ca, i(d), 1), Z < o.value.metadata.trace.length - 1 ? (c(), b("span", Aa, "→")) : V("", !0)]))), 128))])])) : V("", !0), p.value ? (c(), b("div", Ea, [l("p", Ra, i(n(a)("auditLog.detail.requestBody")), 1), l("pre", Ua, i(p.value), 1)])) : V("", !0)])])])) : V("", !0)]),
947
- _: 1
948
- }, 8, ["header", "model-value"])], 64);
949
- };
950
- }
951
- });
952
- export {
953
- el as default
954
- };