liquid-funding/app/components/FunderProfilesTable.jsx

47 lines
1.4 KiB
React
Raw Normal View History

2018-12-02 08:24:31 -05:00
import React, { Fragment, memo } from 'react'
import MaterialTable from 'material-table'
2018-12-07 09:47:00 -05:00
import LiquidPledgingMock from 'Embark/contracts/LiquidPledgingMock'
const { cancelProject } = LiquidPledgingMock.methods
2018-12-02 08:24:31 -05:00
const convertToHours = seconds => seconds / 60 / 60
const cancelText = canceled => canceled ? 'Yes' : 'No'
const formatField = field => ({
...field,
commitTime: convertToHours(field.commitTime),
canceled: cancelText(field.canceled)
})
2018-12-07 09:47:00 -05:00
const FunderProfilesTable = ({ data, cancelFundProfile }) => (
2018-12-02 08:24:31 -05:00
<Fragment>
<MaterialTable
columns={[
2018-12-03 08:50:15 -05:00
{ title: 'Profile Id', field: 'idProfile', type: 'numeric' },
2018-12-02 08:24:31 -05:00
{ title: 'Name', field: 'name' },
{ title: 'Url', field: 'url' },
{ title: 'Admin Address', field: 'addr'},
2018-12-02 08:24:31 -05:00
{ title: 'Commit Time', field: 'commitTime', type: 'numeric' },
2018-12-03 08:50:15 -05:00
{ title: 'Type', field: 'type' },
2018-12-02 09:46:20 -05:00
{ title: 'Canceled', field: 'canceled' }
2018-12-02 08:24:31 -05:00
]}
data={data.map(formatField)}
title="Funding Profiles"
2018-12-07 09:47:00 -05:00
actions={[
{
icon: 'cancel',
tooltip: 'Cancel',
onClick: (event, rowData) => {
cancelProject(rowData.idProfile)
.send()
.then(res => {
console.log({res})
cancelFundProfile(rowData.idProfile)
})
}
}
]}
2018-12-02 08:24:31 -05:00
/>
</Fragment>
)
export default memo(FunderProfilesTable)