├── .gitignore ├── README.md ├── package.json ├── public ├── favicon.ico ├── images │ ├── email.png │ ├── favicon_soccershop.png │ ├── mail.svg │ ├── phone.svg │ ├── produtos │ │ ├── alemanha.jpg │ │ ├── arsenal.jpg │ │ ├── brasil.jpg │ │ ├── brasil94.jpg │ │ ├── fla.jpg │ │ ├── fla81.jpg │ │ ├── fla_treino.jpg │ │ ├── gremio.jpg │ │ ├── man-city.jpg │ │ ├── milan.jpg │ │ ├── palmeiras.jpg │ │ └── real_treino.jpg │ ├── sent.svg │ ├── soccerbg3.jpg │ └── torcida.jpg ├── index.html ├── logo192.png ├── logo512.png ├── manifest.json └── robots.txt ├── src ├── App.js ├── Pages │ ├── contato.js │ └── home.js ├── components │ ├── Card.js │ ├── Cart │ │ └── index.js │ ├── Header.js │ ├── Item.js │ └── store │ │ ├── actions │ │ └── cart.js │ │ ├── index.js │ │ └── reducers │ │ ├── cart.js │ │ ├── index.js │ │ ├── product.js │ │ └── products.js ├── index.js └── routes.js └── yarn.lock /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Getting Started with Create React App 2 | 3 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). 4 | 5 | ## Available Scripts 6 | 7 | In the project directory, you can run: 8 | 9 | ### `yarn start` 10 | 11 | Runs the app in the development mode.\ 12 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser. 13 | 14 | The page will reload if you make edits.\ 15 | You will also see any lint errors in the console. 16 | 17 | ### `yarn test` 18 | 19 | Launches the test runner in the interactive watch mode.\ 20 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. 21 | 22 | ### `yarn build` 23 | 24 | Builds the app for production to the `build` folder.\ 25 | It correctly bundles React in production mode and optimizes the build for the best performance. 26 | 27 | The build is minified and the filenames include the hashes.\ 28 | Your app is ready to be deployed! 29 | 30 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. 31 | 32 | ### `yarn eject` 33 | 34 | **Note: this is a one-way operation. Once you `eject`, you can’t go back!** 35 | 36 | If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. 37 | 38 | Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. 39 | 40 | You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. 41 | 42 | ## Learn More 43 | 44 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). 45 | 46 | To learn React, check out the [React documentation](https://reactjs.org/). 47 | 48 | ### Code Splitting 49 | 50 | This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting) 51 | 52 | ### Analyzing the Bundle Size 53 | 54 | This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size) 55 | 56 | ### Making a Progressive Web App 57 | 58 | This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app) 59 | 60 | ### Advanced Configuration 61 | 62 | This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration) 63 | 64 | ### Deployment 65 | 66 | This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment) 67 | 68 | ### `yarn build` fails to minify 69 | 70 | This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify) 71 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "dioshop", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@material-ui/core": "^4.11.4", 7 | "@material-ui/icons": "^4.11.2", 8 | "@testing-library/jest-dom": "^5.11.4", 9 | "@testing-library/react": "^11.1.0", 10 | "@testing-library/user-event": "^12.1.10", 11 | "history": "^5.0.0", 12 | "react": "^17.0.2", 13 | "react-dom": "^17.0.2", 14 | "react-router-dom": "^6.0.0-beta.0", 15 | "react-scripts": "4.0.3", 16 | "web-vitals": "^1.0.1" 17 | }, 18 | "scripts": { 19 | "start": "react-scripts start", 20 | "build": "react-scripts build", 21 | "test": "react-scripts test", 22 | "eject": "react-scripts eject" 23 | }, 24 | "eslintConfig": { 25 | "extends": [ 26 | "react-app", 27 | "react-app/jest" 28 | ] 29 | }, 30 | "browserslist": { 31 | "production": [ 32 | ">0.2%", 33 | "not dead", 34 | "not op_mini all" 35 | ], 36 | "development": [ 37 | "last 1 chrome version", 38 | "last 1 firefox version", 39 | "last 1 safari version" 40 | ] 41 | }, 42 | "devDependencies": { 43 | "react-redux": "^7.2.4", 44 | "redux": "^4.1.0" 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathsouzadev/dioshopping/57af7bb46d2b4ce1f380136dc69d2c6c336e09e2/public/favicon.ico -------------------------------------------------------------------------------- /public/images/email.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathsouzadev/dioshopping/57af7bb46d2b4ce1f380136dc69d2c6c336e09e2/public/images/email.png -------------------------------------------------------------------------------- /public/images/favicon_soccershop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathsouzadev/dioshopping/57af7bb46d2b4ce1f380136dc69d2c6c336e09e2/public/images/favicon_soccershop.png -------------------------------------------------------------------------------- /public/images/mail.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /public/images/phone.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /public/images/produtos/alemanha.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathsouzadev/dioshopping/57af7bb46d2b4ce1f380136dc69d2c6c336e09e2/public/images/produtos/alemanha.jpg -------------------------------------------------------------------------------- /public/images/produtos/arsenal.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathsouzadev/dioshopping/57af7bb46d2b4ce1f380136dc69d2c6c336e09e2/public/images/produtos/arsenal.jpg -------------------------------------------------------------------------------- /public/images/produtos/brasil.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathsouzadev/dioshopping/57af7bb46d2b4ce1f380136dc69d2c6c336e09e2/public/images/produtos/brasil.jpg -------------------------------------------------------------------------------- /public/images/produtos/brasil94.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathsouzadev/dioshopping/57af7bb46d2b4ce1f380136dc69d2c6c336e09e2/public/images/produtos/brasil94.jpg -------------------------------------------------------------------------------- /public/images/produtos/fla.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathsouzadev/dioshopping/57af7bb46d2b4ce1f380136dc69d2c6c336e09e2/public/images/produtos/fla.jpg -------------------------------------------------------------------------------- /public/images/produtos/fla81.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathsouzadev/dioshopping/57af7bb46d2b4ce1f380136dc69d2c6c336e09e2/public/images/produtos/fla81.jpg -------------------------------------------------------------------------------- /public/images/produtos/fla_treino.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathsouzadev/dioshopping/57af7bb46d2b4ce1f380136dc69d2c6c336e09e2/public/images/produtos/fla_treino.jpg -------------------------------------------------------------------------------- /public/images/produtos/gremio.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathsouzadev/dioshopping/57af7bb46d2b4ce1f380136dc69d2c6c336e09e2/public/images/produtos/gremio.jpg -------------------------------------------------------------------------------- /public/images/produtos/man-city.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathsouzadev/dioshopping/57af7bb46d2b4ce1f380136dc69d2c6c336e09e2/public/images/produtos/man-city.jpg -------------------------------------------------------------------------------- /public/images/produtos/milan.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathsouzadev/dioshopping/57af7bb46d2b4ce1f380136dc69d2c6c336e09e2/public/images/produtos/milan.jpg -------------------------------------------------------------------------------- /public/images/produtos/palmeiras.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathsouzadev/dioshopping/57af7bb46d2b4ce1f380136dc69d2c6c336e09e2/public/images/produtos/palmeiras.jpg -------------------------------------------------------------------------------- /public/images/produtos/real_treino.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathsouzadev/dioshopping/57af7bb46d2b4ce1f380136dc69d2c6c336e09e2/public/images/produtos/real_treino.jpg -------------------------------------------------------------------------------- /public/images/sent.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /public/images/soccerbg3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathsouzadev/dioshopping/57af7bb46d2b4ce1f380136dc69d2c6c336e09e2/public/images/soccerbg3.jpg -------------------------------------------------------------------------------- /public/images/torcida.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathsouzadev/dioshopping/57af7bb46d2b4ce1f380136dc69d2c6c336e09e2/public/images/torcida.jpg -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | React App 12 | 13 | 14 | 15 |
16 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathsouzadev/dioshopping/57af7bb46d2b4ce1f380136dc69d2c6c336e09e2/public/logo192.png -------------------------------------------------------------------------------- /public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathsouzadev/dioshopping/57af7bb46d2b4ce1f380136dc69d2c6c336e09e2/public/logo512.png -------------------------------------------------------------------------------- /public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /src/App.js: -------------------------------------------------------------------------------- 1 | import { BrowserRouter as Router } from 'react-router-dom'; 2 | import { Provider } from 'react-redux'; 3 | import store from './components/store'; 4 | import Routes from './routes'; 5 | import { Container } from '@material-ui/core/'; 6 | import Header from './components/Header'; 7 | 8 | const App = () => { 9 | 10 | const localCart = JSON.parse(localStorage.getItem('dioshopping: cart')) 11 | 12 | if(localCart !== null) { 13 | store.dispatch({type: 'CHANGE_CART', localCart}) 14 | } 15 | 16 | return( 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | 25 | ) 26 | } 27 | 28 | export default App; 29 | -------------------------------------------------------------------------------- /src/Pages/contato.js: -------------------------------------------------------------------------------- 1 | import { useState, useEffect } from 'react'; 2 | import { Grid, Button, TextField } from '@material-ui/core/'; 3 | 4 | const Contatos = () => { 5 | 6 | const url = 'http://localhost:5000/message' 7 | const [message, setMessage] = useState([]); 8 | const [author, setAuthor] = useState(''); 9 | const [content, setContent] = useState(''); 10 | const [validator, setValidator] = useState(false); 11 | const [render, setRender] = useState(false); 12 | const [success, setSuccess] = useState(false); 13 | 14 | useEffect(async () => { 15 | const response = await fetch(url) 16 | const data = await response.json(); 17 | setMessage(data); 18 | }, [render]) 19 | 20 | const sendMessage = () => { 21 | setValidator(false); 22 | if(author.length <= 0 || content.length <= 0){ 23 | return setValidator(!validator) 24 | } 25 | const bodyForm = { 26 | email: author, 27 | message: content, 28 | } 29 | 30 | fetch(url, { 31 | method: "POST", 32 | headers: { 33 | "Content-Type": "application/json" 34 | }, 35 | body: JSON.stringify(bodyForm) 36 | }) 37 | .then((response) => response.json()) 38 | .then((data) => { 39 | if(data.id) { 40 | setRender(true); 41 | setSuccess(true); 42 | setTimeout(() => { 43 | setSuccess(false); 44 | }, 5000) 45 | } 46 | }) 47 | 48 | setAuthor(''); 49 | setContent(''); 50 | 51 | console.log(content) 52 | } 53 | 54 | return( 55 | <> 56 | 57 | {setAuthor(event.target.value)}} fullWidth/> 58 | {setContent(event.target.value)}} fullWidth/> 59 | 60 | 61 | {validator && 62 |
63 | Por favor preencha todos os campos! 64 | 65 |
66 | } 67 | 68 | {success && 69 |
70 | Mensagem foi enviada 71 |
72 | } 73 | 74 | 77 | 78 | {message.map((content) => { 79 | return( 80 |
81 |
82 |
{content.email}
83 |

{content.message}

84 |

{content.created_at}

85 |
86 |
87 | ) 88 | } )} 89 | 90 | ) 91 | } 92 | 93 | export default Contatos; 94 | -------------------------------------------------------------------------------- /src/Pages/home.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { useSelector } from 'react-redux'; 3 | import { Paper, Grid, Typography, List, makeStyles } from '@material-ui/core/'; 4 | import Item from '../components/Item'; 5 | import Card from '../components/Card'; 6 | 7 | const useStyles = makeStyles((theme) => ({ 8 | root: { 9 | flexGrow: 1, 10 | marginTop: '5px', 11 | }, 12 | paper: { 13 | padding: theme.spacing(2), 14 | textAlign: 'center' 15 | }, 16 | })); 17 | 18 | const HomePage = () => { 19 | const products = useSelector(state => state.products) 20 | const classes = useStyles(); 21 | 22 | const categorys = products.map( 23 | category => { 24 | const container = { }; 25 | container['id'] = category.id_categorys; 26 | container['name'] = category.name_categorys; 27 | return container; 28 | } 29 | ) 30 | 31 | const category = categorys.map(JSON.stringify) 32 | .filter(function(item, index, arr){ 33 | return arr.indexOf(item, index + 1) === -1; 34 | }) 35 | .map(JSON.parse) 36 | 37 | const arrayCategory = categorys.map(category => category.name) 38 | let count = { }; 39 | 40 | for(let i = 0; i < arrayCategory.length; i++){ 41 | { 42 | let key = arrayCategory[i]; 43 | count[key] = (count[key] ? count[key] + 1 : 1) 44 | } 45 | } 46 | 47 | return( 48 | 49 | 50 | 51 | 52 | Categorias 53 | 54 | 55 | {category.map( 56 | category => { 57 | return ( 58 | 63 | ) 64 | } 65 | )} 66 | 67 | 68 | 69 | 70 | {products.map(item => { 71 | return( 72 | 76 | {item.name_product} 77 | 78 | ) 79 | })} 80 | 81 | 82 | ) 83 | } 84 | 85 | export default HomePage; 86 | -------------------------------------------------------------------------------- /src/components/Card.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Paper, Grid, Typography, Button, makeStyles} from '@material-ui/core/'; 3 | import { useSelector, useDispatch } from 'react-redux'; 4 | import cartActions from './store/actions/cart'; 5 | 6 | const useStyles = makeStyles((theme) => ({ 7 | paper: { 8 | padding: theme.spacing(2), 9 | textAlign: 'center' 10 | }, 11 | })); 12 | 13 | const Card = ({ product, children }) => { 14 | const cart = useSelector( state => state.cart.value ) 15 | const dispatch = useDispatch(); 16 | const classes = useStyles(); 17 | 18 | return( 19 | 20 | 21 | 22 | 23 | {product.name_product}/ 24 | 25 | {children} 26 | 27 | 28 | R$ {product.price.toFixed(2)} 29 | 30 | 31 | 32 | 38 | 39 | 40 | 41 | ) 42 | } 43 | 44 | export default Card; 45 | -------------------------------------------------------------------------------- /src/components/Cart/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { useSelector, useDispatch } from 'react-redux'; 3 | import cartActions from '../store/actions/cart'; 4 | 5 | const Cart = () => { 6 | const cart = useSelector(state => state.cart) 7 | const dispatch = useDispatch(); 8 | 9 | let totalPrice = 0; 10 | 11 | for(let i = 0; i < cart.Cart.length; i++) { 12 | totalPrice += (cart.Cart[i].price * cart.Cart[i].quantity) 13 | } 14 | 15 | if(cart.value > 0){ 16 | localStorage.setItem('dioshopping: cart', JSON.stringify(cart)) 17 | } 18 | 19 | return( 20 | <> 21 | 27 | 28 | {/* Modal */} 29 | 83 | 84 | ) 85 | } 86 | 87 | export default Cart; 88 | -------------------------------------------------------------------------------- /src/components/Header.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Link } from 'react-router-dom'; 3 | import { Grid, Typography, Button } from '@material-ui/core/'; 4 | import Cart from './Cart'; 5 | 6 | const Header = () => { 7 | return( 8 | 9 | 10 | Dio Shopping 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | ) 23 | } 24 | 25 | export default Header; 26 | -------------------------------------------------------------------------------- /src/components/Item.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { ListItem, ListItemText } from '@material-ui/core/'; 3 | 4 | const Item = ({ name, details }) => { 5 | return( 6 | 7 | 11 | 12 | ) 13 | } 14 | 15 | export default Item; 16 | -------------------------------------------------------------------------------- /src/components/store/actions/cart.js: -------------------------------------------------------------------------------- 1 | const Add = (cart, product) => { 2 | return{ 3 | type: 'ADD_TO_CART', 4 | cart, 5 | product 6 | } 7 | } 8 | 9 | const AddItem = (cart, product) => { 10 | return{ 11 | type: 'ADD_ITEM', 12 | cart, 13 | product 14 | } 15 | } 16 | 17 | const RemoveItem = (cart, product) => { 18 | return{ 19 | type: 'REMOVE_ITEM', 20 | cart, 21 | product 22 | } 23 | } 24 | 25 | const DeleteItem = (cart, product) => { 26 | return{ 27 | type: 'DELETE_ITEM', 28 | cart, 29 | product 30 | } 31 | } 32 | 33 | const ChangeCart = (localCart) => { 34 | return{ 35 | type: 'CHANGE_CART', 36 | localCart 37 | } 38 | } 39 | 40 | export default { 41 | Add, 42 | AddItem, 43 | RemoveItem, 44 | DeleteItem, 45 | ChangeCart 46 | } 47 | -------------------------------------------------------------------------------- /src/components/store/index.js: -------------------------------------------------------------------------------- 1 | import { createStore } from 'redux'; 2 | 3 | import rootReducer from './reducers'; 4 | 5 | const store = createStore(rootReducer) 6 | 7 | export default store; 8 | -------------------------------------------------------------------------------- /src/components/store/reducers/cart.js: -------------------------------------------------------------------------------- 1 | import productList from './product'; 2 | 3 | const INITIAL_STATE = { 4 | value: 0, 5 | products: productList, 6 | Cart: [] 7 | } 8 | 9 | export default function cart(state = INITIAL_STATE, action){ 10 | switch(action.type){ 11 | case 'ADD_TO_CART': 12 | if(state.value === 0) { 13 | let item = { 14 | id: action.product.id_product, 15 | name: action.product.name_product, 16 | price: action.product.price, 17 | image: action.product.image, 18 | quantity: 1 19 | } 20 | state.Cart.push(item); 21 | } else { 22 | let check = false; 23 | state.Cart.map((item, key) => { 24 | if(item.id === action.product.id_product){ 25 | state.Cart[key].quantity++; 26 | check = true; 27 | } 28 | }); 29 | if (!check){ 30 | let item = { 31 | id: action.product.id_product, 32 | name: action.product.name_product, 33 | price: action.product.price, 34 | image: action.product.image, 35 | quantity: 1 36 | } 37 | state.Cart.push(item); 38 | } 39 | } 40 | return { 41 | ...state, 42 | value: ( state.value + 1) 43 | } 44 | case 'ADD_ITEM': 45 | action.product.quantity++ 46 | return{ 47 | ...state, 48 | value: ( action.cart.value + 1 ) 49 | } 50 | case 'REMOVE_ITEM': 51 | if(action.product.quantity > 1){ 52 | action.product.quantity-- 53 | return { 54 | ...state, 55 | value: ( action.cart.value - 1 ) 56 | } 57 | } else { 58 | return state; 59 | } 60 | case 'DELETE_ITEM': 61 | return{ 62 | ...state, 63 | value: (action.cart.value - action.product.quantity), 64 | Cart: state.Cart.filter(item => { 65 | return item.id !== action.product.id 66 | }) 67 | } 68 | case 'CHANGE_CART': 69 | return state = action.localCart 70 | default: 71 | return state; 72 | } 73 | return state 74 | } 75 | -------------------------------------------------------------------------------- /src/components/store/reducers/index.js: -------------------------------------------------------------------------------- 1 | import { combineReducers } from 'redux'; 2 | 3 | import products from './products'; 4 | import cart from './cart'; 5 | 6 | export default combineReducers({ 7 | products, 8 | cart 9 | }) 10 | -------------------------------------------------------------------------------- /src/components/store/reducers/product.js: -------------------------------------------------------------------------------- 1 | const productsList = [ 2 | { 3 | id_product: 1, 4 | category: "nacional", 5 | fk_idcategorys: 1, 6 | name_product: "Flamengo 2020", 7 | price: 300, 8 | image: "./images/produtos/fla.jpg", 9 | id_categorys: 1, 10 | name_categorys: "Clubes brasileiros", 11 | selected: false 12 | }, 13 | { 14 | id_product: 2, 15 | category: "nacional", 16 | fk_idcategorys: 1, 17 | name_product: "Palmeiras 2020", 18 | price: 350, 19 | image: "./images/produtos/palmeiras.jpg", 20 | id_categorys: 1, 21 | name_categorys: "Clubes brasileiros", 22 | selected: false 23 | }, 24 | { 25 | id_product: 9, 26 | category: "nacional", 27 | fk_idcategorys: 1, 28 | name_product: "Grêmio 2020", 29 | price: 230, 30 | image: "./images/produtos/gremio.jpg", 31 | id_categorys: 1, 32 | name_categorys: "Clubes brasileiros", 33 | selected: false 34 | }, 35 | { 36 | id_product: 4, 37 | category: "europeu", 38 | fk_idcategorys: 2, 39 | name_product: "Arsenal 2020/21", 40 | price: 399.99, 41 | image: "./images/produtos/arsenal.jpg", 42 | id_categorys: 2, 43 | name_categorys: "Clubes europeus", 44 | selected: false 45 | }, 46 | { 47 | id_product: 10, 48 | category: "europeu", 49 | fk_idcategorys: 2, 50 | name_product: "Manchester City 2020/21", 51 | price: 350.99, 52 | image: "./images/produtos/man-city.jpg", 53 | id_categorys: 2, 54 | name_categorys: "Clubes europeus", 55 | selected: false 56 | }, 57 | { 58 | id_product: 11, 59 | category: "europeu", 60 | fk_idcategorys: 2, 61 | name_product: "Milan 2020/21", 62 | price: 299.99, 63 | image: "./images/produtos/milan.jpg", 64 | id_categorys: 2, 65 | name_categorys: "Clubes europeus", 66 | selected: false 67 | }, 68 | { 69 | id_product: 6, 70 | category: "historica", 71 | fk_idcategorys: 3, 72 | name_product: "Brasil 1994", 73 | price: 200, 74 | image: "./images/produtos/brasil94.jpg", 75 | id_categorys: 3, 76 | name_categorys: "Camisas históricas", 77 | selected: false 78 | }, 79 | { 80 | id_product: 7, 81 | category: "historica", 82 | fk_idcategorys: 3, 83 | name_product: "Flamengo 1981", 84 | price: 450, 85 | image: "./images/produtos/fla81.jpg", 86 | id_categorys: 3, 87 | name_categorys: "Camisas históricas", 88 | selected: false 89 | }, 90 | { 91 | id_product: 3, 92 | category: "selecao", 93 | fk_idcategorys: 4, 94 | name_product: "Alemanha 2020", 95 | price: 350, 96 | image: "./images/produtos/alemanha.jpg", 97 | id_categorys: 4, 98 | name_categorys: "Seleções nacionais", 99 | selected: false 100 | }, 101 | { 102 | id_product: 5, 103 | category: "selecao", 104 | fk_idcategorys: 4, 105 | name_product: "Brasil 2020", 106 | price: 399, 107 | image: "./images/produtos/brasil.jpg", 108 | id_categorys: 4, 109 | name_categorys: "Seleções nacionais", 110 | selected: false 111 | }, 112 | { 113 | id_product: 8, 114 | category: "casual", 115 | fk_idcategorys: 5, 116 | name_product: "Flamengo T 2020", 117 | price: 180, 118 | image: "./images/produtos/fla_treino.jpg", 119 | id_categorys: 5, 120 | name_categorys: "Casuais", 121 | selected: false 122 | }, 123 | { 124 | id_product: 12, 125 | category: "casual", 126 | fk_idcategorys: 5, 127 | name_product: "Real Madrid 2019/20", 128 | price: 189.99, 129 | image: "./images/produtos/real_treino.jpg", 130 | id_categorys: 5, 131 | name_categorys: "Casuais", 132 | selected: false 133 | }, 134 | ]; 135 | 136 | export default productsList; 137 | -------------------------------------------------------------------------------- /src/components/store/reducers/products.js: -------------------------------------------------------------------------------- 1 | import productsList from './product'; 2 | 3 | const PRODUCT = productsList; 4 | 5 | export default function products(state = PRODUCT){ 6 | return state; 7 | } 8 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import App from './App'; 4 | 5 | ReactDOM.render( 6 | 7 | 8 | , 9 | document.getElementById('root') 10 | ); 11 | -------------------------------------------------------------------------------- /src/routes.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Routes, Route } from 'react-router-dom'; 3 | import HomePage from './Pages/home'; 4 | import Contatos from './Pages/contato'; 5 | 6 | const MainRoutes = () => { 7 | return( 8 | 9 | } 12 | /> 13 | } 16 | /> 17 | 18 | ) 19 | } 20 | 21 | export default MainRoutes; 22 | --------------------------------------------------------------------------------