1
0
mirror of https://github.com/franjsco/tick3t synced 2025-01-15 19:00:38 +01:00

refactor: Table component

This commit is contained in:
Francesco Esposito 2019-07-31 15:55:55 +02:00
parent 53f7bda915
commit 91766ed11d

View File

@ -1,26 +1,21 @@
import React, { Component } from 'react'; import React from 'react';
import { import {
Col, Col,
Row, Row,
Table as TableBootstrap Table as TableBootstrap
} from 'reactstrap'; } from 'reactstrap';
import { formatStatus, formatDate } from '../utils/helper';
const tableKeyStyle = { const tableKeyStyle = {
width: '18%', width: '18%',
color: '#45474b' color: '#45474b'
} }
class Table extends Component { const Table = (props) => {
constructor(props) { const data = props.data;
super(props);
this.state = {};
}
render() {
let data = this.props.data;
if (data) {
return ( return (
<Row> <Row>
<Col sm="12" md={{ size: 10, offset: 1 }}> <Col sm="12" md={{ size: 10, offset: 1 }}>
@ -37,16 +32,16 @@ class Table extends Component {
</tr> </tr>
<tr> <tr>
<td style={tableKeyStyle} className="font-weight-bold text-right">status:</td> <td style={tableKeyStyle} className="font-weight-bold text-right">status:</td>
<td className="text-left">{data.status}</td> <td className="text-left">{formatStatus(data.status)}</td>
</tr> </tr>
<tr> <tr>
<td style={tableKeyStyle} className="font-weight-bold text-right">created:</td> <td style={tableKeyStyle} className="font-weight-bold text-right">created:</td>
<td className="text-left">{data.createdAt}</td> <td className="text-left">{formatDate(data.createdAt)}</td>
</tr> </tr>
<tr> <tr>
<td style={tableKeyStyle} className="font-weight-bold text-right">updated:</td> <td style={tableKeyStyle} className="font-weight-bold text-right">updated:</td>
<td className="text-left">{data.updatedAt}</td> <td className="text-left">{formatDate(data.updatedAt)}</td>
</tr> </tr>
<tr> <tr>
<td style={tableKeyStyle} className="font-weight-bold text-right">created by:</td> <td style={tableKeyStyle} className="font-weight-bold text-right">created by:</td>
@ -73,6 +68,8 @@ class Table extends Component {
</Col> </Col>
</Row> </Row>
); );
} else {
return (null);
} }
} }