Skip to content

Commit

Permalink
first commit, carrinho de vendas com redux, reactotron, toastify
Browse files Browse the repository at this point in the history
  • Loading branch information
flavioro committed Nov 11, 2019
0 parents commit 6754b9c
Show file tree
Hide file tree
Showing 31 changed files with 12,333 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
end_of_line = lf
indent_style = space
indent_size = 2
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
38 changes: 38 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
module.exports = {
env: {
browser: true,
es6: true,
},
extends: [
'airbnb',
'prettier',
'prettier/react'
],
globals: {
Atomics: 'readonly',
SharedArrayBuffer: 'readonly',
},
parser: 'babel-eslint',
parserOptions: {
ecmaFeatures: {
jsx: true,
},
ecmaVersion: 2018,
sourceType: 'module',
},
plugins: [
'react',
'prettier'
],
rules: {
'prettier/prettier': 'error',
'react/jsx-filename-extension': [
'warn',
{ extensions: ['.jsx', '.js'] }
],
'import/prefer-default-export': 'off',
'react/state-in-constructor': 'off',
'no-param-reassign': 'off',
'no-console': ["error", { allow: ["tron"] }]
},
};
23 changes: 23 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# 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*
4 changes: 4 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"singleQuote": true,
"trailingComma": "es5"
}
58 changes: 58 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"name": "modulo07",
"version": "0.1.0",
"private": true,
"dependencies": {
"axios": "^0.19.0",
"history": "^4.10.1",
"immer": "^5.0.0",
"polished": "^3.4.2",
"react": "^16.11.0",
"react-dom": "^16.11.0",
"react-icons": "^3.8.0",
"react-redux": "^7.1.1",
"react-router-dom": "^5.1.2",
"react-scripts": "3.2.0",
"react-toastify": "^5.4.0",
"reactotron-react-js": "^3.3.6",
"reactotron-redux": "^3.1.2",
"reactotron-redux-saga": "^4.2.2",
"redux": "^4.0.4",
"redux-saga": "^1.1.3",
"styled-components": "^4.4.1"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"babel-eslint": "^10.0.3",
"eslint": "^6.6.0",
"eslint-config-airbnb": "^18.0.1",
"eslint-config-prettier": "^6.5.0",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-prettier": "^3.1.1",
"eslint-plugin-react": "^7.16.0",
"eslint-plugin-react-hooks": "^1.7.0",
"json-server": "^0.15.1",
"prettier": "^1.18.2"
}
}
16 changes: 16 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />

<title>Rocketshoes</title>
</head>

<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
</body>

</html>
66 changes: 66 additions & 0 deletions server.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{
"stock": [
{
"id": 1,
"amount": 3
},
{
"id": 2,
"amount": 5
},
{
"id": 3,
"amount": 2
},
{
"id": 4,
"amount": 1
},
{
"id": 5,
"amount": 5
},
{
"id": 6,
"amount": 10
}
],
"products": [
{
"id": 1,
"title": "Tênis de Caminhada Leve Confortável",
"price": 179.9,
"image": "https://rocketseat-cdn.s3-sa-east-1.amazonaws.com/modulo-redux/tenis1.jpg"
},
{
"id": 2,
"title": "Tênis VR Caminhada Confortável Detalhes Couro Masculino",
"price": 139.9,
"image": "https://rocketseat-cdn.s3-sa-east-1.amazonaws.com/modulo-redux/tenis2.jpg"
},
{
"id": 3,
"title": "Tênis Adidas Duramo Lite 2.0",
"price": 219.9,
"image": "https://rocketseat-cdn.s3-sa-east-1.amazonaws.com/modulo-redux/tenis3.jpg"
},
{
"id": 5,
"title": "Tênis VR Caminhada Confortável Detalhes Couro Masculino",
"price": 139.9,
"image": "https://rocketseat-cdn.s3-sa-east-1.amazonaws.com/modulo-redux/tenis2.jpg"
},
{
"id": 6,
"title": "Tênis Adidas Duramo Lite 2.0",
"price": 219.9,
"image": "https://rocketseat-cdn.s3-sa-east-1.amazonaws.com/modulo-redux/tenis3.jpg"
},
{
"id": 4,
"title": "Tênis de Caminhada Leve Confortável",
"price": 179.9,
"image": "https://rocketseat-cdn.s3-sa-east-1.amazonaws.com/modulo-redux/tenis1.jpg"
}
]
}
28 changes: 28 additions & 0 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import React from 'react';
import { Router } from 'react-router-dom';
import { Provider } from 'react-redux';
import { ToastContainer } from 'react-toastify';

import './config/ReactotronConfig';

import GlobalStyle from './styles/global';
import Header from './components/Header';
import Routes from './routes';

import history from './services/history';
import store from './store';

function App() {
return (
<Provider store={store}>
<Router history={history}>
<Header />
<Routes />
<GlobalStyle />
<ToastContainer autoClose={3000} />
</Router>
</Provider>
);
}

export default App;
11 changes: 11 additions & 0 deletions src/assets/images/background.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions src/assets/images/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 31 additions & 0 deletions src/components/Header/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import React from 'react';
import { Link } from 'react-router-dom';
import { connect } from 'react-redux';

import { MdShoppingBasket } from 'react-icons/md';

import { Container, Cart } from './styles';

import logo from '../../assets/images/logo.svg';

function Header({ cartSize }) {
return (
<Container>
<Link to="/">
<img src={logo} alt="Rocketshoes" />
</Link>

<Cart to="/cart">
<div>
<strong>Meu carrinho</strong>
<span>{cartSize} itens</span>
</div>
<MdShoppingBasket size={36} color="#FFF" />
</Cart>
</Container>
);
}

export default connect(state => ({
cartSize: state.cart.length,
}))(Header);
30 changes: 30 additions & 0 deletions src/components/Header/styles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import styled from 'styled-components';
import { Link } from 'react-router-dom';

export const Container = styled.header`
display: flex;
justify-content: space-between;
align-items: center;
margin: 50px 0;
`;

export const Cart = styled(Link)`
display: flex;
align-items: center;
text-decoration: none;
transition: opacity 0.2s;
&:hover {
opacity: 0.7;
}
div {
text-align: right;
margin-right: 10px;
strong {
display: block;
color: #fff;
}
}
`;
14 changes: 14 additions & 0 deletions src/config/ReactotronConfig.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import Reactotron from 'reactotron-react-js';
import { reactotronRedux } from 'reactotron-redux';
import reactotronSaga from 'reactotron-redux-saga';

if (process.env.NODE_ENV === 'development') {
const tron = Reactotron.configure()
.use(reactotronRedux())
.use(reactotronSaga())
.connect();

tron.clear();

console.tron = tron;
}
5 changes: 5 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';

ReactDOM.render(<App />, document.getElementById('root'));
13 changes: 13 additions & 0 deletions src/pages/Cart/actions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export function addToCart(product) {
return {
type: 'ADD_TO_CART',
product,
};
}

export function removeFromCart(id) {
return {
type: 'REMOVE_FROM_CART',
id,
};
}
Loading

0 comments on commit 6754b9c

Please sign in to comment.