Refactor code

This commit is contained in:
2026-02-03 12:17:47 +01:00
parent ea5eb6fa59
commit 8572e22c5d
185 changed files with 1268 additions and 1458 deletions

View File

@ -1,12 +1,10 @@
"use server";
import { prisma } from "@/lib/prisma";
import type { CountRow } from "@/types/dashboard";
type CountRow<K extends string> = {
[P in K]: string;
} & { _count: { _all: number } };
function toCountMapSafe(rows: any[], key: string) {
// Aggregates dashboard stats for admin overview cards and tables.
function toCountMapSafe<K extends string>(rows: Array<CountRow<K>>, key: K) {
const out: Record<string, number> = {};
for (const r of rows) out[String(r[key])] = Number(r?._count?._all ?? 0);
return out;