|
|
@@ -1,18 +1,24 @@
|
|
|
-import type { OrderData } from "@/types/api/customer/order/vieworder";
|
|
|
-
|
|
|
+import type { CustomerOrder } from "@/types/customer/accountOrderDetail/order";
|
|
|
+import Image from "next/image";
|
|
|
interface Props {
|
|
|
- orderData: OrderData;
|
|
|
+ orderData: CustomerOrder;
|
|
|
}
|
|
|
-
|
|
|
export default function PromotionDetails({ orderData }: Props) {
|
|
|
const money = (value: number) =>
|
|
|
new Intl.NumberFormat("en-US", {
|
|
|
style: "currency",
|
|
|
- currency: orderData.order_currency_code,
|
|
|
+ currency: "USD",
|
|
|
}).format(value);
|
|
|
|
|
|
- const discount = Math.abs(orderData.discount_amount);
|
|
|
-
|
|
|
+ // 各个优惠金额,取绝对值用于展示
|
|
|
+ const couponDiscount = Math.abs(orderData.discountAmount ?? 0);
|
|
|
+ const giftCardAmt = Math.abs(orderData.giftcardAmount ?? 0);
|
|
|
+ const rewardPointsAmt = Math.abs(orderData.rewardPointsAmount ?? 0);
|
|
|
+ const vipPlusAmt = orderData.vipPlusAmount
|
|
|
+ ? Number(orderData.vipPlusAmount)
|
|
|
+ : 0;
|
|
|
+ const vipDiscountAmt = Math.abs(orderData.vipDiscountAmount ?? 0);
|
|
|
+ const earnedPoints = orderData.rewardPointsEarned ?? 0;
|
|
|
return (
|
|
|
<section
|
|
|
className="
|
|
|
@@ -25,40 +31,94 @@ export default function PromotionDetails({ orderData }: Props) {
|
|
|
"
|
|
|
>
|
|
|
<h2 className="text-[18px]">Promotion Details</h2>
|
|
|
-
|
|
|
<div className="mt-6 border-t border-[#EEEEEE] pt-4">
|
|
|
{/* Subtotal */}
|
|
|
<div className="flex justify-between py-3 text-[14px]">
|
|
|
<span>Subtotal</span>
|
|
|
-
|
|
|
- <span>{money(orderData.sub_total)}</span>
|
|
|
+ <span>{money(orderData.subTotal)}</span>
|
|
|
</div>
|
|
|
|
|
|
- {/* Discount */}
|
|
|
- <div className="flex justify-between py-3 text-[14px]">
|
|
|
- <span>Discount</span>
|
|
|
+ {/* Gift Card */}
|
|
|
+ {giftCardAmt > 0 && (
|
|
|
+ <div className="flex justify-between py-3 text-[14px]">
|
|
|
+ <span>Gift Card</span>
|
|
|
+ <span className="bg-[#FFD600] px-2 py-1">
|
|
|
+ -{money(giftCardAmt)}
|
|
|
+ </span>
|
|
|
+ </div>
|
|
|
+ )}
|
|
|
|
|
|
- <span className={discount > 0 ? "bg-[#FFD600] px-2 py-1" : ""}>
|
|
|
- {discount > 0 ? `-${money(discount)}` : money(0)}
|
|
|
- </span>
|
|
|
- </div>
|
|
|
+ {/* Coupon Discount */}
|
|
|
+ {couponDiscount > 0 && (
|
|
|
+ <div className="flex justify-between py-3 text-[14px]">
|
|
|
+ <span>
|
|
|
+ Discount
|
|
|
+ {orderData.couponCode ? `(Code:${orderData.couponCode})` : ""}
|
|
|
+ </span>
|
|
|
+ <span className="bg-[#FFD600] px-2 py-1">
|
|
|
+ -{money(couponDiscount)}
|
|
|
+ </span>
|
|
|
+ </div>
|
|
|
+ )}
|
|
|
+
|
|
|
+ {/* Reward Points */}
|
|
|
+ {rewardPointsAmt > 0 && (
|
|
|
+ <div className="flex justify-between py-3 text-[14px]">
|
|
|
+ <span>Points</span>
|
|
|
+ <span className="bg-[#FFD600] px-2 py-1">
|
|
|
+ -{money(rewardPointsAmt)}
|
|
|
+ </span>
|
|
|
+ </div>
|
|
|
+ )}
|
|
|
+
|
|
|
+ {/* VIP Plus Discount - 使用图片代替css标签 */}
|
|
|
+ {vipDiscountAmt > 0 && (
|
|
|
+ <div className="flex justify-between py-3 text-[14px]">
|
|
|
+ <span className="relative">
|
|
|
+ <Image
|
|
|
+ src="/image/account/plus-tag.png"
|
|
|
+ alt="PLUS"
|
|
|
+ width={60}
|
|
|
+ height={20}
|
|
|
+ className="inline-block align-middle"
|
|
|
+ />
|
|
|
+ </span>
|
|
|
+ <span className="bg-[#FFD600] px-2 py-1">
|
|
|
+ -{money(vipDiscountAmt)}
|
|
|
+ </span>
|
|
|
+ </div>
|
|
|
+ )}
|
|
|
+
|
|
|
+ {/* WIGGINS PLUS */}
|
|
|
+ {vipPlusAmt > 0 && (
|
|
|
+ <div className="flex justify-between py-3 text-[14px]">
|
|
|
+ <span>ASTERIA PLUS</span>
|
|
|
+ <span>{money(vipPlusAmt)}</span>
|
|
|
+ </div>
|
|
|
+ )}
|
|
|
|
|
|
{/* Shipping */}
|
|
|
<div className="flex justify-between py-3 text-[14px]">
|
|
|
<span>Shipping</span>
|
|
|
-
|
|
|
<span>
|
|
|
- {orderData.shipping_amount === 0
|
|
|
+ {orderData.shippingAmount === 0
|
|
|
? "Free"
|
|
|
- : money(orderData.shipping_amount)}
|
|
|
+ : money(orderData.shippingAmount)}
|
|
|
</span>
|
|
|
</div>
|
|
|
|
|
|
+ {/* Insurance for Lost */}
|
|
|
+ {Number(orderData.shippingInsuranceAmount) > 0 && (
|
|
|
+ <div className="flex justify-between py-3 text-[14px]">
|
|
|
+ <span>Insurance for Lost(3%)</span>
|
|
|
+ <span>{money(Number(orderData.shippingInsuranceAmount))}</span>
|
|
|
+ </div>
|
|
|
+ )}
|
|
|
+
|
|
|
{/* Tax */}
|
|
|
<div className="flex justify-between py-3 text-[14px]">
|
|
|
<span>Tax</span>
|
|
|
-
|
|
|
- <span>{money(orderData.tax_amount)}</span>
|
|
|
+ <span>{money(orderData.taxAmount)}</span>
|
|
|
</div>
|
|
|
|
|
|
{/* Total */}
|
|
|
@@ -74,9 +134,15 @@ export default function PromotionDetails({ orderData }: Props) {
|
|
|
"
|
|
|
>
|
|
|
<span>Total:</span>
|
|
|
-
|
|
|
- <span className="font-medium">{money(orderData.grand_total)}</span>
|
|
|
+ <span className="font-medium">{money(orderData.grandTotal)}</span>
|
|
|
</div>
|
|
|
+
|
|
|
+ {/* You've earned points 底部文字 */}
|
|
|
+ {earnedPoints > 0 && (
|
|
|
+ <div className="mt-4 text-[14px] text-[#8A8A8A]">
|
|
|
+ You've earned {earnedPoints} points
|
|
|
+ </div>
|
|
|
+ )}
|
|
|
</div>
|
|
|
</section>
|
|
|
);
|