mirror of
https://github.com/34892002/edgeKey.git
synced 2026-06-21 02:26:04 +08:00
25 lines
631 B
TypeScript
25 lines
631 B
TypeScript
import type { PrismaClient } from "../../../../generated/prisma/client";
|
|
import { getAdminOrderById } from "../../../../modules/order/service";
|
|
|
|
export type Data = ReturnType<typeof data>;
|
|
|
|
export async function data(pageContext: {
|
|
routeParams: { id: string };
|
|
prisma: PrismaClient;
|
|
session?: { user?: { role?: string } };
|
|
}) {
|
|
const orderId = Number(pageContext.routeParams.id);
|
|
|
|
if (pageContext.session?.user?.role !== "admin") {
|
|
return {
|
|
orderId,
|
|
order: null,
|
|
};
|
|
}
|
|
|
|
return {
|
|
orderId,
|
|
order: Number.isFinite(orderId) ? await getAdminOrderById(orderId, pageContext.prisma) : null,
|
|
};
|
|
}
|