mirror of
https://github.com/34892002/edgeKey.git
synced 2026-09-10 18:29:11 +08:00
24 lines
747 B
TypeScript
24 lines
747 B
TypeScript
import type { PrismaClient } from "../../../generated/prisma/client";
|
|
import { getProductBySlug } from "../../../modules/catalog/service";
|
|
import { listEnabledPaymentMethods } from "../../../modules/payment/service";
|
|
|
|
export type Data = Awaited<ReturnType<typeof data>>;
|
|
|
|
export async function data(pageContext: {
|
|
routeParams: { slug: string };
|
|
prisma: PrismaClient;
|
|
}) {
|
|
const product = await getProductBySlug(pageContext.routeParams.slug, pageContext.prisma);
|
|
|
|
const paymentMethods = product
|
|
? (await listEnabledPaymentMethods(pageContext.prisma))
|
|
.filter((item) => item.enabled)
|
|
.sort((a, b) => Number(b.provider === "EPAY") - Number(a.provider === "EPAY"))
|
|
: [];
|
|
|
|
return {
|
|
product,
|
|
paymentMethods,
|
|
};
|
|
}
|