|
@@ -1,51 +1,149 @@
|
|
|
-// OrderInfoBlock.tsx
|
|
|
|
|
-import type { OrderData } from "@/types/api/customer/order/vieworder";
|
|
|
|
|
-
|
|
|
|
|
|
|
+// import type { CustomerOrder } from "@/types/customer/accountOrderDetail/order";
|
|
|
|
|
+import type { OrderDetails } from "@/types/customer/type";
|
|
|
|
|
+import Image from "next/image";
|
|
|
interface Props {
|
|
interface Props {
|
|
|
- orderData: OrderData; // 直接传入完整订单对象
|
|
|
|
|
|
|
+ orderData: OrderDetails;
|
|
|
}
|
|
}
|
|
|
|
|
+export default function PromotionDetails({ orderData }: Props) {
|
|
|
|
|
+ const money = (value: number) =>
|
|
|
|
|
+ new Intl.NumberFormat("en-US", {
|
|
|
|
|
+ style: "currency",
|
|
|
|
|
+ currency: "USD",
|
|
|
|
|
+ }).format(value);
|
|
|
|
|
|
|
|
-export default function OrderInfoBlock({ orderData }: Props) {
|
|
|
|
|
- console.log("orderData:::",orderData);
|
|
|
|
|
-
|
|
|
|
|
- // 拼接收货信息
|
|
|
|
|
- const shipToText = `${orderData.shipping_address.first_name} ${orderData.shipping_address.last_name},
|
|
|
|
|
-Phone: ${orderData.shipping_address.phone},
|
|
|
|
|
-${orderData.shipping_address.city}, ${orderData.shipping_address.state}, ${orderData.shipping_address.country} ${orderData.shipping_address.postcode}`;
|
|
|
|
|
-
|
|
|
|
|
|
|
+ // 各个优惠金额,取绝对值用于展示
|
|
|
|
|
+ const couponDiscount = Math.abs(orderData.discountAmount ?? 0);
|
|
|
|
|
+ const giftCardAmt = Math.abs(Number(orderData.giftcardAmount ?? 0));
|
|
|
|
|
+ const rewardPointsAmt = Math.abs(orderData.rewardPointsAmount ?? 0);
|
|
|
|
|
+ const vipPlusAmt = orderData.vipPlusAmount
|
|
|
|
|
+ ? Number(orderData.vipPlusAmount)
|
|
|
|
|
+ : 0;
|
|
|
|
|
+ const vipDiscountAmt = Math.abs(Number(orderData.vipDiscountAmount ?? 0));
|
|
|
|
|
+ const earnedPoints = orderData.rewardPointsEarned ?? 0;
|
|
|
return (
|
|
return (
|
|
|
- <>
|
|
|
|
|
- <h2 className="text-xl font-bold mb-6 border-b pb-3">Order Information</h2>
|
|
|
|
|
|
|
+ <section
|
|
|
|
|
+ className="
|
|
|
|
|
+ rounded-[6px]
|
|
|
|
|
+ bg-white
|
|
|
|
|
+ px-4
|
|
|
|
|
+ pb-6
|
|
|
|
|
+ "
|
|
|
|
|
+ >
|
|
|
|
|
+ <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.subTotal)}</span>
|
|
|
|
|
+ </div>
|
|
|
|
|
+
|
|
|
|
|
+ {/* 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>
|
|
|
|
|
+ )}
|
|
|
|
|
|
|
|
- {/* 两列网格布局 */}
|
|
|
|
|
- <div className="grid grid-cols-[auto_1fr] gap-x-4 gap-y-5">
|
|
|
|
|
- <div className="font-medium text-gray-700">Ship To:</div>
|
|
|
|
|
- <div>{shipToText}</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>
|
|
|
|
|
+ )}
|
|
|
|
|
|
|
|
- <div className="font-medium text-gray-700">Order Number:</div>
|
|
|
|
|
- <div>{orderData.increment_id}</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>
|
|
|
|
|
+ )}
|
|
|
|
|
|
|
|
- <div className="font-medium text-gray-700">Status:</div>
|
|
|
|
|
- <div>{orderData.status}</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>
|
|
|
|
|
+ )}
|
|
|
|
|
|
|
|
- <div className="font-medium text-gray-700">Order Date:</div>
|
|
|
|
|
- <div>{orderData.created_at}</div>
|
|
|
|
|
|
|
+ {/* WIGGINS PLUS */}
|
|
|
|
|
+ {vipPlusAmt > 0 && (
|
|
|
|
|
+ <div className="flex justify-between py-3 text-[14px]">
|
|
|
|
|
+ <span>ASTERIA PLUS</span>
|
|
|
|
|
+ <span>{money(vipPlusAmt)}</span>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ )}
|
|
|
|
|
|
|
|
- <div className="font-medium text-gray-700">Customer Email:</div>
|
|
|
|
|
- <div>{orderData.customer_email}</div>
|
|
|
|
|
|
|
+ {/* Shipping */}
|
|
|
|
|
+ <div className="flex justify-between py-3 text-[14px]">
|
|
|
|
|
+ <span>Shipping</span>
|
|
|
|
|
+ <span>
|
|
|
|
|
+ {orderData.shippingAmount === 0
|
|
|
|
|
+ ? "Free"
|
|
|
|
|
+ : 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>
|
|
|
|
|
+ )}
|
|
|
|
|
|
|
|
- <div className="font-medium text-gray-700">Shipping Method:</div>
|
|
|
|
|
- <div>{orderData.shipping_title}</div>
|
|
|
|
|
|
|
+ {/* Tax */}
|
|
|
|
|
+ <div className="flex justify-between py-3 text-[14px]">
|
|
|
|
|
+ <span>Tax</span>
|
|
|
|
|
+ <span>{money(orderData.taxAmount)}</span>
|
|
|
|
|
+ </div>
|
|
|
|
|
|
|
|
- <div className="font-medium text-gray-700">Payment Method:</div>
|
|
|
|
|
- <div className="bg-pink-300 px-3 py-1 rounded w-fit">
|
|
|
|
|
- {orderData.payment.method_title}
|
|
|
|
|
|
|
+ {/* Total */}
|
|
|
|
|
+ <div
|
|
|
|
|
+ className="
|
|
|
|
|
+ mt-2
|
|
|
|
|
+ flex
|
|
|
|
|
+ justify-between
|
|
|
|
|
+ border-t
|
|
|
|
|
+ border-[#EEEEEE]
|
|
|
|
|
+ pt-5
|
|
|
|
|
+ text-[15px]
|
|
|
|
|
+ "
|
|
|
|
|
+ >
|
|
|
|
|
+ <span>Total:</span>
|
|
|
|
|
+ <span className="font-medium">{money(orderData.grandTotal)}</span>
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
- {/* 可选:显示总价信息 */}
|
|
|
|
|
- <div className="font-medium text-gray-700">Total Amount:</div>
|
|
|
|
|
- <div>{orderData.order_currency_code} {orderData.grand_total}</div>
|
|
|
|
|
|
|
+ {/* You've earned points 底部文字 */}
|
|
|
|
|
+ {earnedPoints > 0 && (
|
|
|
|
|
+ <div className="mt-4 text-[14px] text-[#8A8A8A]">
|
|
|
|
|
+ You've earned {earnedPoints} points
|
|
|
|
|
+ </div>
|
|
|
|
|
+ )}
|
|
|
</div>
|
|
</div>
|
|
|
- </>
|
|
|
|
|
|
|
+ <div className="h-px bg-[rgba(172,189,184,1)] w-full mt-6"></div>
|
|
|
|
|
+ </section>
|
|
|
);
|
|
);
|
|
|
-}
|
|
|
|
|
|
|
+}
|