import React from "react"; import { CartItem } from "../types"; type Props = { items: CartItem[]; promoPercent: number; shippingPence: number; }; // header dropdown cart; same maths as CheckoutPanel export default function MiniCart({ items, promoPercent, shippingPence }: Props) { const afterDiscount = items.reduce( (sum, i) => sum + Math.round(i.unitPence * i.qty * (1 - promoPercent / 100)), 0 ); const discount = items.reduce((s, i) => s + i.unitPence * i.qty, 0) - afterDiscount; const freeShipping = afterDiscount >= 5000; const total = afterDiscount + (freeShipping ? 0 : shippingPence); const fmt = (p: number) => `£${(p / 100).toFixed(2)}`; return (
You've got free delivery
}