diff --git a/src/components/projects/CreateProject.jsx b/src/components/projects/CreateProject.jsx index 6a086d2..034decd 100644 --- a/src/components/projects/CreateProject.jsx +++ b/src/components/projects/CreateProject.jsx @@ -250,7 +250,7 @@ const SubmissionSection = ({ classes, history }) => { setSubmissionState(CONFIRMED) openSnackBar('success', addProjectSucessMsg(res)) setTimeout(() => { - history.push(`/fund-project/${getProjectId(res)}`) + history.push(`/fund-project/${getProjectId(res)}?new=true`) resetForm() }, 5000) }) diff --git a/src/components/projects/FundProject.jsx b/src/components/projects/FundProject.jsx index ec4ade9..e21a913 100644 --- a/src/components/projects/FundProject.jsx +++ b/src/components/projects/FundProject.jsx @@ -3,6 +3,7 @@ import { Formik } from 'formik' import { makeStyles } from '@material-ui/core/styles' import classnames from 'classnames' import idx from 'idx' +import queryString from 'query-string' import { useQuery } from '@apollo/react-hooks' import LiquidPledging from '../../embarkArtifacts/contracts/LiquidPledging' import SwapProxy from '../../embarkArtifacts/contracts/SwapProxy' @@ -73,7 +74,6 @@ async function stepperProgress(values, projectData, submissionState, currencies) const sanitizedAmount = amount.replace(/\D/g,'') const weiAmount = sanitizedAmount ? chainReadibleFn(sanitizedAmount) : '0' const isAuthorized = Number(authorization) >= Number(weiAmount) - console.log({submissionState, isAuthorized, weiAmount, authorization}) if (!isAuthorized) return NOT_APPROVED return IS_APPROVED } @@ -300,9 +300,10 @@ const SubmissionSection = ({ classes, projectData, projectId, profileData, start ) } -function FundProject({ match, history }) { +function FundProject({ match, history, location: { search } }) { const projectId = match.params.id const classes = useStyles() + const [queryParams, setQueryParams] = useState({}) const { account, currencies } = useContext(FundingContext) const { loading, error, data, stopPolling, startPolling, client } = useQuery(getProfileById, { variables: { id: formatProjectId(projectId) } @@ -313,7 +314,20 @@ function FundProject({ match, history }) { stopPolling() }, [data]) - if (loading || !currencies) return + useEffect(() => { + const queryParams = queryString.parse(search) + if (queryParams.new) { + startPolling(3000) + setQueryParams({ ...queryParams }) + } + + if (data && data.profile) { + stopPolling() + return setQueryParams({}) + } + }, [data && data.profile]) + + if (loading || !currencies || queryParams.new) return if (error) return
{`Error! ${error.message}`}
if(!data.profile) return Project Not Found const isCreator = projectData.creator === account