|
@@ -7,9 +7,9 @@ import Image from "next/image";
|
|
|
import type {FetchGraphqlResult} from "@/types/graphqlFetch/type";
|
|
import type {FetchGraphqlResult} from "@/types/graphqlFetch/type";
|
|
|
import type { OrderDetailsData } from "@/types/customer/type";
|
|
import type { OrderDetailsData } from "@/types/customer/type";
|
|
|
import {deleteGuestCookieAction} from "@/actions";
|
|
import {deleteGuestCookieAction} from "@/actions";
|
|
|
-import { useConfig } from "@utils/hooks/useConfig";
|
|
|
|
|
import {getAddressFromOrderDetailAddressList,getProductAdditionalInfo} from "@/utils/orderDetailTools";
|
|
import {getAddressFromOrderDetailAddressList,getProductAdditionalInfo} from "@/utils/orderDetailTools";
|
|
|
import Faqs from "./Faqs";
|
|
import Faqs from "./Faqs";
|
|
|
|
|
+import { Price } from "@components/theme/ui/Price";
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 订单详情里的金额的货币符号不会根据用户选择的货币改变 ,而是固定为下单时使用的货币
|
|
* 订单详情里的金额的货币符号不会根据用户选择的货币改变 ,而是固定为下单时使用的货币
|
|
@@ -23,22 +23,22 @@ export default function OrderDetailWrapper({
|
|
|
isGuest: boolean;
|
|
isGuest: boolean;
|
|
|
}) {
|
|
}) {
|
|
|
|
|
|
|
|
- const {currencies} = useConfig();
|
|
|
|
|
|
|
+
|
|
|
const promiseRes = use(orderDetailPromise);
|
|
const promiseRes = use(orderDetailPromise);
|
|
|
const orderDetailRes = promiseRes.data?.customerOrder ?? null;
|
|
const orderDetailRes = promiseRes.data?.customerOrder ?? null;
|
|
|
if(!orderDetailRes) {
|
|
if(!orderDetailRes) {
|
|
|
redirect('/', RedirectType.replace);
|
|
redirect('/', RedirectType.replace);
|
|
|
}
|
|
}
|
|
|
- const shippingAddress = getAddressFromOrderDetailAddressList(orderDetailRes?.addresses,"order_shipping");
|
|
|
|
|
|
|
+ const shippingAddress = getAddressFromOrderDetailAddressList(orderDetailRes.addresses,"order_shipping");
|
|
|
let orderCreatedAt = 'Can\'t get order date';
|
|
let orderCreatedAt = 'Can\'t get order date';
|
|
|
- if(orderDetailRes?.createdAt) {
|
|
|
|
|
|
|
+ if(orderDetailRes.createdAt) {
|
|
|
const localDate = new Date(orderDetailRes.createdAt);
|
|
const localDate = new Date(orderDetailRes.createdAt);
|
|
|
orderCreatedAt = localDate.toLocaleDateString('en-US', { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' });
|
|
orderCreatedAt = localDate.toLocaleDateString('en-US', { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' });
|
|
|
}
|
|
}
|
|
|
const productItems = orderDetailRes?.items?.edges.map(item => {
|
|
const productItems = orderDetailRes?.items?.edges.map(item => {
|
|
|
return item.node;
|
|
return item.node;
|
|
|
}) || [];
|
|
}) || [];
|
|
|
- const currency = currencies.find(item => item.code === orderDetailRes?.orderCurrencyCode) || null;
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
|
// 如果是游客且支付成功,删除cookie里的GUEST_CART_TOKEN GUEST_CART_ID
|
|
// 如果是游客且支付成功,删除cookie里的GUEST_CART_TOKEN GUEST_CART_ID
|
|
@@ -61,10 +61,10 @@ export default function OrderDetailWrapper({
|
|
|
</div>
|
|
</div>
|
|
|
<p className="text-ly-16 text-center mt-6">Your Order Has Been Received</p>
|
|
<p className="text-ly-16 text-center mt-6">Your Order Has Been Received</p>
|
|
|
<p className="text-ly-16 mt-4 flex justify-center">
|
|
<p className="text-ly-16 mt-4 flex justify-center">
|
|
|
- <span className="px-3.75 leading-ly-28 bg-[#f0fffa]">Order #{orderDetailRes?._id}</span>
|
|
|
|
|
|
|
+ <span className="px-3.75 leading-ly-28 bg-[#f0fffa]">Order #{orderDetailRes._id}</span>
|
|
|
</p>
|
|
</p>
|
|
|
<p className="text-ly-12 text-center mt-4 leading-ly-22">
|
|
<p className="text-ly-12 text-center mt-4 leading-ly-22">
|
|
|
- Hello, {orderDetailRes?.customerFirstName} <br/>
|
|
|
|
|
|
|
+ Hello, {orderDetailRes.customerFirstName} <br/>
|
|
|
Thank you so much for your order !<br/>
|
|
Thank you so much for your order !<br/>
|
|
|
We’ll get started on your order very soon!<br/>
|
|
We’ll get started on your order very soon!<br/>
|
|
|
You’ll receive an order confirmation email with details of your order in an hour, please be sure to check your email and confirm your order, that is very important for us to process your order.
|
|
You’ll receive an order confirmation email with details of your order in an hour, please be sure to check your email and confirm your order, that is very important for us to process your order.
|
|
@@ -96,13 +96,13 @@ export default function OrderDetailWrapper({
|
|
|
<div className="mt-6 flex justify-between">
|
|
<div className="mt-6 flex justify-between">
|
|
|
<div className="text-ly-12 flex-none">Order number:</div>
|
|
<div className="text-ly-12 flex-none">Order number:</div>
|
|
|
<div className="w-40.5 text-ly-12 leading-ly-20 text-[#666666] flex-none">
|
|
<div className="w-40.5 text-ly-12 leading-ly-20 text-[#666666] flex-none">
|
|
|
- {orderDetailRes?._id}
|
|
|
|
|
|
|
+ {orderDetailRes._id}
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
<div className="mt-6 flex justify-between">
|
|
<div className="mt-6 flex justify-between">
|
|
|
<div className="text-ly-12 flex-none">Status:</div>
|
|
<div className="text-ly-12 flex-none">Status:</div>
|
|
|
<div className="w-40.5 text-ly-12 leading-ly-20 text-[#666666] flex-none capitalize">
|
|
<div className="w-40.5 text-ly-12 leading-ly-20 text-[#666666] flex-none capitalize">
|
|
|
- {orderDetailRes?.status}
|
|
|
|
|
|
|
+ {orderDetailRes.status}
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
<div className="mt-6 flex justify-between">
|
|
<div className="mt-6 flex justify-between">
|
|
@@ -114,13 +114,13 @@ export default function OrderDetailWrapper({
|
|
|
<div className="mt-6 flex justify-between">
|
|
<div className="mt-6 flex justify-between">
|
|
|
<div className="text-ly-12 flex-none">Shipping method:</div>
|
|
<div className="text-ly-12 flex-none">Shipping method:</div>
|
|
|
<div className="w-40.5 text-ly-12 leading-ly-20 text-[#666666] flex-none">
|
|
<div className="w-40.5 text-ly-12 leading-ly-20 text-[#666666] flex-none">
|
|
|
- {orderDetailRes?.shippingTitle}
|
|
|
|
|
|
|
+ {orderDetailRes.shippingTitle}
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
<div className="mt-6 flex justify-between">
|
|
<div className="mt-6 flex justify-between">
|
|
|
<div className="text-ly-12 flex-none">Payment method:</div>
|
|
<div className="text-ly-12 flex-none">Payment method:</div>
|
|
|
<div className="w-40.5 text-ly-12 leading-ly-20 text-[#666666] flex-none">
|
|
<div className="w-40.5 text-ly-12 leading-ly-20 text-[#666666] flex-none">
|
|
|
- {orderDetailRes?.payment?.methodTitle}
|
|
|
|
|
|
|
+ {orderDetailRes.payment?.methodTitle}
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
@@ -152,7 +152,10 @@ export default function OrderDetailWrapper({
|
|
|
</div>
|
|
</div>
|
|
|
<div className="flex justify-between">
|
|
<div className="flex justify-between">
|
|
|
<p className="text-ly-14 leading-ly-20 font-bold">
|
|
<p className="text-ly-14 leading-ly-20 font-bold">
|
|
|
- {currency && currency.symbol}{product.price}
|
|
|
|
|
|
|
+ <Price
|
|
|
|
|
+ amount={String(product.price)}
|
|
|
|
|
+ currencyCode={orderDetailRes.orderCurrencyCode}
|
|
|
|
|
+ />
|
|
|
</p>
|
|
</p>
|
|
|
<p className="text-ly-12 leading-ly-20">x {product.qtyOrdered}</p>
|
|
<p className="text-ly-12 leading-ly-20">x {product.qtyOrdered}</p>
|
|
|
</div>
|
|
</div>
|
|
@@ -166,60 +169,105 @@ export default function OrderDetailWrapper({
|
|
|
<div className="box-border px-4 w-full mt-6 pt-6 border-t-1 border-black">
|
|
<div className="box-border px-4 w-full mt-6 pt-6 border-t-1 border-black">
|
|
|
<div className="flex justify-between mt-3 first:mt-0">
|
|
<div className="flex justify-between mt-3 first:mt-0">
|
|
|
<p className="text-ly-12 leading-ly-20">Subtotal</p>
|
|
<p className="text-ly-12 leading-ly-20">Subtotal</p>
|
|
|
- <p className="text-ly-12 leading-ly-20">{currency && currency.symbol}{orderDetailRes?.subTotal}</p>
|
|
|
|
|
|
|
+ <p className="text-ly-12 leading-ly-20">
|
|
|
|
|
+ <Price
|
|
|
|
|
+ amount={String(orderDetailRes.subTotal)}
|
|
|
|
|
+ currencyCode={orderDetailRes.orderCurrencyCode}
|
|
|
|
|
+ />
|
|
|
|
|
+ </p>
|
|
|
</div>
|
|
</div>
|
|
|
- {orderDetailRes?.rewardPointsEarned > 0 &&
|
|
|
|
|
|
|
+ {orderDetailRes.rewardPointsEarned > 0 &&
|
|
|
<div className="flex justify-between mt-3 first:mt-0">
|
|
<div className="flex justify-between mt-3 first:mt-0">
|
|
|
<p className="text-ly-12 leading-ly-20">You Earn</p>
|
|
<p className="text-ly-12 leading-ly-20">You Earn</p>
|
|
|
- <p className="text-ly-12 leading-ly-20">{orderDetailRes?.rewardPointsEarned} Reward Points</p>
|
|
|
|
|
|
|
+ <p className="text-ly-12 leading-ly-20">{orderDetailRes.rewardPointsEarned} Reward Points</p>
|
|
|
</div>
|
|
</div>
|
|
|
}
|
|
}
|
|
|
- {!!orderDetailRes?.shippingAmount &&
|
|
|
|
|
|
|
+ {!!orderDetailRes.shippingAmount &&
|
|
|
<div className="flex justify-between mt-3 first:mt-0">
|
|
<div className="flex justify-between mt-3 first:mt-0">
|
|
|
<p className="text-ly-12 leading-ly-20">Shipping</p>
|
|
<p className="text-ly-12 leading-ly-20">Shipping</p>
|
|
|
- <p className="text-ly-12 leading-ly-20">{currency && currency.symbol}{orderDetailRes?.shippingAmount}</p>
|
|
|
|
|
|
|
+ <p className="text-ly-12 leading-ly-20">
|
|
|
|
|
+ <Price
|
|
|
|
|
+ amount={String(orderDetailRes.shippingAmount)}
|
|
|
|
|
+ currencyCode={orderDetailRes.orderCurrencyCode}
|
|
|
|
|
+ />
|
|
|
|
|
+ </p>
|
|
|
</div>
|
|
</div>
|
|
|
}
|
|
}
|
|
|
- {Number(orderDetailRes?.shippingInsuranceAmount) > 0 &&
|
|
|
|
|
|
|
+ {Number(orderDetailRes.shippingInsuranceAmount) > 0 &&
|
|
|
<div className="flex justify-between mt-3 first:mt-0">
|
|
<div className="flex justify-between mt-3 first:mt-0">
|
|
|
<p className="text-ly-12 leading-ly-20">Insurance of Lost</p>
|
|
<p className="text-ly-12 leading-ly-20">Insurance of Lost</p>
|
|
|
- <p className="text-ly-12 leading-ly-20">{currency && currency.symbol}{Number(orderDetailRes?.shippingInsuranceAmount)}</p>
|
|
|
|
|
|
|
+ <p className="text-ly-12 leading-ly-20">
|
|
|
|
|
+ <Price
|
|
|
|
|
+ amount={String(orderDetailRes.shippingInsuranceAmount)}
|
|
|
|
|
+ currencyCode={orderDetailRes.orderCurrencyCode}
|
|
|
|
|
+ />
|
|
|
|
|
+ </p>
|
|
|
</div>
|
|
</div>
|
|
|
}
|
|
}
|
|
|
- {!!orderDetailRes?.taxAmount &&
|
|
|
|
|
|
|
+ {!!orderDetailRes.taxAmount &&
|
|
|
<div className="flex justify-between mt-3 first:mt-0">
|
|
<div className="flex justify-between mt-3 first:mt-0">
|
|
|
<p className="text-ly-12 leading-ly-20">Tax</p>
|
|
<p className="text-ly-12 leading-ly-20">Tax</p>
|
|
|
- <p className="text-ly-12 leading-ly-20">{currency && currency.symbol}{orderDetailRes?.taxAmount}</p>
|
|
|
|
|
|
|
+ <p className="text-ly-12 leading-ly-20">
|
|
|
|
|
+ <Price
|
|
|
|
|
+ amount={String(orderDetailRes.taxAmount)}
|
|
|
|
|
+ currencyCode={orderDetailRes.orderCurrencyCode}
|
|
|
|
|
+ />
|
|
|
|
|
+ </p>
|
|
|
</div>
|
|
</div>
|
|
|
}
|
|
}
|
|
|
- {(orderDetailRes?.vipPlusAmount !== '0.00' && orderDetailRes?.vipPlusAmount !== null) &&
|
|
|
|
|
|
|
+ {(orderDetailRes.vipPlusAmount !== '0.00' && orderDetailRes.vipPlusAmount !== null) &&
|
|
|
<div className="flex justify-between mt-3 first:mt-0">
|
|
<div className="flex justify-between mt-3 first:mt-0">
|
|
|
<p className="text-ly-12 leading-ly-20">Plus Fee</p>
|
|
<p className="text-ly-12 leading-ly-20">Plus Fee</p>
|
|
|
- <p className="text-ly-12 leading-ly-20">{currency && currency.symbol}{orderDetailRes?.vipPlusAmount}</p>
|
|
|
|
|
|
|
+ <p className="text-ly-12 leading-ly-20">
|
|
|
|
|
+ <Price
|
|
|
|
|
+ amount={String(orderDetailRes.vipPlusAmount)}
|
|
|
|
|
+ currencyCode={orderDetailRes.orderCurrencyCode}
|
|
|
|
|
+ />
|
|
|
|
|
+ </p>
|
|
|
</div>
|
|
</div>
|
|
|
}
|
|
}
|
|
|
- {orderDetailRes?.rewardPointsAmount > 0 &&
|
|
|
|
|
|
|
+ {orderDetailRes.rewardPointsAmount > 0 &&
|
|
|
<div className="flex justify-between mt-3 first:mt-0">
|
|
<div className="flex justify-between mt-3 first:mt-0">
|
|
|
<p className="text-ly-12 leading-ly-20">You Redeem ({orderDetailRes.rewardPointsUsed} Reward Points)</p>
|
|
<p className="text-ly-12 leading-ly-20">You Redeem ({orderDetailRes.rewardPointsUsed} Reward Points)</p>
|
|
|
- <p className="text-ly-12 leading-ly-20">-{currency && currency.symbol}{orderDetailRes?.rewardPointsAmount}</p>
|
|
|
|
|
|
|
+ <p className="text-ly-12 leading-ly-20">
|
|
|
|
|
+ -<Price
|
|
|
|
|
+ amount={String(orderDetailRes.rewardPointsAmount)}
|
|
|
|
|
+ currencyCode={orderDetailRes.orderCurrencyCode}
|
|
|
|
|
+ />
|
|
|
|
|
+ </p>
|
|
|
</div>
|
|
</div>
|
|
|
}
|
|
}
|
|
|
- {!!orderDetailRes?.discountAmount &&
|
|
|
|
|
|
|
+ {!!orderDetailRes.discountAmount &&
|
|
|
<div className="flex justify-between mt-3 first:mt-0">
|
|
<div className="flex justify-between mt-3 first:mt-0">
|
|
|
<p className="text-ly-12 leading-ly-20">Discount</p>
|
|
<p className="text-ly-12 leading-ly-20">Discount</p>
|
|
|
- <p className="text-ly-12 leading-ly-20">-{currency && currency.symbol}{orderDetailRes?.discountAmount}</p>
|
|
|
|
|
|
|
+ <p className="text-ly-12 leading-ly-20">
|
|
|
|
|
+ -<Price
|
|
|
|
|
+ amount={String(orderDetailRes.discountAmount)}
|
|
|
|
|
+ currencyCode={orderDetailRes.orderCurrencyCode}
|
|
|
|
|
+ />
|
|
|
|
|
+ </p>
|
|
|
</div>
|
|
</div>
|
|
|
}
|
|
}
|
|
|
- {(orderDetailRes?.giftcardAmount !== '0.00' && orderDetailRes?.giftcardAmount !== null) &&
|
|
|
|
|
|
|
+ {(orderDetailRes.giftcardAmount !== '0.00' && orderDetailRes.giftcardAmount !== null) &&
|
|
|
<div className="flex justify-between mt-3 first:mt-0">
|
|
<div className="flex justify-between mt-3 first:mt-0">
|
|
|
<p className="text-ly-12 leading-ly-20">Gift Card</p>
|
|
<p className="text-ly-12 leading-ly-20">Gift Card</p>
|
|
|
- <p className="text-ly-12 leading-ly-20">-{currency && currency.symbol}{orderDetailRes?.giftcardAmount}</p>
|
|
|
|
|
|
|
+ <p className="text-ly-12 leading-ly-20">
|
|
|
|
|
+ -<Price
|
|
|
|
|
+ amount={String(orderDetailRes.giftcardAmount)}
|
|
|
|
|
+ currencyCode={orderDetailRes.orderCurrencyCode}
|
|
|
|
|
+ />
|
|
|
|
|
+ </p>
|
|
|
</div>
|
|
</div>
|
|
|
}
|
|
}
|
|
|
{(orderDetailRes?.vipDiscountAmount !== '0.00' && orderDetailRes?.vipDiscountAmount !== null) &&
|
|
{(orderDetailRes?.vipDiscountAmount !== '0.00' && orderDetailRes?.vipDiscountAmount !== null) &&
|
|
|
<div className="flex justify-between mt-3 first:mt-0">
|
|
<div className="flex justify-between mt-3 first:mt-0">
|
|
|
<p className="text-ly-12 leading-ly-20">Plus Save</p>
|
|
<p className="text-ly-12 leading-ly-20">Plus Save</p>
|
|
|
- <p className="text-ly-12 leading-ly-20">-{currency && currency.symbol}{orderDetailRes?.vipDiscountAmount}</p>
|
|
|
|
|
|
|
+ <p className="text-ly-12 leading-ly-20">
|
|
|
|
|
+ -<Price
|
|
|
|
|
+ amount={String(orderDetailRes.vipDiscountAmount)}
|
|
|
|
|
+ currencyCode={orderDetailRes.orderCurrencyCode}
|
|
|
|
|
+ />
|
|
|
|
|
+ </p>
|
|
|
</div>
|
|
</div>
|
|
|
}
|
|
}
|
|
|
{/* <div className="flex justify-between mt-3 first:mt-0">
|
|
{/* <div className="flex justify-between mt-3 first:mt-0">
|
|
@@ -228,7 +276,12 @@ export default function OrderDetailWrapper({
|
|
|
</div> */}
|
|
</div> */}
|
|
|
<div className="flex justify-between mt-3 first:mt-0">
|
|
<div className="flex justify-between mt-3 first:mt-0">
|
|
|
<p className="text-ly-16 leading-ly-24">Total</p>
|
|
<p className="text-ly-16 leading-ly-24">Total</p>
|
|
|
- <p className="text-ly-16 leading-ly-24 font-bold">{currency && currency.symbol}{orderDetailRes?.grandTotal}</p>
|
|
|
|
|
|
|
+ <p className="text-ly-16 leading-ly-24 font-bold">
|
|
|
|
|
+ <Price
|
|
|
|
|
+ amount={String(orderDetailRes.grandTotal)}
|
|
|
|
|
+ currencyCode={orderDetailRes.orderCurrencyCode}
|
|
|
|
|
+ />
|
|
|
|
|
+ </p>
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
</>
|
|
</>
|