mirror of
https://github.com/status-im/liquid-funding.git
synced 2025-01-26 11:20:48 +00:00
add project query
This commit is contained in:
parent
cc2c2a073a
commit
309d301938
@ -1,6 +1,7 @@
|
|||||||
import React, { useContext, useMemo } from 'react'
|
import React, { useContext, useMemo } from 'react'
|
||||||
import { Formik } from 'formik'
|
import { Formik } from 'formik'
|
||||||
import classnames from 'classnames'
|
import classnames from 'classnames'
|
||||||
|
import { useQuery } from '@apollo/react-hooks'
|
||||||
import LiquidPledging from '../../embarkArtifacts/contracts/LiquidPledging'
|
import LiquidPledging from '../../embarkArtifacts/contracts/LiquidPledging'
|
||||||
import Button from '@material-ui/core/Button'
|
import Button from '@material-ui/core/Button'
|
||||||
import Typography from '@material-ui/core/Typography'
|
import Typography from '@material-ui/core/Typography'
|
||||||
@ -14,11 +15,12 @@ import Icon from '../base/icons/IconByName'
|
|||||||
import { convertTokenAmountUsd } from '../../utils/prices'
|
import { convertTokenAmountUsd } from '../../utils/prices'
|
||||||
import { getAmountsPledged } from '../../utils/pledges'
|
import { getAmountsPledged } from '../../utils/pledges'
|
||||||
import { useProjectData } from './hooks'
|
import { useProjectData } from './hooks'
|
||||||
import { getMediaType, getMediaSrc } from '../../utils/project'
|
import { getMediaType, getMediaSrc, formatProjectId } from '../../utils/project'
|
||||||
import { getDateCreated, convertToHours } from '../../utils/dates'
|
import { getDateCreated, convertToHours } from '../../utils/dates'
|
||||||
import { getTokenLabel, getTokenByAddress } from '../../utils/currencies'
|
import { getTokenLabel, getTokenByAddress } from '../../utils/currencies'
|
||||||
import MediaView from '../base/MediaView'
|
import MediaView from '../base/MediaView'
|
||||||
import StatusTextField from '../base/TextField'
|
import StatusTextField from '../base/TextField'
|
||||||
|
import { getProfileById } from './queries'
|
||||||
|
|
||||||
const { addGiverAndDonate } = LiquidPledging.methods
|
const { addGiverAndDonate } = LiquidPledging.methods
|
||||||
|
|
||||||
@ -203,7 +205,6 @@ const SubmissionSection = ({ classes, projectData, projectId, pledges, commitTim
|
|||||||
const totalPledged = amountsPledged[0] ? amountsPledged[0][1] : 0
|
const totalPledged = amountsPledged[0] ? amountsPledged[0][1] : 0
|
||||||
const percentToGoal = manifest ? (Number(totalPledged) / Number(manifest.goal)) * 100 : 0
|
const percentToGoal = manifest ? (Number(totalPledged) / Number(manifest.goal)) * 100 : 0
|
||||||
const isCreator = projectData.creator === account
|
const isCreator = projectData.creator === account
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Formik
|
<Formik
|
||||||
initialValues={{
|
initialValues={{
|
||||||
@ -333,6 +334,12 @@ const SubmissionSection = ({ classes, projectData, projectId, pledges, commitTim
|
|||||||
function FundProject({ classes, match, history, projectAddedEvents, pledges, profile }) {
|
function FundProject({ classes, match, history, projectAddedEvents, pledges, profile }) {
|
||||||
const projectId = match.params.id
|
const projectId = match.params.id
|
||||||
const projectData = useProjectData(projectId, projectAddedEvents)
|
const projectData = useProjectData(projectId, projectAddedEvents)
|
||||||
|
const { loading, error, data } = useQuery(getProfileById, {
|
||||||
|
variables: { id: formatProjectId(projectId) }
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log({loading,error,data})
|
||||||
|
|
||||||
const commitTime = convertToHours(profile[0].commitTime)
|
const commitTime = convertToHours(profile[0].commitTime)
|
||||||
return (
|
return (
|
||||||
<div className={classes.root}>
|
<div className={classes.root}>
|
||||||
|
15
src/components/projects/queries.js
Normal file
15
src/components/projects/queries.js
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
import { gql } from 'apollo-boost'
|
||||||
|
|
||||||
|
export const getProfileById = gql`
|
||||||
|
query Profile($id: ID!){
|
||||||
|
profile(id: $id) {
|
||||||
|
id
|
||||||
|
addr
|
||||||
|
commitTime
|
||||||
|
url,
|
||||||
|
profileId,
|
||||||
|
type,
|
||||||
|
name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
@ -5,7 +5,7 @@ import EmbarkJS from './embarkArtifacts/embarkjs'
|
|||||||
import LiquidPledging from './embarkArtifacts/contracts/LiquidPledging'
|
import LiquidPledging from './embarkArtifacts/contracts/LiquidPledging'
|
||||||
import Snackbar from '@material-ui/core/Snackbar'
|
import Snackbar from '@material-ui/core/Snackbar'
|
||||||
import { ApolloProvider } from '@apollo/react-hooks'
|
import { ApolloProvider } from '@apollo/react-hooks'
|
||||||
import ApolloClient, { gql } from 'apollo-boost'
|
import ApolloClient from 'apollo-boost'
|
||||||
import { initVaultAndLP, vaultPledgingNeedsInit, standardTokenApproval } from './utils/initialize'
|
import { initVaultAndLP, vaultPledgingNeedsInit, standardTokenApproval } from './utils/initialize'
|
||||||
import { getAuthorizedPayments } from './utils/events'
|
import { getAuthorizedPayments } from './utils/events'
|
||||||
import { FundingContext } from './context'
|
import { FundingContext } from './context'
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
|
/*global web3*/
|
||||||
import { uniqBy, length } from 'ramda'
|
import { uniqBy, length } from 'ramda'
|
||||||
|
|
||||||
|
const { utils } = web3
|
||||||
|
|
||||||
|
export const formatProjectId = id => utils.toHex(id)
|
||||||
const getFile = filePath => filePath.split('/').slice(-1)[0]
|
const getFile = filePath => filePath.split('/').slice(-1)[0]
|
||||||
const formatMedia = content => {
|
const formatMedia = content => {
|
||||||
const type = 'video/mp4'
|
const type = 'video/mp4'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user