-
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
Amir Amiri
committed
Feb 15, 2023
1 parent
7719ae0
commit aef5010
Showing
7 changed files
with
192 additions
and
3 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
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,30 @@ | ||
import { useContext } from 'react'; | ||
import { CartContext } from '../../contexts/cart.context'; | ||
import './checkout-item.styles.scss'; | ||
|
||
const CheckoutItem = ({ cartItem }) => { | ||
const { name, imageUrl, price, quantity } = cartItem; | ||
const { clearItemFromCart, addItemToCart, removeItemFromCart } = useContext(CartContext); | ||
|
||
return ( | ||
<div className='checkout-item-container'> | ||
<div className='image-container'> | ||
<img src={imageUrl} alt={`${name}`} /> | ||
</div> | ||
<span className='name'>{name}</span> | ||
<span className='quantity'> | ||
<div className='arrow' onClick={() => removeItemFromCart(cartItem)}> | ||
❮ | ||
</div> | ||
<span className='value'>{quantity}</span> | ||
<div className='arrow' onClick={() => addItemToCart(cartItem)}> | ||
❯ | ||
</div> | ||
</span> | ||
<span className='price'>${price}</span> | ||
<div onClick={() => clearItemFromCart(cartItem)} className='remove-button'>✕</div> | ||
</div> | ||
) | ||
} | ||
|
||
export default CheckoutItem; |
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,42 @@ | ||
.checkout-item-container { | ||
width: 100%; | ||
display: flex; | ||
min-height: 100px; | ||
border-bottom: 1px solid darkgrey; | ||
padding: 15px 0; | ||
font-size: 20px; | ||
align-items: center; | ||
|
||
.image-container { | ||
width: 23%; | ||
padding-right: 15px; | ||
|
||
img { | ||
width: 100%; | ||
height: 100%; | ||
} | ||
} | ||
.name, | ||
.quantity, | ||
.price { | ||
width: 23%; | ||
} | ||
|
||
.quantity { | ||
display: flex; | ||
|
||
.arrow { | ||
cursor: pointer; | ||
} | ||
|
||
.value { | ||
margin: 0 10px; | ||
} | ||
} | ||
|
||
.remove-button { | ||
padding-left: 12px; | ||
cursor: pointer; | ||
} | ||
} | ||
|
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,39 @@ | ||
import { useContext } from 'react'; | ||
import { CartContext } from '../../contexts/cart.context'; | ||
import CheckoutItem from '../../components/checkout-item/checkout-item.component'; | ||
import './checkout.styles.scss'; | ||
|
||
const Checkout = () => { | ||
const { cartItems, cartTotal } = useContext(CartContext); | ||
return ( | ||
<div className='checkout-container'> | ||
<div className='checkout-header'> | ||
<div className='header-block'> | ||
<span>Product</span> | ||
</div> | ||
<div className='header-block'> | ||
<span>Description</span> | ||
</div> | ||
<div className='header-block'> | ||
<span>Quantity</span> | ||
</div> | ||
<div className='header-block'> | ||
<span>Price</span> | ||
</div> | ||
<div className='header-block'> | ||
<span>Remove</span> | ||
</div> | ||
</div> | ||
{ | ||
cartItems.map((cartItem) => { | ||
return ( | ||
<CheckoutItem key={cartItem.id} cartItem={cartItem} /> | ||
) | ||
}) | ||
} | ||
<span className='total'>Total: ${cartTotal}</span> | ||
</div> | ||
) | ||
} | ||
|
||
export default Checkout; |
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,32 @@ | ||
.checkout-container { | ||
width: 55%; | ||
min-height: 90vh; | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
margin: 50px auto 0; | ||
|
||
.checkout-header { | ||
width: 100%; | ||
padding: 10px 0; | ||
display: flex; | ||
justify-content: space-between; | ||
border-bottom: 1px solid darkgrey; | ||
|
||
.header-block { | ||
text-transform: capitalize; | ||
width: 23%; | ||
|
||
&:last-child { | ||
width: 8%; | ||
} | ||
} | ||
} | ||
|
||
.total { | ||
margin-top: 30px; | ||
margin-left: auto; | ||
font-size: 36px; | ||
} | ||
} | ||
|