Refactor requests, refactor users, add home dashboard
This commit is contained in:
@ -4,14 +4,13 @@ import { prisma } from "@/lib/prisma";
|
||||
import {
|
||||
commissionRequestTableRowSchema,
|
||||
commissionStatusSchema,
|
||||
} from "@/schemas/commissions/tableSchema";
|
||||
} from "@/schemas/commissions/requests";
|
||||
import { z } from "zod";
|
||||
|
||||
export type CursorPagination = { pageIndex: number; pageSize: number };
|
||||
export type SortDir = "asc" | "desc";
|
||||
|
||||
const triStateSchema = z.enum(["any", "true", "false"]);
|
||||
type TriState = z.infer<typeof triStateSchema>;
|
||||
|
||||
const sortingSchema = z.array(
|
||||
z.object({
|
||||
@ -42,7 +41,6 @@ export async function getCommissionRequestsTablePage(input: {
|
||||
where.OR = [
|
||||
{ customerName: { contains: q, mode: "insensitive" } },
|
||||
{ customerEmail: { contains: q, mode: "insensitive" } },
|
||||
{ message: { contains: q, mode: "insensitive" } },
|
||||
];
|
||||
}
|
||||
}
|
||||
@ -78,12 +76,12 @@ export async function getCommissionRequestsTablePage(input: {
|
||||
take: pagination.pageSize,
|
||||
select: {
|
||||
id: true,
|
||||
index: true,
|
||||
createdAt: true,
|
||||
status: true,
|
||||
customerName: true,
|
||||
customerEmail: true,
|
||||
customerSocials: true,
|
||||
message: true,
|
||||
_count: { select: { files: true } },
|
||||
},
|
||||
}),
|
||||
@ -91,13 +89,13 @@ export async function getCommissionRequestsTablePage(input: {
|
||||
|
||||
const mapped = rows.map((r) => ({
|
||||
id: r.id,
|
||||
index: r.index,
|
||||
createdAt: r.createdAt.toISOString(),
|
||||
status: r.status as any,
|
||||
customerName: r.customerName,
|
||||
customerEmail: r.customerEmail,
|
||||
customerSocials: r.customerSocials ?? null,
|
||||
messagePreview: r.message.slice(0, 140),
|
||||
filesCount: r._count.files,
|
||||
status: r.status as any,
|
||||
fileCount: r._count.files,
|
||||
}));
|
||||
|
||||
// Validate output once (helps catch schema drift)
|
||||
|
||||
Reference in New Issue
Block a user