Skip to content

Commit

Permalink
limit cost to 2 decimals
Browse files Browse the repository at this point in the history
  • Loading branch information
RhysSullivan committed Oct 18, 2024
1 parent 229c615 commit bbb541a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/app/order/dynamic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ function CartItem({ product }: { product: CartItem }) {
if (!product) {
return null;
}
// limit to 2 decimal places
const cost = (Number(product.price) * product.quantity).toFixed(2);
return (
<div className="flex flex-row items-center justify-between space-x-4 border-t border-gray-200 pt-4">
<Link
Expand Down Expand Up @@ -65,9 +67,7 @@ function CartItem({ product }: { product: CartItem }) {
</div>
</div>
<div className="min-w-24">
<p className="font-semibold">
${Number(product.price) * product.quantity}
</p>
<p className="font-semibold">${cost}</p>
</div>
</div>
<form action={removeFromCart}>
Expand Down

0 comments on commit bbb541a

Please sign in to comment.