-
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.
first commit, carrinho de vendas com redux, reactotron, toastify
- Loading branch information
0 parents
commit 6754b9c
Showing
31 changed files
with
12,333 additions
and
0 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
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 |
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,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"] }] | ||
}, | ||
}; |
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,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* |
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,4 @@ | ||
{ | ||
"singleQuote": true, | ||
"trailingComma": "es5" | ||
} |
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,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" | ||
} | ||
} |
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,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> |
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,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" | ||
} | ||
] | ||
} |
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,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; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 @@ | ||
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); |
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,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; | ||
} | ||
} | ||
`; |
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,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; | ||
} |
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,5 @@ | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import App from './App'; | ||
|
||
ReactDOM.render(<App />, document.getElementById('root')); |
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,13 @@ | ||
export function addToCart(product) { | ||
return { | ||
type: 'ADD_TO_CART', | ||
product, | ||
}; | ||
} | ||
|
||
export function removeFromCart(id) { | ||
return { | ||
type: 'REMOVE_FROM_CART', | ||
id, | ||
}; | ||
} |
Oops, something went wrong.