add pledge query and fetch
This commit is contained in:
parent
b3ecab0fe4
commit
18077236fd
|
@ -2,6 +2,10 @@ import React, { Fragment } from 'react'
|
||||||
import classnames from 'classnames'
|
import classnames from 'classnames'
|
||||||
import Typography from '@material-ui/core/Typography'
|
import Typography from '@material-ui/core/Typography'
|
||||||
import { makeStyles } from '@material-ui/core/styles'
|
import { makeStyles } from '@material-ui/core/styles'
|
||||||
|
import { useQuery } from '@apollo/react-hooks'
|
||||||
|
import { formatProjectId } from '../utils/project'
|
||||||
|
import { getProfileWithPledges } from './projects/queries'
|
||||||
|
import Loading from './base/Loading'
|
||||||
|
|
||||||
const styles = () => ({
|
const styles = () => ({
|
||||||
main: {
|
main: {
|
||||||
|
@ -12,14 +16,19 @@ const styles = () => ({
|
||||||
tableHeader: {
|
tableHeader: {
|
||||||
color: 'rgba(147, 155, 161, 0.8)',
|
color: 'rgba(147, 155, 161, 0.8)',
|
||||||
fontSize: '0.9rem',
|
fontSize: '0.9rem',
|
||||||
gridRow: '4 / 5'
|
|
||||||
},
|
},
|
||||||
headerStatus: {
|
headerStatus: {
|
||||||
gridColumn: '3 / 12'
|
gridColumn: '3 / 12'
|
||||||
},
|
},
|
||||||
|
rowStatus: {
|
||||||
|
gridColumn: '3 / 12'
|
||||||
|
},
|
||||||
headerAmount: {
|
headerAmount: {
|
||||||
gridColumn: '12 / 30'
|
gridColumn: '12 / 30'
|
||||||
},
|
},
|
||||||
|
rowAmount: {
|
||||||
|
gridColumn: '12 / 30'
|
||||||
|
},
|
||||||
headerId: {
|
headerId: {
|
||||||
gridColumn: '30 / 35'
|
gridColumn: '30 / 35'
|
||||||
},
|
},
|
||||||
|
@ -47,11 +56,32 @@ function TableHeader() {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function Pledges() {
|
function TableRow({ pledge }) {
|
||||||
const classes = useStyles()
|
const classes = useStyles()
|
||||||
|
return (
|
||||||
|
<Fragment>
|
||||||
|
<div className={classes.rowStatus}>{pledge.pledgeState}</div>
|
||||||
|
<div className={classes.rowAmount}>{pledge.amount}</div>
|
||||||
|
</Fragment>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function Pledges({ match }) {
|
||||||
|
const classes = useStyles()
|
||||||
|
const projectId = match.params.id
|
||||||
|
const { loading, error, data } = useQuery(getProfileWithPledges, {
|
||||||
|
variables: { id: formatProjectId(projectId) }
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log({loading, error, data})
|
||||||
|
if (loading) return <Loading />
|
||||||
|
if (error) return <div>{`Error! ${error.message}`}</div>
|
||||||
|
const { pledges } = data.profile
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={classes.main}>
|
<div className={classes.main}>
|
||||||
<TableHeader />
|
<TableHeader />
|
||||||
|
{pledges.map(p => <TableRow key={p.id} pledge={p} />)}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue