refactor(components/contracts): move ContractsList into its own component
This is done so we can reuse the contracts list component, without introducing an entire page layout with headline etc.
This commit is contained in:
parent
7690418bb1
commit
35d86beab7
|
@ -1,47 +1,13 @@
|
|||
import PropTypes from "prop-types";
|
||||
import React from 'react';
|
||||
import {
|
||||
Page,
|
||||
Grid,
|
||||
Card,
|
||||
Table
|
||||
} from "tabler-react";
|
||||
import {Link} from 'react-router-dom';
|
||||
import {formatContractForDisplay} from '../utils/presentation';
|
||||
import {Page, Grid} from "tabler-react";
|
||||
import ContractsList from './ContractsList';
|
||||
|
||||
const Contracts = ({contracts, title = "Contracts"}) => (
|
||||
<Page.Content title={title}>
|
||||
<Grid.Row>
|
||||
<Grid.Col>
|
||||
<Card>
|
||||
<Table
|
||||
responsive
|
||||
cards
|
||||
verticalAlign="center"
|
||||
className="text-nowrap">
|
||||
<Table.Header>
|
||||
<Table.Row>
|
||||
<Table.ColHeader>Name</Table.ColHeader>
|
||||
<Table.ColHeader>Address</Table.ColHeader>
|
||||
<Table.ColHeader>State</Table.ColHeader>
|
||||
</Table.Row>
|
||||
</Table.Header>
|
||||
<Table.Body>
|
||||
{
|
||||
contracts.map((contract) => {
|
||||
const contractDisplay = formatContractForDisplay(contract);
|
||||
return (
|
||||
<Table.Row key={contract.className} className={contractDisplay.stateColor}>
|
||||
<Table.Col><Link to={`/embark/contracts/${contract.className}/overview`}>{contract.className}</Link></Table.Col>
|
||||
<Table.Col>{contractDisplay.address}</Table.Col>
|
||||
<Table.Col>{contractDisplay.state}</Table.Col>
|
||||
</Table.Row>
|
||||
);
|
||||
})
|
||||
}
|
||||
</Table.Body>
|
||||
</Table>
|
||||
</Card>
|
||||
<ContractsList contracts={contracts}></ContractsList>
|
||||
</Grid.Col>
|
||||
</Grid.Row>
|
||||
</Page.Content>
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
import PropTypes from "prop-types";
|
||||
import React from 'react';
|
||||
import {Card, Table} from "tabler-react";
|
||||
import {Link} from 'react-router-dom';
|
||||
import {formatContractForDisplay} from '../utils/presentation';
|
||||
|
||||
const ContractsList = ({contracts}) => (
|
||||
<Card>
|
||||
<Table
|
||||
responsive
|
||||
cards
|
||||
verticalAlign="center"
|
||||
className="text-nowrap">
|
||||
<Table.Header>
|
||||
<Table.Row>
|
||||
<Table.ColHeader>Name</Table.ColHeader>
|
||||
<Table.ColHeader>Address</Table.ColHeader>
|
||||
<Table.ColHeader>State</Table.ColHeader>
|
||||
</Table.Row>
|
||||
</Table.Header>
|
||||
<Table.Body>
|
||||
{
|
||||
contracts.map((contract) => {
|
||||
const contractDisplay = formatContractForDisplay(contract);
|
||||
return (
|
||||
<Table.Row key={contract.className} className={contractDisplay.stateColor}>
|
||||
<Table.Col><Link to={`/embark/contracts/${contract.className}/overview`}>{contract.className}</Link></Table.Col>
|
||||
<Table.Col>{contractDisplay.address}</Table.Col>
|
||||
<Table.Col>{contractDisplay.state}</Table.Col>
|
||||
</Table.Row>
|
||||
);
|
||||
})
|
||||
}
|
||||
</Table.Body>
|
||||
</Table>
|
||||
</Card>
|
||||
)
|
||||
|
||||
ContractsList.propTypes = {
|
||||
contracts: PropTypes.array,
|
||||
};
|
||||
|
||||
export default ContractsList;
|
Loading…
Reference in New Issue