This file contains hidden or 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
| const INITIAL_STATE = { | |
| materiais: [] | |
| }; | |
| export default (state = INITIAL_STATE, action) => { | |
| switch (action.type) { | |
| case "COMPRA_MATERIAL": | |
| return { ...state, materiais: [...state.materiais, action.payload] }; | |
| default: |
This file contains hidden or 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
| export const compraMateriais = () => { | |
| return dispatch => { | |
| // Código para fazer requisição a uma API | |
| dispatch({ | |
| type: "COMPRA_MATERIAL", | |
| payload: { | |
| nome: "Caixa de canetas", | |
| qtd: 20 | |
| } |
This file contains hidden or 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
| import ReduxThunk from "redux-thunk"; | |
| import reducers from "./appReducers"; | |
| import { applyMiddleware, createStore } from "redux"; | |
| const middleware = [ReduxThunk]; | |
| const store = createStore(reducers, applyMiddleware(...middleware)); | |
| export default store; |
This file contains hidden or 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
| import React, { Component } from "react"; | |
| class App extends Component { | |
| render() { | |
| return ( | |
| <div className="App"> | |
| <header className="App-header">Teste Redux</header> | |
| </div> | |
| ); | |
| } | |
| } |
This file contains hidden or 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
| const express = require('express'); | |
| const httpProxy = require('express-http-proxy'); | |
| const app = express(); | |
| const port = 3000; | |
| const { | |
| USERS_API_URL, | |
| PRODUCTS_API_URL, | |
| } = require('./URLs'); | |
| const userServiceProxy = httpProxy(USERS_API_URL); |
This file contains hidden or 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
| module.exports = { | |
| USERS_API_URL: 'http://localhost:3001', | |
| PRODUCTS_API_URL: 'http://localhost:3002', | |
| }; |
This file contains hidden or 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
| const app = require('express')(); | |
| app.get('/products', (req, res) => res.send('Hello Products API')); | |
| app.listen(3002, () => console.log(`Products API listening on port 3002!`)); |
This file contains hidden or 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
| const app = require('express')(); | |
| app.get('/users', (req, res) => res.send('Hello Users API')); | |
| app.listen(3001, () => console.log(`Users API listening on port 3001!`)); |
NewerOlder