add pledge details to dropdown

This commit is contained in:
Barry Gitarts 2019-03-20 15:53:18 -04:00 committed by Barry G
parent 0d874ae881
commit 245fed55db
2 changed files with 12 additions and 2 deletions

View File

@ -8,6 +8,8 @@ import { useProjectData, useProfileData } from './hooks'
import Divider from '@material-ui/core/Divider'
import TextField from '@material-ui/core/TextField'
import MenuItem from '@material-ui/core/MenuItem'
import { toEther } from '../../utils/conversions'
import { getTokenLabel } from '../../utils/currencies'
const styles = theme => ({
root: {
@ -100,7 +102,7 @@ const SubmissionSection = ({ classes, profiles, delegatePledges }) => {
>
{filteredPledges.map(pledge => (
<MenuItem style={{ display: 'flex', alignItems: 'center' }} key={pledge.idPledge} value={pledge.idPledge}>
{`Pledge no: ${pledge.idPledge}`}
{`Pledge no: ${pledge.idPledge} - Amount: ${toEther(pledge.pledgeData.amount)} ${getTokenLabel(pledge.pledgeData.token)}`}
</MenuItem>
))}
</TextField>}

View File

@ -45,6 +45,12 @@ async function getProjectAssets(projectId, setState){
})
}
async function getPledge(dPledge) {
const pledge = await dPledge.pledge.fetch()
dPledge.pledgeData = pledge
return dPledge
}
async function fetchAndAddDelegateProfiles(account, setState) {
const profiles = await getDelegateProfiles(account)
setState(profiles)
@ -57,7 +63,9 @@ async function fetchAndAddDelegatePledges(profiles, setState) {
dPledges.push(delegatePledges)
})
const resolved = await Promise.all(dPledges)
setState(unnest(resolved))
const unnested = unnest(resolved)
const expanded = await Promise.all(unnested.map(getPledge))
setState(expanded)
}
export function useProfileData(profiles) {