-
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.
uploading cart items, checkout page and using reselect for selectors
- Loading branch information
Showing
12 changed files
with
187 additions
and
23 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 was deleted.
Oops, something went wrong.
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
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,17 @@ | ||
import React from 'react'; | ||
|
||
import './checkout-item.styles.scss'; | ||
|
||
const CheckoutItem = ({cartItem:{name, imageUrl, price, quantity}}) => ( | ||
<div className='checkout-item'> | ||
<div className='image-container'> | ||
<img src={imageUrl} alt='item' /> | ||
</div> | ||
<span className='name'>{name}</span> | ||
<span className='quantity'>{quantity}</span> | ||
<span className='price'>{price}</span> | ||
<div 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,33 @@ | ||
.checkout-item { | ||
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 { | ||
padding-left: 20px; | ||
} | ||
|
||
.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,45 @@ | ||
import React from 'react'; | ||
import { connect } from 'react-redux'; | ||
import { createStructuredSelector } from 'reselect' | ||
|
||
import { selectCartItems, selectCartTotal } from '../../redux/cart/cart.selector'; | ||
|
||
import CheckoutItem from '../../components/checkout-item/checkout-item.component' | ||
|
||
import './checkout.styles.scss'; | ||
|
||
const CheckoutPage = ({cartItems, cartTotal}) => ( | ||
<div className='checkout-page'> | ||
<div className='checkout-header'> | ||
<div className='header-block'> | ||
<span>Producto</span> | ||
</div> | ||
<div className='header-block'> | ||
<span>Descripcion</span> | ||
</div> | ||
<div className='header-block'> | ||
<span>Cantidad</span> | ||
</div> | ||
<div className='header-block'> | ||
<span>Precio</span> | ||
</div> | ||
<div className='header-block'> | ||
<span>Remover</span> | ||
</div> | ||
</div> | ||
{ | ||
cartItems.map( | ||
cartItem=> <CheckoutItem key={cartItem.id} cartItem={cartItem} /> | ||
) | ||
} | ||
<div className='total'> | ||
<span>TOTAL: ${cartTotal}</span> | ||
</div> | ||
</div> | ||
) | ||
const mapStateToProps = createStructuredSelector({ | ||
cartItems: selectCartItems, | ||
cartTotal: selectCartTotal | ||
}) | ||
|
||
export default connect(mapStateToProps)(CheckoutPage); |
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,31 @@ | ||
.checkout-page { | ||
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; | ||
} | ||
} |
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,8 @@ | ||
import { createSelector } from 'reselect'; | ||
|
||
const selectUser = state => state.user | ||
|
||
export const selectCurrentUser = createSelector ( | ||
[selectUser], | ||
user=>user.currentUser | ||
) |