import { useAppSelector } from '@akinon/next/redux/hooks'; import { useLocalization } from '@akinon/next/hooks'; import PluginModule, { Component } from '@akinon/next/components/plugin-module'; import { Price, Link } from '@theme/components'; import { partAttrs } from '@akinon/pz-theme/src/utils/part-styles'; import { Image } from '@akinon/next/components/image'; import { StoreCredits } from '@theme/views/checkout/steps/payment/options/store-credit'; import type { RootState } from '@theme/redux/store'; import type { SectionId } from './hooks/use-section-state'; interface OnePageSummaryProps { onEditSection: (section: SectionId) => void; showReview?: boolean; } const OnePageSummary = ({ onEditSection, showReview = true }: OnePageSummaryProps) => { const { t } = useLocalization(); const preOrder = useAppSelector( (state: RootState) => state.checkout.preOrder ); const { isMobileApp } = useAppSelector((state: RootState) => state.root); if (!preOrder?.basket) return null; const itemCount = preOrder.basket.basketitem_set.length; return (
{t('checkout.summary.title')} {itemCount} {t('checkout.summary.items')}
    {preOrder.basket.basketitem_set.map((item, index) => (
  • {item.product.name}
    {item.product.name}
    {t('checkout.summary.quantity')}:{' '} {item.quantity}
    {item.product.retail_price !== item.product.price && ( )}
  • ))}
{t('checkout.summary.subtotal')}
{/* The amount declares its own weight and colour, so a rule on the row can never reach it by inheritance — it gets its own part instead of leaving the row's Text Color a dead control. */}
{t('checkout.summary.shipping')}
{parseFloat(preOrder.loyalty_money || '0') > 0 && (
{t('checkout.summary.loyalty_money_total')}
)} {parseFloat(preOrder.basket.total_discount_amount || '0') > 0 && (
{t('checkout.summary.discounts_total')}
)}
{/* The row carries the baseline typography that used to live on the label span, so the row's own controls have something to change; the amount keeps its distinct treatment and answers to its own part. */}
{t('checkout.summary.total')}
{showReview && (preOrder.shipping_address || preOrder.shipping_option || preOrder.payment_option) && (
{t('checkout.one_page.summary.review_title')}
    {preOrder.shipping_address && (
  • {t('checkout.one_page.summary.deliver_to')}
    {preOrder.shipping_address.title}
    {preOrder.shipping_address.line},{' '} {preOrder.shipping_address.township?.name},{' '} {preOrder.shipping_address.city?.name}
  • )} {preOrder.shipping_option && (
  • {t('checkout.one_page.summary.shipping_method')}
    {preOrder.shipping_option.name}
    {preOrder.shipping_option.shipping_amount && (
    )}
  • )} {preOrder.payment_option && (
  • {t('checkout.one_page.summary.payment_method')}
    {preOrder.payment_option.name}
  • )}
)}
); }; export default OnePageSummary;