add display date

This commit is contained in:
Barry Gitarts 2019-08-20 20:58:04 -04:00 committed by Barry G
parent 9a9510f5cb
commit 119e51216e
3 changed files with 11 additions and 2 deletions

View File

@ -9,6 +9,7 @@ import Loading from '../base/Loading'
import { convertTokenAmountUsd, percentToGoal } from '../../utils/prices'
import { getTokenLabel } from '../../utils/currencies'
import { getAmountFromWei } from '../../utils/pledges'
import { getDateFromTimestamp } from '../../utils/dates'
import { FundingContext } from '../../context'
function FundingDetail({ classes, pledgesInfos, goal, goalToken }) {
@ -54,14 +55,16 @@ function ListProjects({ classes }) {
<Typography className={classnames(tableHeader, classes.headerContact)}>Contact person</Typography>
<Typography className={classnames(tableHeader, classes.dateCreated)}>Date created</Typography>
{profiles.map((profile, i) => {
const { id, projectInfo: { title, subtitle, goal, goalToken, creator }, pledgesInfos } = profile
const { id, projectInfo: { title, subtitle, goal, goalToken, creator, creationTime }, pledgesInfos } = profile
console.log({i, profile})
const creationDate = getDateFromTimestamp(creationTime)
return (
<Fragment key={id}>
<Typography className={classnames(classes.headerName, cellText)}>{title}</Typography>
<Typography className={classnames(classes.headerDescription, cellText, classes.cellDescription)}>{subtitle}</Typography>
<FundingDetail classes={classes} pledgesInfos={pledgesInfos} goal={goal} goalToken={goalToken} />
<Typography className={classnames(classes.headerContact, cellText, classes.cellDescription)}>{creator}</Typography>
<Typography className={classnames(classes.dateCreated, cellText, classes.cellDescription)}>{creationDate}</Typography>
</Fragment>
)
})}

View File

@ -45,6 +45,7 @@ query Projects($type: String! = "PROJECT"){
type
url
profileId
creationTime
projectInfo {
id
title

View File

@ -22,7 +22,12 @@ export function timeSinceBlock(date=false, interval) {
export function getDateCreated(daysSince) {
const d = new Date();
d.setDate(d.getDate() - daysSince);
return `${d.getMonth()}/${d.getDate()}/${d.getFullYear()}`
return `${d.getMonth()+1}/${d.getDate()}/${d.getFullYear()}`
}
export function getDateFromTimestamp(ts) {
const daysSince = timeSinceBlock(ts, 'days')
return getDateCreated(daysSince)
}
export const convertToHours = seconds => Number(seconds) / 60 / 60