mirror of
https://github.com/strapi/strapi.git
synced 2025-11-22 21:23:11 +00:00
50 lines
1.0 KiB
JavaScript
50 lines
1.0 KiB
JavaScript
|
|
/**
|
||
|
|
*
|
||
|
|
* Table
|
||
|
|
*
|
||
|
|
*/
|
||
|
|
|
||
|
|
import React from 'react';
|
||
|
|
|
||
|
|
import TableHeader from 'components/TableHeader';
|
||
|
|
import TableRow from 'components/TableRow';
|
||
|
|
|
||
|
|
import styles from './styles.scss';
|
||
|
|
|
||
|
|
class Table extends React.Component { // eslint-disable-line react/prefer-stateless-function
|
||
|
|
render() {
|
||
|
|
const tableRows = this.props.records.map((record, key) => {
|
||
|
|
const destination = this.props.route.path.replace(':slug', this.props.routeParams.slug) + '/' + record.id;
|
||
|
|
|
||
|
|
return (
|
||
|
|
<TableRow
|
||
|
|
key={key}
|
||
|
|
destination={destination}
|
||
|
|
headers={this.props.headers}
|
||
|
|
record={record}
|
||
|
|
/>
|
||
|
|
);
|
||
|
|
});
|
||
|
|
|
||
|
|
return (
|
||
|
|
<table className={`table ${styles.table}`}>
|
||
|
|
<TableHeader
|
||
|
|
headers={this.props.headers}
|
||
|
|
/>
|
||
|
|
<tbody>
|
||
|
|
{tableRows}
|
||
|
|
</tbody>
|
||
|
|
</table>
|
||
|
|
);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
Table.propTypes = {
|
||
|
|
records: React.PropTypes.array,
|
||
|
|
route: React.PropTypes.object,
|
||
|
|
routeParams: React.PropTypes.object,
|
||
|
|
headers: React.PropTypes.array,
|
||
|
|
};
|
||
|
|
|
||
|
|
export default Table;
|