- header
- main
- footer
list of task
Name | |
---|---|
John Doe | john@gmail.com |
Jane Doe | jane@gmail.com |
- create products data.json
- import its to App.js
- make html strc
- create component folder
- create filter file
- make section to [Count product | filter section | order section]
- style filter file with css
// filterproducts method
filterProducts = (e) => {
console.log(e.target.value)
// check the value
if (e.target.value === '') {
this.setState({ size: e.target.value, product: data.products })
} else {
this.setState({
size: e.target.value,
products: data.products.filter(
(product) => product.availableSizes.indexOf(e.target.value) >= 0
),
})
}
}
// sortproducts method
sortProducts = (e) => {
const sort = e.target.value
this.setState((state) => ({
sort: sort,
products: this.state.products
.slice()
.sort((a, b) =>
sort === 'lowset'
? a.price > b.price
? 1
: -1
: sort === 'hightes'
? a.price < b.price
? 1
: -1
: a.id < b.id
? 1
: -1
),
}))
}
- Create branch cart-component
- products.js
- handle "Add To Cart" to this.props.addToCart(product)
- app.js
- add cartItems to state as []
- Create addToCart(product)
- Slice, Check product existance, add to catitems
- Cart.js
- define cartitems, order form this.props
- check cartitem.lenght and show message
- list cartitem{cartitems.lenght > 0 && (})}
- index.css
- style cart , cart-header, cart-item ( img,li)
- use localsotroge on app constructor to load cart items (Josn.parse)
- use localstorage on addToCart to save cart items
1.create branch chechout-form
- Cart.js 1.make cart items presisten
- use localstorage on app constructor to load cart items
- use localstroge on addTocart to save cart items 1.handle click on process
- update showCheckout state to ture on click
- conditional rendering checkout form
- get email, name and address required input
- define handleInput function
- add checkout button
- handle onSubmit form event by this.createOrder
- create order object and pass to parent to handle it
- publish changes
1.create branch animation-modal
- show Animation
- create fade effect from bottom for products
- create fade left for add to cart
- create fade right for show checkout form
- open modal by click on produc image
- install react-modal 1.product.js 1.import modal
- set state for product to null
- define openModal and closemodal 1.show modal if product exist
- create modal
- create zoom effect for modal 1.index.js
- create branch add-redux
- npm insatll redux react-redux
- import redux 1.set initial state 1.create types
- types.js
- define FEATC_PRODUCTS
- actions/productAction.js
- declare feactProducts
- create reducers
- reducers/ProductsReducers.hs
- define case FETCH_PRODUCTS 1.Create Store
- import productReducer
- combine reducers
- use store
- app.js
- import store 1.wrap all in provider
- connect products
- import fetchProducts
- set state products to null
- fetch products on did mount
- package.json
- set proxy to http://localhost:4000
- npm run serever 1.check products list