From 2c21f9fe0c193c662f3f13fe2908aa81a3dea6b7 Mon Sep 17 00:00:00 2001 From: Barry Gitarts Date: Fri, 15 Nov 2019 14:21:37 -0500 Subject: [PATCH] add link to withdraw pledges --- src/components/Pledges.jsx | 6 +++--- src/components/projects/FundProject.jsx | 7 +++++++ src/components/projects/styles/FundProject.js | 7 +++++++ src/utils/currencies.js | 2 +- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/components/Pledges.jsx b/src/components/Pledges.jsx index fc83108..f4a2890 100644 --- a/src/components/Pledges.jsx +++ b/src/components/Pledges.jsx @@ -132,7 +132,7 @@ function Pledges({ match }) { const [selectedPledges, setSelected] = useState([]) const [submitted, setSubmitted] = useState(false) const [confirmed, setConfirmed] = useState(false) - const { openSnackBar } = useContext(FundingContext) + const { openSnackBar, currencies } = useContext(FundingContext) const projectId = match.params.id const { loading, error, data, startPolling, stopPolling } = useQuery(getProfileWithPledges, { variables: { id: formatProjectId(projectId) } @@ -145,8 +145,8 @@ function Pledges({ match }) { if (error) return
{`Error! ${error.message}`}
const { pledges, projectInfo: { goalToken } } = data.profile - const amtFormatter = getHumanAmountFormatter(goalToken) - const tokenLabel = getTokenLabel(goalToken) + const amtFormatter = getHumanAmountFormatter(goalToken, currencies) + const tokenLabel = getTokenLabel(goalToken, currencies) const allSelected = selectedPledges.length === pledges.length const selectAll = () => { if (allSelected) return setSelected([]) diff --git a/src/components/projects/FundProject.jsx b/src/components/projects/FundProject.jsx index 3e39fd4..86714f3 100644 --- a/src/components/projects/FundProject.jsx +++ b/src/components/projects/FundProject.jsx @@ -5,6 +5,7 @@ import classnames from 'classnames' import { useQuery } from '@apollo/react-hooks' import LiquidPledging from '../../embarkArtifacts/contracts/LiquidPledging' import SwapProxy from '../../embarkArtifacts/contracts/SwapProxy' +import { Link } from 'react-router-dom' import Typography from '@material-ui/core/Typography' import { FundingContext } from '../../context' import TextDisplay from '../base/TextDisplay' @@ -317,6 +318,12 @@ function FundProject({ match, history }) { profileData={data.profile} startPolling={startPolling} /> + {!!Number(data.profile.pledgesInfos[0].lifetimeReceived) &&
+ This project received pledges. You have funds available to withdraw. + + + +
} ) } diff --git a/src/components/projects/styles/FundProject.js b/src/components/projects/styles/FundProject.js index ac659f8..35e5342 100644 --- a/src/components/projects/styles/FundProject.js +++ b/src/components/projects/styles/FundProject.js @@ -145,6 +145,9 @@ const styles = theme => ({ marginTop: '15px', color: '#4360DF' }, + link:{ + textDecoration: 'none' + }, secondHalf: { display: 'grid', gridTemplateColumns: 'repeat(12, [col] 1fr)', @@ -187,6 +190,10 @@ const styles = theme => ({ preview: { fontSize: '20px' }, + pledgesLink: { + gridColumn: '5 / 10', + textAlign: 'center', + }, contact: { gridColumnStart: '1', gridColumnEnd: '6' diff --git a/src/utils/currencies.js b/src/utils/currencies.js index 14723a4..64f9d89 100644 --- a/src/utils/currencies.js +++ b/src/utils/currencies.js @@ -50,7 +50,7 @@ export const currencies = [ ] export const getTokenByAddress = (value, currencies = currencies) => currencies.find(currency => currency.value.toLowerCase() === value.toLowerCase()) -export const getHumanAmountFormatter = tokenAddress => getTokenByAddress(tokenAddress).humanReadibleFn +export const getHumanAmountFormatter = (tokenAddress, currencies = currencies) => getTokenByAddress(tokenAddress, currencies).humanReadibleFn export const getTokenLabel = (value, currencies = currencies) => { const token = getTokenByAddress(value, currencies) return token ? token.label : null