rl-core-front 0.2.0 → 0.4.0
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.
- package/package.json +1 -1
- package/src/_services/api/schema.d.ts +238 -117
- package/src/_utils/filter.ts +15 -34
- package/src/components/app-shell.tsx +51 -1
- package/src/components/brand-header.tsx +23 -8
- package/src/components/brand-panel.tsx +41 -0
- package/src/components/index.ts +1 -0
- package/src/components/ui/button.tsx +5 -0
- package/src/components/ui/confirm-dialog.tsx +3 -1
- package/src/components/ui/data-table.tsx +13 -4
- package/src/components/ui/dialog.tsx +120 -21
- package/src/components/ui/filter-sheet.tsx +47 -25
- package/src/components/ui/index.ts +1 -1
- package/src/components/ui/segmented-control.tsx +74 -0
- package/src/contexts/brand-context.tsx +15 -0
- package/src/contexts/i18n-context.tsx +69 -4
- package/src/features/audit/audit-screen.tsx +13 -140
- package/src/features/audit/components/audit-diff.tsx +156 -0
- package/src/features/audit/components/index.ts +3 -0
- package/src/features/audit/components/record-audit-button.tsx +176 -0
- package/src/features/audit/enums/audit-data-action.enum.ts +20 -0
- package/src/features/audit/hooks/use-audit-trail.ts +9 -2
- package/src/features/audit/services/audit.service.ts +43 -1
- package/src/features/login/login-screen.tsx +86 -40
- package/src/features/logs/enums/error-type.enum.ts +21 -0
- package/src/features/logs/enums/request-outcome.enum.ts +14 -0
- package/src/features/logs/hooks/use-request-logs.ts +26 -3
- package/src/features/logs/logs-screen.tsx +2 -14
- package/src/features/logs/panels/index.ts +0 -1
- package/src/features/logs/panels/request-logs-panel.tsx +177 -25
- package/src/features/logs/services/logs.service.ts +13 -51
- package/src/features/notifications/components/notification-item.tsx +10 -8
- package/src/features/notifications/enums/notification-type.enum.ts +8 -0
- package/src/features/profile/profile-screen.tsx +2 -1
- package/src/features/rbac/panels/groups-panel.tsx +20 -7
- package/src/features/users/components/user-form-dialog.tsx +16 -7
- package/src/features/users/hooks/use-users.ts +9 -2
- package/src/hooks/use-filters.ts +25 -2
- package/src/hooks/use-list-query.ts +14 -1
- package/src/i18n/messages/en.ts +17 -5
- package/src/i18n/messages/pt.ts +18 -5
- package/src/index.ts +12 -1
- package/src/components/ui/filter-chips.tsx +0 -88
- package/src/features/logs/hooks/use-error-logs.ts +0 -65
- package/src/features/logs/panels/error-logs-panel.tsx +0 -183
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import type {
|
|
4
|
-
ColumnDef,
|
|
5
|
-
OnChangeFn,
|
|
6
|
-
PaginationState,
|
|
7
|
-
SortingState,
|
|
8
|
-
} from "@tanstack/react-table";
|
|
9
|
-
import { Eye } from "lucide-react";
|
|
10
|
-
import type { JSX } from "react";
|
|
11
|
-
import { useMemo, useState } from "react";
|
|
12
|
-
|
|
13
|
-
import {
|
|
14
|
-
Badge,
|
|
15
|
-
Button,
|
|
16
|
-
DataTable,
|
|
17
|
-
DataTableFeatures,
|
|
18
|
-
Dialog,
|
|
19
|
-
DialogContent,
|
|
20
|
-
DialogHeader,
|
|
21
|
-
DialogTitle,
|
|
22
|
-
RowActions,
|
|
23
|
-
} from "#core/components/ui";
|
|
24
|
-
import { useI18n } from "#core/contexts";
|
|
25
|
-
import { useErrorLogs } from "#core/features/logs/hooks/use-error-logs";
|
|
26
|
-
import { ErrorLog, ErrorType } from "#core/features/logs/services/logs.service";
|
|
27
|
-
|
|
28
|
-
function typeVariant(type: ErrorType): "warning" | "destructive" | "secondary" {
|
|
29
|
-
if (type === "DATABASE" || type === "INTEGRATION" || type === "INTERNAL")
|
|
30
|
-
{return "destructive";}
|
|
31
|
-
if (type === "VALIDATION") {return "secondary";}
|
|
32
|
-
return "warning";
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export function ErrorLogsPanel(): JSX.Element {
|
|
36
|
-
const { t } = useI18n();
|
|
37
|
-
const logs = useErrorLogs();
|
|
38
|
-
const [detail, setDetail] = useState<ErrorLog | null>(null);
|
|
39
|
-
|
|
40
|
-
const columns = useMemo<ColumnDef<DataTableFeatures, ErrorLog, unknown>[]>(
|
|
41
|
-
() => [
|
|
42
|
-
{
|
|
43
|
-
accessorKey: "createdAt",
|
|
44
|
-
header: t("logs.date"),
|
|
45
|
-
meta: { label: t("logs.date") },
|
|
46
|
-
cell: ({ getValue }) => new Date(String(getValue())).toLocaleString(),
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
accessorKey: "type",
|
|
50
|
-
header: t("logs.type"),
|
|
51
|
-
meta: { label: t("logs.type") },
|
|
52
|
-
cell: ({ getValue }) => {
|
|
53
|
-
const type = getValue() as ErrorType;
|
|
54
|
-
return <Badge variant={typeVariant(type)}>{type}</Badge>;
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
accessorKey: "statusCode",
|
|
59
|
-
header: t("logs.status"),
|
|
60
|
-
meta: { label: t("logs.status") },
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
accessorKey: "message",
|
|
64
|
-
header: t("logs.message"),
|
|
65
|
-
meta: { label: t("logs.message") },
|
|
66
|
-
enableSorting: false,
|
|
67
|
-
cell: ({ getValue }) => (
|
|
68
|
-
<span className="line-clamp-1 max-w-md">{String(getValue())}</span>
|
|
69
|
-
),
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
id: "user",
|
|
73
|
-
header: t("logs.user"),
|
|
74
|
-
meta: { label: t("logs.user") },
|
|
75
|
-
enableSorting: false,
|
|
76
|
-
cell: ({ row }) => row.original.user?.name ?? t("logs.systemUser"),
|
|
77
|
-
},
|
|
78
|
-
{
|
|
79
|
-
id: "actions",
|
|
80
|
-
header: () => <div className="text-center">{t("common.actions")}</div>,
|
|
81
|
-
meta: { shrink: true },
|
|
82
|
-
enableHiding: false,
|
|
83
|
-
enableSorting: false,
|
|
84
|
-
cell: ({ row }) => (
|
|
85
|
-
<RowActions>
|
|
86
|
-
<Button
|
|
87
|
-
variant="ghost"
|
|
88
|
-
size="sm"
|
|
89
|
-
onClick={() => setDetail(row.original)}
|
|
90
|
-
>
|
|
91
|
-
<Eye className="h-4 w-4" />
|
|
92
|
-
{t("logs.viewDetails")}
|
|
93
|
-
</Button>
|
|
94
|
-
</RowActions>
|
|
95
|
-
),
|
|
96
|
-
},
|
|
97
|
-
],
|
|
98
|
-
|
|
99
|
-
[t],
|
|
100
|
-
);
|
|
101
|
-
|
|
102
|
-
const pagination: PaginationState = {
|
|
103
|
-
pageIndex: logs.page,
|
|
104
|
-
pageSize: logs.pageSize,
|
|
105
|
-
};
|
|
106
|
-
const onPaginationChange: OnChangeFn<PaginationState> = (updater) => {
|
|
107
|
-
const next = typeof updater === "function" ? updater(pagination) : updater;
|
|
108
|
-
if (next.pageSize !== logs.pageSize) {
|
|
109
|
-
logs.setPageSize(next.pageSize);
|
|
110
|
-
logs.setPage(0);
|
|
111
|
-
} else if (next.pageIndex !== logs.page) {
|
|
112
|
-
logs.setPage(next.pageIndex);
|
|
113
|
-
}
|
|
114
|
-
};
|
|
115
|
-
const onSortingChange: OnChangeFn<SortingState> = (updater) => {
|
|
116
|
-
const next =
|
|
117
|
-
typeof updater === "function" ? updater(logs.sorting) : updater;
|
|
118
|
-
logs.setSorting(next);
|
|
119
|
-
logs.setPage(0);
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
return (
|
|
123
|
-
<div>
|
|
124
|
-
<DataTable
|
|
125
|
-
columns={columns}
|
|
126
|
-
data={logs.rows}
|
|
127
|
-
getRowId={(r) => r.id}
|
|
128
|
-
storageKey="logs-errors"
|
|
129
|
-
loading={logs.loading}
|
|
130
|
-
manualPagination
|
|
131
|
-
rowCount={logs.total}
|
|
132
|
-
pagination={pagination}
|
|
133
|
-
onPaginationChange={onPaginationChange}
|
|
134
|
-
manualSorting
|
|
135
|
-
sorting={logs.sorting}
|
|
136
|
-
onSortingChange={onSortingChange}
|
|
137
|
-
filters={logs.filters}
|
|
138
|
-
/>
|
|
139
|
-
|
|
140
|
-
<Dialog open={!!detail} onOpenChange={(o) => !o && setDetail(null)}>
|
|
141
|
-
<DialogContent className="max-w-2xl">
|
|
142
|
-
<DialogHeader>
|
|
143
|
-
<DialogTitle>
|
|
144
|
-
{t("logs.detailsTitle")} — {detail?.type} ({detail?.statusCode})
|
|
145
|
-
</DialogTitle>
|
|
146
|
-
</DialogHeader>
|
|
147
|
-
{detail && (
|
|
148
|
-
<div className="flex min-w-0 flex-col gap-3 text-sm">
|
|
149
|
-
<div>
|
|
150
|
-
<span className="font-medium">{t("logs.route")}: </span>
|
|
151
|
-
<span className="font-mono text-xs">
|
|
152
|
-
{detail.method} {detail.path}
|
|
153
|
-
</span>
|
|
154
|
-
</div>
|
|
155
|
-
<div>
|
|
156
|
-
<span className="font-medium">{t("logs.message")}: </span>
|
|
157
|
-
{detail.message}
|
|
158
|
-
</div>
|
|
159
|
-
<div>
|
|
160
|
-
<span className="font-medium">{t("logs.user")}: </span>
|
|
161
|
-
{detail.user?.name ?? t("logs.systemUser")}
|
|
162
|
-
</div>
|
|
163
|
-
<div>
|
|
164
|
-
<span className="font-medium">{t("logs.requestId")}: </span>
|
|
165
|
-
<span className="font-mono text-xs">
|
|
166
|
-
{detail.requestId ?? "—"}
|
|
167
|
-
</span>
|
|
168
|
-
</div>
|
|
169
|
-
{detail.stack && (
|
|
170
|
-
<div className="min-w-0">
|
|
171
|
-
<p className="mb-1 font-medium">{t("logs.stackTrace")}</p>
|
|
172
|
-
<pre className="max-h-64 min-w-0 max-w-full overflow-auto rounded-md bg-muted p-3 text-xs">
|
|
173
|
-
{detail.stack}
|
|
174
|
-
</pre>
|
|
175
|
-
</div>
|
|
176
|
-
)}
|
|
177
|
-
</div>
|
|
178
|
-
)}
|
|
179
|
-
</DialogContent>
|
|
180
|
-
</Dialog>
|
|
181
|
-
</div>
|
|
182
|
-
);
|
|
183
|
-
}
|