"use client"; import { useState } from "react"; import Image from "next/image"; import { useRouter } from 'next/navigation'; import {useConfig} from "@/utils/hooks/useConfig"; import { OrderDetails } from "@/types/customer/type"; import { confirmDialog } from "@/components/theme/ui/kernel/confirm/api"; import ProductsModalPendingOrder from "./ProductsModalPendingOrder"; import dynamic from "next/dynamic"; import {getAddressFromOrderDetailAddressList} from "@/utils/orderDetailTools"; const CountDown = dynamic(() => import("@/components/common/CountDown"), { ssr: false, }); export default function ContinueToPayOrderInfo({ orderDetail }: { orderDetail: OrderDetails; }) { const router = useRouter(); const {currencies,getCurrentCurrencyItem} = useConfig(); const currentCurrency = getCurrentCurrencyItem(); const currencySymbol = currentCurrency.symbol; const orderCurrency = currencies.find(item => item.code === orderDetail.orderCurrencyCode) || null; const orderSymbol = orderCurrency?.symbol || currencySymbol; const [productsModalOpen, setProductsModalOpen] = useState(false); const countDownEnd = (new Date(orderDetail.createdAt)).getTime() + 24*3600*1000; const shippingAddress = getAddressFromOrderDetailAddressList(orderDetail.addresses,"order_shipping"); const billingAddress = getAddressFromOrderDetailAddressList(orderDetail.addresses,"order_billing"); const totalQty = orderDetail.totalQtyOrdered > 1 ? String(orderDetail.totalQtyOrdered) + 'Items' : '1 Item'; const productItems = orderDetail.items.edges.map((item) => { return item.node; }); // 倒计时结束跳转到首页 const handleCountDownEnd = () => { confirmDialog({ title: "Order Timeout", content: "This order timeout, has been canceled. Will redirect to home page.", noCancel: true, }).then(() => { router.replace('/'); }); }; const closeProductsModal = () => { setProductsModalOpen(false); }; const openProductsModal = () => { setProductsModalOpen(true); }; return( <>
Awaiting For Payment

Shipping Address

{shippingAddress.firstName} {shippingAddress.lastName} {shippingAddress.phone}

{/* */}
{shippingAddress.address}, {shippingAddress.city}, {shippingAddress.state}, {shippingAddress.postcode}, {shippingAddress.country}

Billing Address

{billingAddress.firstName} {billingAddress.lastName} {billingAddress.phone}

{/* */}
{billingAddress.address}, {billingAddress.city}, {billingAddress.state}, {billingAddress.postcode}, {billingAddress.country}
Order Summary({totalQty})
{productItems.map((product) => { return(
product
) })}

Promotion Details

Subtotal

{orderSymbol}{orderDetail.subTotal}

{orderDetail.rewardPointsEarned > 0 &&

You Earn

{orderDetail.rewardPointsEarned} Reward Points

} {orderDetail.shippingAmount !== 0 &&

Shipping

{orderSymbol}{orderDetail.shippingAmount}

} {Number(orderDetail?.shippingInsuranceAmount) > 0 &&

Shipping

{orderSymbol}{Number(orderDetail.shippingInsuranceAmount)}

} {orderDetail.taxAmount !== 0 &&

Tax

{orderSymbol}{orderDetail.taxAmount}

} {(orderDetail.vipPlusAmount !== '0.00' && orderDetail.vipPlusAmount !== null) &&

Plus Fee

{orderSymbol}{orderDetail.vipPlusAmount}

} {orderDetail.discountAmount !== 0 &&

Discount

-{orderSymbol}{orderDetail.discountAmount}

} {(orderDetail.giftcardAmount !== '0.00' && orderDetail.giftcardAmount !== null) &&

Gift Card

-{orderSymbol}{orderDetail.giftcardAmount}

} {(orderDetail.vipDiscountAmount !== '0.00' && orderDetail.vipDiscountAmount !== null) &&

Plus Save

-{orderSymbol}{orderDetail.vipDiscountAmount}

} {orderDetail.rewardPointsAmount > 0 &&

You Redeem ({orderDetail.rewardPointsUsed} Reward Points)

-{orderSymbol}{orderDetail.rewardPointsAmount}

} {/*

You Earn

600 Reward Points

*/}

Total

{orderSymbol}{orderDetail.grandTotal}

{/** 产品弹窗 */} closeProductsModal()} /> ); }