Last active
January 15, 2018 22:33
-
-
Save devalexandre/73ceb0e17c457c73f23ba471ae1b3dce to your computer and use it in GitHub Desktop.
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
import React, { Component } from "react"; | |
import axios from "axios"; | |
import Cardcalls from "../components/cardcalls/cardcalls"; | |
import ModalCall from "../components/modals/modalcalls"; | |
import { Grid, Loader, Dimmer } from "semantic-ui-react"; | |
import { connect } from 'react-redux' | |
import {bindActionCreators} from 'redux' | |
import { featchCalls } from '../actions/callsAction' | |
class Calls extends Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
calls: [], | |
loader: false, | |
selectd: null | |
}; | |
} | |
componentDidMount() { | |
let vm = this; | |
this.setState({ loader: true }); | |
setInterval(() => { | |
this.props.featchCalls | |
.then(res => { | |
console.log(res.data, "data"); | |
const calls = res.data; | |
vm.setState(state => ({ ...state, calls })); | |
vm.setState(state => ({ ...state, loader: false })); | |
}); | |
}, 3000); | |
} | |
selecionarCall(call) { | |
this.state(state => ({ ...state, selectd: call })); | |
} | |
render() { | |
const calls = this.state.calls.map((call, index) => ( | |
<Grid.Column key={call.id}> | |
<Cardcalls data={call} key={index} | |
/> | |
</Grid.Column> | |
)); | |
return [ | |
<h2 key="1">Chamados</h2>, | |
<Dimmer key="2" active={this.state.loader} inverted> | |
<Loader size="large">Carregando Dados</Loader> | |
</Dimmer>, | |
<Grid key="3" columns={4} stackable> | |
{calls} | |
</Grid> | |
]; | |
} | |
} | |
function mapDispatchToProps(dispatch){ | |
return bindActionCreators({featchCalls}, dispatch) | |
} | |
export default connect(null,mapDispatchToProps)(Calls); |
Outra coisa é que sua função se chama featchCalls, tem um a
a mais no meio, acho que vc quer fetch
apenas.
deu certo felquis, mapiei o metodo e não o stado
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
linha 61