import Link from 'next/link' import Router from 'next/router' import styles from './style.module.css' import {Icon} from '@rmwc/icon' import {Input, Button} from '~/components/form' import useUser from '~/hooks/useUser' // TODO: Load previous addresses CheckoutSummary.getInitialProps = async function({ctx: {axios}}){ const {data: order} = await axios.get(`/api/orders/current`) return {order} } export default function CheckoutSummary({order}){ const user = useUser(); const currentTransaction = order .transactions.find(transaction => ( transaction.payment_state === 'started' )) const {item_total_price, shipping_price, tax_price} = currentTransaction const shippingPrice = shipping_price ? '$' + (shipping_price / 100) : null const total_price = (item_total_price && shipping_price && tax_price) ? '$' + (item_total_price + shippingPrice + tax_price - coupon_effective_discount) : null return ( <>
{item.name} ({count}): | ${count * item.price_cents / 100} |
Shipping: | {shippingPrice || '-'} |
Sales tax: | ${tax_price / 100} |
Total: | {total_price || '-'} |