refactor(housekeeping): split client, add loading states, URL persistence, fix dead code
Local Build and Deploy / deploy (push) Failing after 48s
Local Build and Deploy / deploy (push) Failing after 48s
- Split ManageClient into ManageSection, PresetsSection, TestSection, ImportSection, ExportSection - each tab only renders what it needs - Add loading/disabled states to preset, import, export, clear buttons - Persist search and group filter via URL searchParams (survives refresh) - Remove dead getAuditHistory export from actions - Fix testRankPermission - remove unnecessary revalidatePath with JSON result - Clean up unused errors/count variables in bulkImportPermissions - Add 'loading' translation key to housekeeping section (en/nl)
This commit is contained in:
1 parent
0a350a354e
commit
70f5e37373
7 files changed
+319
-309
No files matched your search
@@ -131,9 +131,6 @@ export async function bulkImportPermissions(formData: FormData): Promise<void> {
|
||||
await requirePermission(PERMS.SETTINGS_EDIT);
|
||||
|
||||
const raw = sanitize(String(formData.get("json") ?? ""));
|
||||
const errors: string[] = [];
|
||||
let count = 0;
|
||||
|
||||
if (!raw) return;
|
||||
|
||||
let parsed: unknown;
|
||||
@@ -157,7 +154,6 @@ export async function bulkImportPermissions(formData: FormData): Promise<void> {
|
||||
const dependsOn = sanitize(String(item.dependsOn ?? "")) || null;
|
||||
|
||||
if (!permission || !Number.isFinite(minRank) || minRank < 0) {
|
||||
errors.push("Invalid entry: " + JSON.stringify(item));
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -180,9 +176,8 @@ export async function bulkImportPermissions(formData: FormData): Promise<void> {
|
||||
updatedBy: userId ?? undefined,
|
||||
},
|
||||
});
|
||||
count++;
|
||||
} catch {
|
||||
errors.push("Failed to upsert: " + permission);
|
||||
// Failed to upsert
|
||||
}
|
||||
}
|
||||
|
||||
@@ -881,17 +876,7 @@ export async function testRankPermission(formData: FormData): Promise<void> {
|
||||
});
|
||||
|
||||
const granted = perms.map((p) => p.permission);
|
||||
// Result is displayed via the revalidated page
|
||||
revalidatePath(
|
||||
"/admin/housekeeping?tab=test&result=" +
|
||||
encodeURIComponent(JSON.stringify({ rank, permissions: granted })),
|
||||
);
|
||||
revalidatePath("/admin/housekeeping");
|
||||
}
|
||||
|
||||
export async function getAuditHistory(): Promise<unknown[]> {
|
||||
await requirePermission(PERMS.SETTINGS_VIEW);
|
||||
|
||||
const { getAuditLogs } = await import("@/lib/services/audit");
|
||||
const result = await getAuditLogs({ search: "housekeeping", perPage: 50 });
|
||||
return result.rows;
|
||||
}
|
||||
Reference in new issue
Block a user