mirror of
https://github.com/status-im/liquid-funding.git
synced 2025-01-23 09:50:11 +00:00
add cancelProfiles
This commit is contained in:
parent
9724e8c7e8
commit
4f7a24153c
@ -1,5 +1,8 @@
|
||||
import React, { Fragment, memo } from 'react'
|
||||
import MaterialTable from 'material-table'
|
||||
import LiquidPledgingMock from 'Embark/contracts/LiquidPledgingMock'
|
||||
|
||||
const { cancelProject } = LiquidPledgingMock.methods
|
||||
|
||||
const convertToHours = seconds => seconds / 60 / 60
|
||||
const cancelText = canceled => canceled ? 'Yes' : 'No'
|
||||
@ -8,7 +11,7 @@ const formatField = field => ({
|
||||
commitTime: convertToHours(field.commitTime),
|
||||
canceled: cancelText(field.canceled)
|
||||
})
|
||||
const FunderProfilesTable = ({ data }) => (
|
||||
const FunderProfilesTable = ({ data, cancelFundProfile }) => (
|
||||
<Fragment>
|
||||
<MaterialTable
|
||||
columns={[
|
||||
@ -22,6 +25,20 @@ const FunderProfilesTable = ({ data }) => (
|
||||
]}
|
||||
data={data.map(formatField)}
|
||||
title="Funding Profiles"
|
||||
actions={[
|
||||
{
|
||||
icon: 'cancel',
|
||||
tooltip: 'Cancel',
|
||||
onClick: (event, rowData) => {
|
||||
cancelProject(rowData.idProfile)
|
||||
.send()
|
||||
.then(res => {
|
||||
console.log({res})
|
||||
cancelFundProfile(rowData.idProfile)
|
||||
})
|
||||
}
|
||||
}
|
||||
]}
|
||||
/>
|
||||
</Fragment>
|
||||
)
|
||||
|
@ -13,6 +13,7 @@ import { initVaultAndLP, vaultPledgingNeedsInit, standardTokenApproval, getLpAll
|
||||
import { getProfileEvents, formatFundProfileEvent } from './utils/events';
|
||||
import { getAllPledges, appendToExistingPledges, transferBetweenPledges } from './utils/pledges';
|
||||
import { FundingContext } from './context'
|
||||
import { cancelProfile } from './utils/fundProfiles'
|
||||
|
||||
const { getNetworkType } = web3.eth.net;
|
||||
|
||||
@ -62,15 +63,19 @@ class App extends React.Component {
|
||||
transferBetweenPledges(this.setState.bind(this), tx)
|
||||
}
|
||||
|
||||
cancelFundProfile = id => {
|
||||
this.setState((state) => cancelProfile(state, id))
|
||||
}
|
||||
|
||||
render() {
|
||||
const { needsInit, lpAllowance, fundProfiles, allPledges } = this.state;
|
||||
const { appendFundProfile, appendPledges, transferPledgeAmounts } = this
|
||||
const { appendFundProfile, appendPledges, transferPledgeAmounts, cancelFundProfile } = this
|
||||
const fundingContext = { transferPledgeAmounts }
|
||||
return (
|
||||
<FundingContext.Provider value={fundingContext}>
|
||||
<div>
|
||||
{allPledges && <PledgesTable data={allPledges} transferPledgeAmounts={transferPledgeAmounts} />}
|
||||
{fundProfiles && <FunderProfilesTable data={fundProfiles} />}
|
||||
{fundProfiles && <FunderProfilesTable data={fundProfiles} cancelFundProfile={cancelFundProfile}/>}
|
||||
<AddFunder appendFundProfile={appendFundProfile} />
|
||||
<Divider variant="middle" />
|
||||
<CreateFunding refreshTable={appendPledges} />
|
||||
|
10
app/utils/fundProfiles.js
Normal file
10
app/utils/fundProfiles.js
Normal file
@ -0,0 +1,10 @@
|
||||
import { evolve, map, when, propEq, set, lensProp } from 'ramda'
|
||||
|
||||
export const cancelProfile = (state, id) => {
|
||||
const updateMatch = when(
|
||||
propEq('idProfile', id),
|
||||
set(lensProp('canceled'), true)
|
||||
)
|
||||
const transformation = { fundProfiles: map(updateMatch) }
|
||||
return evolve(transformation, state)
|
||||
}
|
@ -60,6 +60,7 @@
|
||||
"eth-contract-class": "^0.0.12",
|
||||
"formik": "^1.3.2",
|
||||
"material-table": "^1.3.0",
|
||||
"ramda": "^0.26.1",
|
||||
"react": "^16.6.3",
|
||||
"react-dom": "^16.6.3"
|
||||
}
|
||||
|
@ -5511,6 +5511,11 @@ quick-lru@^1.0.0:
|
||||
version "1.1.0"
|
||||
resolved "https://registry.yarnpkg.com/quick-lru/-/quick-lru-1.1.0.tgz#4360b17c61136ad38078397ff11416e186dcfbb8"
|
||||
|
||||
ramda@^0.26.1:
|
||||
version "0.26.1"
|
||||
resolved "https://registry.yarnpkg.com/ramda/-/ramda-0.26.1.tgz#8d41351eb8111c55353617fc3bbffad8e4d35d06"
|
||||
integrity sha512-hLWjpy7EnsDBb0p+Z3B7rPi3GDeRG5ZtiI33kJhTt+ORCd38AbAIjB/9zRIUoeTbE/AVX5ZkU7m6bznsvrf8eQ==
|
||||
|
||||
random-bytes@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/random-bytes/-/random-bytes-1.0.0.tgz#4f68a1dc0ae58bd3fb95848c30324db75d64360b"
|
||||
|
Loading…
x
Reference in New Issue
Block a user