add filtering functionality
This commit is contained in:
parent
65b73a39d9
commit
972bd2470f
|
@ -207,18 +207,17 @@ const useStyles = makeStyles({
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
function CenteredTabs({ pledged, paying, paid }) {
|
function CenteredTabs({ pledged, paying, paid, pledgeType, setPledgeType }) {
|
||||||
const classes = useStyles();
|
const classes = useStyles();
|
||||||
const [value, setValue] = useState(0);
|
|
||||||
|
|
||||||
function handleChange(event, newValue) {
|
function handleChange(event, newValue) {
|
||||||
setValue(newValue);
|
setPledgeType(newValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Paper className={classes.root}>
|
<Paper className={classes.root}>
|
||||||
<Tabs
|
<Tabs
|
||||||
value={value}
|
value={pledgeType}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
indicatorColor="primary"
|
indicatorColor="primary"
|
||||||
textColor="primary"
|
textColor="primary"
|
||||||
|
@ -233,6 +232,7 @@ function CenteredTabs({ pledged, paying, paid }) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function ProjectPledges({classes, match, delegates: _delegates, projectAddedEvents, delegateAddedEvents: _delegateAddedEvents, pledges, authorizedPayments}) {
|
function ProjectPledges({classes, match, delegates: _delegates, projectAddedEvents, delegateAddedEvents: _delegateAddedEvents, pledges, authorizedPayments}) {
|
||||||
|
const [pledgeType, setPledgeType] = useState(0)
|
||||||
const projectId = match.params.id
|
const projectId = match.params.id
|
||||||
const { manifest, delegateProfiles, openSnackBar } = useProjectData(projectId, projectAddedEvents)
|
const { manifest, delegateProfiles, openSnackBar } = useProjectData(projectId, projectAddedEvents)
|
||||||
const delegatePledges = useProfileData(delegateProfiles)
|
const delegatePledges = useProfileData(delegateProfiles)
|
||||||
|
@ -240,18 +240,29 @@ function ProjectPledges({classes, match, delegates: _delegates, projectAddedEven
|
||||||
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)
|
||||||
|
const selectedPledges = {
|
||||||
|
0: pledged,
|
||||||
|
1: paying,
|
||||||
|
2: paid
|
||||||
|
}
|
||||||
console.log('pledges', {pledges, authorizedPayments, enrichedPledges})
|
console.log('pledges', {pledges, authorizedPayments, enrichedPledges})
|
||||||
return (
|
return (
|
||||||
<div className={classes.root}>
|
<div className={classes.root}>
|
||||||
<Title className={classes.title} manifest={manifest} />
|
<Title className={classes.title} manifest={manifest} />
|
||||||
<CenteredTabs pledged={pledged.length} paying={paying.length} paid={paid.length} />
|
<CenteredTabs
|
||||||
|
pledged={pledged.length}
|
||||||
|
paying={paying.length}
|
||||||
|
paid={paid.length}
|
||||||
|
pledgeType={pledgeType}
|
||||||
|
setPledgeType={setPledgeType}
|
||||||
|
/>
|
||||||
<SubmissionSection
|
<SubmissionSection
|
||||||
classes={classes}
|
classes={classes}
|
||||||
profiles={delegateProfiles}
|
profiles={delegateProfiles}
|
||||||
delegatePledges={delegatePledges}
|
delegatePledges={delegatePledges}
|
||||||
projectId={projectId}
|
projectId={projectId}
|
||||||
openSnackBar={openSnackBar}
|
openSnackBar={openSnackBar}
|
||||||
pledges={pledges}
|
pledges={selectedPledges[pledgeType]}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue