| 1234567891011121314151617181920212223242526272829303132333435363738394041 |
- import { redirect, RedirectType } from 'next/navigation';
- import {serverGraphqlFetch} from "@utils/bagisto/index";
- import CheckoutWrapper from "./_components/CheckoutWrapper";
- import { GET_CART_ITEM } from "@/graphql";
- import { auth } from "@/utils/auth/auth-helper";
- import { GetCartItemData } from "@/types/cart/type";
- /**
- * 进入结账页
- * 登录用户的话,获取用户地址列表 从auth session 中获取email
- * 获取billing地址和shipping地址
- * 获取购物车数据
- * 获取运输方式
- * 获取支付方式
- *
- *
- */
- export const dynamic = "force-dynamic";
- export default async function CheckoutPage() {
- const session = await auth(); // 游客是null
- const {data: cartDetailsRes} = await serverGraphqlFetch<GetCartItemData>({
- query: GET_CART_ITEM
- });
- if(cartDetailsRes.createReadCart === null) {
- redirect('/', RedirectType.replace);
- }
- const cartDetails = cartDetailsRes.createReadCart.readCart;
- return (
- <>
- <CheckoutWrapper key={cartDetails.grandTotal}
- cartDetailData={cartDetails}
- loginEmail={session?.user?.email || ""}
- />
- </>
- );
-
- }
|