mirror of
https://github.com/34892002/edgeKey.git
synced 2026-09-07 00:38:14 +08:00
25 lines
640 B
TypeScript
25 lines
640 B
TypeScript
import type { PrismaClient } from "../../../../generated/prisma/client";
|
|
import { getAdminOrderById } from "../../../../modules/order/service";
|
|
|
|
export type Data = Awaited<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,
|
|
};
|
|
}
|