|
@@ -0,0 +1,80 @@
|
|
|
+import React, { Component } from 'react'
|
|
|
+import Base from '../common/Base'
|
|
|
+import Paper from 'material-ui/Paper'
|
|
|
+import Table, { TableHead, TableBody, TableRow, TableCell } from 'material-ui/Table'
|
|
|
+import { get } from '../../actions'
|
|
|
+import { REQUEST } from '../../constants/ResourceNames'
|
|
|
+import { connect } from 'react-redux'
|
|
|
+import { withStyles } from 'material-ui/styles'
|
|
|
+
|
|
|
+const styles = theme => ({
|
|
|
+ root: {}
|
|
|
+})
|
|
|
+
|
|
|
+class RequestsList extends Component {
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ */
|
|
|
+ componentDidMount() {
|
|
|
+ this.props.loadData()
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ */
|
|
|
+ render() {
|
|
|
+ return (
|
|
|
+ <Base title={this.props.title}>
|
|
|
+ <Paper>
|
|
|
+ <Table>
|
|
|
+ <TableHead>
|
|
|
+ <TableRow>
|
|
|
+ <TableCell>Nombre</TableCell>
|
|
|
+ <TableCell>Estado</TableCell>
|
|
|
+ <TableCell>Fecha</TableCell>
|
|
|
+ </TableRow>
|
|
|
+ </TableHead>
|
|
|
+ <TableBody>
|
|
|
+ {this.props.data.map(item =>
|
|
|
+ <TableRow key={item.id}>
|
|
|
+ <TableCell>{item.name}</TableCell>
|
|
|
+ <TableCell>{item.status[1]}</TableCell>
|
|
|
+ <TableCell>{item.create_at}</TableCell>
|
|
|
+ </TableRow>
|
|
|
+ )}
|
|
|
+ </TableBody>
|
|
|
+ </Table>
|
|
|
+ </Paper>
|
|
|
+ </Base>
|
|
|
+ )
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ *
|
|
|
+ * @param {*} state
|
|
|
+ * @param {*} props
|
|
|
+ */
|
|
|
+const mapStateToProps = (state, props) => {
|
|
|
+ return {
|
|
|
+ data: state.requests
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ *
|
|
|
+ * @param {*} dispatch
|
|
|
+ * @param {*} props
|
|
|
+ */
|
|
|
+const mapDispatchToProps = (dispatch, props) => ({
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ */
|
|
|
+ loadData() {
|
|
|
+ dispatch(get(`${REQUEST}`))
|
|
|
+ },
|
|
|
+})
|
|
|
+
|
|
|
+RequestsList = withStyles(styles)(RequestsList)
|
|
|
+
|
|
|
+export default connect(mapStateToProps, mapDispatchToProps)(RequestsList)
|