@feedmepos/mf-hrm-portal 2.0.8-dev.20 → 2.0.8-dev.21

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