Repository: TheCoderDream/React-Ecommerce-App-with-Redux Branch: master Commit: a83dde725a92 Files: 57 Total size: 113.7 KB Directory structure: gitextract_ub8tvy_4/ ├── .gitignore ├── .idea/ │ ├── ecommerce.iml │ ├── inspectionProfiles/ │ │ └── Project_Default.xml │ ├── misc.xml │ ├── modules.xml │ ├── vcs.xml │ └── workspace.xml ├── README.md ├── package.json ├── public/ │ ├── index.html │ └── manifest.json └── src/ ├── App.js ├── App.scss ├── App.test.js ├── actions/ │ └── index.js ├── components/ │ ├── BrandFilter/ │ │ ├── BrandFilter.js │ │ └── BrandFilter.scss │ ├── CartItem/ │ │ ├── CartItem.js │ │ └── CartItem.scss │ ├── Footer/ │ │ └── Footer.js │ ├── Header/ │ │ └── Header.js │ ├── LayoutMode/ │ │ ├── LayoutMode.js │ │ └── LayoutMode.scss │ ├── OrderFilter/ │ │ ├── OrderFilter.js │ │ └── OrderFilter.scss │ ├── Pagination/ │ │ ├── Pagination.js │ │ └── Pagination.scss │ ├── Product/ │ │ ├── Product.js │ │ └── Product.scss │ ├── ProductDetail/ │ │ └── ProductDetail.js │ ├── ProductSlider/ │ │ ├── ProductSlider.js │ │ └── ProductSlider.scss │ └── SlideDots/ │ ├── SlideDots.js │ └── SlideDots.scss ├── containers/ │ ├── FilterBar/ │ │ └── FilterBar.js │ └── ProductList/ │ ├── ProductList.js │ └── ProductList.scss ├── data/ │ ├── brands.js │ ├── getData.js │ └── phones.js ├── index.js ├── index.scss ├── pages/ │ ├── Home/ │ │ └── Home.js │ ├── ProductDetail/ │ │ └── ProductDetail.js │ └── ShopingCart/ │ └── ShoppingCart.js ├── pipes/ │ ├── brandFilter.js │ ├── orderByFilter.js │ ├── paginationFilter.js │ ├── priceFormatter.js │ └── shortenTitle.js ├── reducers/ │ ├── brand.filter.reducer.js │ ├── index.js │ ├── orderByPrice.filter.reducer.js │ ├── pagination.reducer.js │ └── shop.reducer.js ├── serviceWorker.js └── utilities/ └── cumulativeOffset.js ================================================ FILE CONTENTS ================================================ ================================================ FILE: .gitignore ================================================ # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. # dependencies /node_modules /.pnp .pnp.js # testing /coverage # production /build # misc .DS_Store .env.local .env.development.local .env.test.local .env.production.local npm-debug.log* yarn-debug.log* yarn-error.log* ================================================ FILE: .idea/ecommerce.iml ================================================ ================================================ FILE: .idea/inspectionProfiles/Project_Default.xml ================================================ ================================================ FILE: .idea/misc.xml ================================================ ================================================ FILE: .idea/modules.xml ================================================ ================================================ FILE: .idea/vcs.xml ================================================ ================================================ FILE: .idea/workspace.xml ================================================ true DEFINITION_ORDER ))} ); }; const mapStateToProps = (state) => { const brandItemsCount = {}; state.shop.products.forEach(p => { brandItemsCount[p.brand] = brandItemsCount[p.brand] + 1 || 1; }); return { brandItemsCount } }; export default connect(mapStateToProps)(BrandFilter); ================================================ FILE: src/components/BrandFilter/BrandFilter.scss ================================================ .custom-checkbox { display: block; position: relative; padding-left: 2rem; cursor: pointer; user-select: none; &__input { position: absolute; opacity: 0; height: 0; width: 0; } &__span { position: absolute; top: 50%; left: 0; transform: translateY(-50%); height: 1.2rem; width: 1.2rem; background-color: white; border: 2px solid gray; &::after { content: ""; opacity: 0; position: absolute; top: 50%; left: 50%; width: .6rem; height: .6rem; background-color: dodgerblue; transform: translate(-50%, -50%); } } &:hover &__span { background-color: #eeeeee; } &__input:checked + &__span::after { opacity: 1; } } .flex-50 { flex: 0 0 100%; } @media only screen and (max-width: 768px) { .flex-50 { flex: 0 0 50%; } } ================================================ FILE: src/components/CartItem/CartItem.js ================================================ import React, {useState} from 'react'; import {connect} from 'react-redux'; import {shortenTitle} from "../../pipes/shortenTitle"; import {formatMoney} from "../../pipes/priceFormatter"; import './CartItem.scss'; import {addProductToCart, decrementCartQuantity, incrementCartQuantity, removeProductToCart} from "../../actions"; const CartItem = ( { title, price, description, quantity, id, img, dispatch } ) => { console.log(id); const [itemQuantity, setItemQuantity] = useState(quantity); const removeItem = () => { dispatch(removeProductToCart(id)); }; const handleQuantityChange = (e) => { /* const value = e.target.value; console.log(value) if(value > 0 && value <= 10) { setItemQuantity(value); dispatch(addProductToCart(id)); } */ }; const incrementOrDecrement = (e, type) => { const value = itemQuantity; console.log(type, value); if(type === 'inc' && value < 10) { setItemQuantity(itemQuantity + 1); dispatch(incrementCartQuantity(id)); } if(type === 'desc' && value > 1) { setItemQuantity(itemQuantity - 1); dispatch(decrementCartQuantity(id)); } }; return (
{description}

{shortenTitle(title)}

{description}

{formatMoney(price)}$ x
{incrementOrDecrement(e, 'inc')}} type="button" value="+" className="plus" /> {incrementOrDecrement(e, 'desc')}} type="button" value="-" className="minus" />
); }; export default connect()(CartItem); ================================================ FILE: src/components/CartItem/CartItem.scss ================================================ .quantity { float: left; margin-right: 15px; background-color: #eee; position: relative; width: 80px; overflow: hidden } .quantity input { margin: 0; text-align: center; width: 15px; height: 15px; padding: 0; float: right; color: #000; font-size: 20px; border: 0; outline: 0; background-color: #F6F6F6 } .quantity input.qty { position: relative; border: 0; width: 100%; height: 40px; padding: 10px 25px 10px 10px; text-align: center; font-weight: 400; font-size: 15px; border-radius: 0; background-clip: padding-box } .quantity .minus, .quantity .plus { line-height: 0; background-clip: padding-box; -webkit-border-radius: 0; -moz-border-radius: 0; border-radius: 0; -webkit-background-size: 6px 30px; -moz-background-size: 6px 30px; color: #bbb; font-size: 20px; position: absolute; height: 50%; border: 0; right: 0; padding: 0; width: 25px; z-index: 3 } .quantity .minus:hover, .quantity .plus:hover { background-color: #dad8da } .quantity .minus { bottom: 0 } .shopping-cart { margin-top: 20px; } @media only screen and (max-width: 768px) { .product-name { font-size: 1rem; margin-top: .5rem; } .product-description { font-size: 1rem; } .product-quantity-container { margin-top: .5rem; } } ================================================ FILE: src/components/Footer/Footer.js ================================================ import React from 'react'; const Footer = () => { return (

Copyright © Emre Baskan 2019

); }; export default Footer; ================================================ FILE: src/components/Header/Header.js ================================================ import React from 'react'; import {connect} from 'react-redux'; import {NavLink} from 'react-router-dom'; const Header = ({cartLength}) => { return (