-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
161 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { Box, Typography, Stack, Divider } from '@mui/material'; | ||
import { IItem } from '../api/useGetCartItems'; | ||
|
||
interface CartItemListProps { | ||
items: IItem[]; | ||
} | ||
|
||
export const CartItemList = ({ items }: CartItemListProps) => { | ||
return ( | ||
<Box sx={{ mb: 2 }}> | ||
<Typography variant="h6" gutterBottom> | ||
Order Summary | ||
</Typography> | ||
<Stack divider={<Divider />} spacing={2}> | ||
{items.map((item) => ( | ||
<Box | ||
key={item.name} | ||
sx={{ | ||
display: 'flex', | ||
justifyContent: 'space-between', | ||
alignItems: 'center', | ||
}} | ||
> | ||
<Box> | ||
<Typography variant="body1">{item.name}</Typography> | ||
<Typography variant="body2" color="text.secondary"> | ||
Quantity: {item.quantity} | ||
</Typography> | ||
</Box> | ||
<Typography variant="body1"> | ||
${(Number(item.price) * item.quantity).toFixed(2)} | ||
</Typography> | ||
</Box> | ||
))} | ||
</Stack> | ||
</Box> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { Stack, Typography, Divider } from '@mui/material'; | ||
import { ICheckout } from '../api/useGetCartItems'; | ||
|
||
export const CheckoutInfo = ({ | ||
checkout, | ||
itemsCount, | ||
}: { | ||
checkout: ICheckout | undefined; | ||
itemsCount: number; | ||
}) => { | ||
return ( | ||
<Stack spacing={1}> | ||
{/* Items total */} | ||
<Stack direction="row" justifyContent="space-between"> | ||
<Typography variant="body1">Item(s) total</Typography> | ||
<Typography variant="body1"> | ||
CA${checkout?.itemsTotal} | ||
</Typography> | ||
</Stack> | ||
{/* Shop discount */} | ||
<Stack direction="row" justifyContent="space-between"> | ||
<Typography variant="body1">Shop discount</Typography> | ||
<Typography variant="body1"> | ||
- CA${checkout?.shopDiscount} | ||
</Typography> | ||
</Stack> | ||
<Divider /> | ||
{/* Subtotal */} | ||
<Stack direction="row" justifyContent="space-between"> | ||
<Typography variant="body1">Subtotal</Typography> | ||
<Typography variant="body1">CA${checkout?.subtotal}</Typography> | ||
</Stack> | ||
{/* Shipping */} | ||
<Stack direction="row" justifyContent="space-between"> | ||
<Typography variant="body1">Shipping</Typography> | ||
<Typography variant="body1">CA${checkout?.shipping}</Typography> | ||
</Stack> | ||
<Divider /> | ||
{/* Total */} | ||
<Stack direction="row" justifyContent="space-between"> | ||
<Typography fontWeight={'bold'}> | ||
Total ({itemsCount} items) | ||
</Typography> | ||
<Typography variant="body1" fontWeight={'bold'}> | ||
CA${checkout?.total} | ||
</Typography> | ||
</Stack> | ||
</Stack> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters