import React, {useMemo} from 'react'
import {DateTime} from 'luxon'
import Link from 'next/link'
import styles from './style.module.css'
export default function OrderSummary({order, isAdmin}) {
const items = useMemo(() => coalesceItems(order), [order])
const totalShipping = useMemo(() => sumShippingPrice(order), [order])
return (
<>
Contents:
{items.map(({count, item}) => (
Address:
{order.address.name || order.address.company}
{order.address.street1}
{order.address.street2 && (<>{order.address.street2}
>)}
{order.address.city}, {order.address.state}, {order.address.zip}
{order.address.country !== 'US' && order.address.country}
Shipping:
{formatMoney(totalShipping)} charged to customer
)}Not yet shipped
> ) switch (delivery.type) { case 'easypost': case 'hand_shipped': return ( <> {isAdmin && (
{formatMoney(totalShipping)} charged to customer
{(delivery.price_cents && !delivery.easypost) && (<>{formatMoney(parseInt(delivery.price_cents, 10))} paid to ship
>)}
{delivery.easypost && (<>{formatMoney(parseFloat(delivery.easypost.selected_rate.rate) * 100)} paid to EasyPost>)}
Shipped {isAdmin && delivery.type === 'hand_shipped' && ' by hand '} {' '} on {formatTime(delivery.date_shipped)}
Tracking number:
{delivery.tracking_number}
Delivered {isAdmin && ' in person '} on {formatTime(delivery.date_delivered)}
{isAdmin && ( <>{delivery.description}> )} > ) default: return
Error displaying shipment information
} }