import { setCurrentStep } from '@akinon/next/redux/reducers/checkout';
import { useAppDispatch, useAppSelector } from '@akinon/next/redux/hooks';
import { RootState } from '@theme/redux/store';
import { Price, Link } from '@theme/components';
import { partAttrs } from '@akinon/pz-theme/src/utils/part-styles';
import { CheckoutStep } from '@akinon/next/types';
import { useLocalization } from '@akinon/next/hooks';
import PluginModule, { Component } from '@akinon/next/components/plugin-module';
import { twMerge } from 'tailwind-merge';
import { Image } from '@akinon/next/components/image';
import { Trans } from '@akinon/next/components/trans';
import { StoreCredits } from './steps/payment/options/store-credit';
export const Summary = () => {
const { t } = useLocalization();
const currentStep = useAppSelector(
(state: RootState) => state.checkout.steps.current
);
const preOrder = useAppSelector(
(state: RootState) => state.checkout.preOrder
);
const { isMobileApp } = useAppSelector((state: RootState) => state.root);
const dispatch = useAppDispatch();
if (!preOrder) {
return null;
}
const Text = (props) => {
return props.title;
};
return (
{t('checkout.summary.title')}
{preOrder.basket.basketitem_set.length}{' '}
{t('checkout.summary.items').toUpperCase()}
{preOrder.basket.basketitem_set.map((item, index) => (
{item.product.name}
{t('checkout.summary.quantity')}:
{item.quantity}
{item.product.retail_price !== item.product.price && (
)}
))}
{t('checkout.summary.subtotal')} (
{preOrder.basket.basketitem_set.length}{' '}
{t('checkout.summary.items')})
{t('checkout.summary.shipping')}
{parseFloat(preOrder?.loyalty_money) > 0 && (
{t('checkout.summary.loyalty_money_total')}
)}
{t('checkout.summary.discounts_total')}
{t('checkout.summary.total')}
{currentStep === CheckoutStep.Payment && (
{t('checkout.summary.delivery_info')}
dispatch(setCurrentStep(CheckoutStep.Shipping))}
{...partAttrs('summary-edit')}
>
{t('checkout.summary.change')}
),
ShippingOption: (
)
}}
/>
{preOrder.shipping_address?.line}{' '}
{preOrder.shipping_address?.postcode}{' '}
{preOrder.shipping_address?.district && (
<>{preOrder.shipping_address?.district.name} / >
)}
{preOrder.shipping_address?.township && (
<>{preOrder.shipping_address?.township.name} / >
)}
{preOrder.shipping_address?.city?.name}
)}
);
};