filter out confirmed pledges from paying screen
This commit is contained in:
parent
c0423b10e0
commit
44543271c2
|
@ -192,13 +192,13 @@ const SubmissionSection = ({ classes, openSnackBar, syncWithRemote, pledges, ple
|
||||||
toSend.send({gas: estimatedGas})
|
toSend.send({gas: estimatedGas})
|
||||||
.then(async res => {
|
.then(async res => {
|
||||||
console.log({res})
|
console.log({res})
|
||||||
|
openSnackBar('success', 'Withdraws initiated')
|
||||||
})
|
})
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
openSnackBar('error', 'An error has occured with the transaction')
|
openSnackBar('error', 'An error has occured with the transaction')
|
||||||
console.log({e})
|
console.log({e})
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
openSnackBar('success', 'Withdraws initiated')
|
|
||||||
syncWithRemote()
|
syncWithRemote()
|
||||||
})
|
})
|
||||||
}}
|
}}
|
||||||
|
@ -256,12 +256,12 @@ function CenteredTabs({ pledged, paying, paid, pledgeType, setPledgeType }) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function ProjectPledges({classes, match, projectAddedEvents, pledges, authorizedPayments}) {
|
function ProjectPledges({classes, match, projectAddedEvents, pledges, authorizedPayments, confirmedPayments}) {
|
||||||
const [pledgeType, setPledgeType] = useState(0)
|
const [pledgeType, setPledgeType] = useState(0)
|
||||||
const projectId = match.params.id
|
const projectId = match.params.id
|
||||||
const { manifest, delegateProfiles, openSnackBar, syncWithRemote } = useProjectData(projectId, projectAddedEvents)
|
const { manifest, delegateProfiles, openSnackBar, syncWithRemote } = useProjectData(projectId, projectAddedEvents)
|
||||||
const delegatePledges = useProfileData(delegateProfiles)
|
const delegatePledges = useProfileData(delegateProfiles)
|
||||||
const enrichedPledges = usePledgesAuthorizations(pledges, authorizedPayments).filter(p => Number(p.amount) > 0)
|
const enrichedPledges = usePledgesAuthorizations(pledges, authorizedPayments, confirmedPayments).filter(p => Number(p.amount) > 0)
|
||||||
const pledged = enrichedPledges.filter(p => p.pledgeState === 0)
|
const pledged = enrichedPledges.filter(p => p.pledgeState === 0)
|
||||||
const paying = enrichedPledges.filter(p => p.pledgeState === 1)
|
const paying = enrichedPledges.filter(p => p.pledgeState === 1)
|
||||||
const paid = enrichedPledges.filter(p => p.pledgeState === 2)
|
const paid = enrichedPledges.filter(p => p.pledgeState === 2)
|
||||||
|
@ -310,6 +310,9 @@ export default withDatabase(withObservables([], ({ database, match }) => ({
|
||||||
).observe(),
|
).observe(),
|
||||||
authorizedPayments: database.collections.get('vault_events').query(
|
authorizedPayments: database.collections.get('vault_events').query(
|
||||||
Q.where('event', 'AuthorizePayment')
|
Q.where('event', 'AuthorizePayment')
|
||||||
|
).observe(),
|
||||||
|
confirmedPayments: database.collections.get('vault_events').query(
|
||||||
|
Q.where('event', 'ConfirmPayment')
|
||||||
).observe()
|
).observe()
|
||||||
}))(StyledPledges))
|
}))(StyledPledges))
|
||||||
|
|
||||||
|
|
|
@ -144,11 +144,15 @@ function mergePledgesAuthorizations(pledges, authorizations, setState) {
|
||||||
})
|
})
|
||||||
setState(enriched)
|
setState(enriched)
|
||||||
}
|
}
|
||||||
export function usePledgesAuthorizations(pledges, authorizations) {
|
export function usePledgesAuthorizations(pledges, authorizations, confirmedPayments) {
|
||||||
const [enrichedPledges, setEnrichedPledges] = useState(pledges)
|
const [enrichedPledges, setEnrichedPledges] = useState(pledges)
|
||||||
|
const confirmedIds = confirmedPayments.map(p => p.returnValues.idPayment)
|
||||||
|
const filteredAuths = authorizations.filter(
|
||||||
|
a => !confirmedIds.includes(a.returnValues.idPayment)
|
||||||
|
)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
mergePledgesAuthorizations(pledges, authorizations, setEnrichedPledges)
|
mergePledgesAuthorizations(pledges, filteredAuths, setEnrichedPledges)
|
||||||
}, [pledges, authorizations])
|
}, [pledges, authorizations])
|
||||||
|
|
||||||
return enrichedPledges
|
return enrichedPledges
|
||||||
|
|
Loading…
Reference in New Issue