cleanup create project
This commit is contained in:
parent
0c6ea227fa
commit
05671c3771
|
@ -9,7 +9,7 @@ import Button from '@material-ui/core/Button'
|
||||||
import InputAdornment from '@material-ui/core/InputAdornment'
|
import InputAdornment from '@material-ui/core/InputAdornment'
|
||||||
import CloudUpload from '@material-ui/icons/CloudUpload'
|
import CloudUpload from '@material-ui/icons/CloudUpload'
|
||||||
import { withStyles } from '@material-ui/core/styles'
|
import { withStyles } from '@material-ui/core/styles'
|
||||||
import { formatForIpfs, uploadToIpfs } from '../../utils/ipfs'
|
import { formatForIpfs, uploadToIpfs, formatMedia, isWeb } from '../../utils/ipfs'
|
||||||
import { FundingContext } from '../../context'
|
import { FundingContext } from '../../context'
|
||||||
|
|
||||||
const { addProject } = LiquidPledging.methods
|
const { addProject } = LiquidPledging.methods
|
||||||
|
@ -65,10 +65,7 @@ const styles = theme => ({
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const isWeb = str => str.includes('http')
|
|
||||||
const formatMedia = str => {
|
|
||||||
return isWeb(str) ? str : `/root/${str}`
|
|
||||||
}
|
|
||||||
const createJSON = values => {
|
const createJSON = values => {
|
||||||
const {
|
const {
|
||||||
title,
|
title,
|
||||||
|
@ -385,7 +382,7 @@ const SubmissionSection = ({ classes, history }) => {
|
||||||
onBlur={handleBlur}
|
onBlur={handleBlur}
|
||||||
value={values.description || ''}
|
value={values.description || ''}
|
||||||
/>
|
/>
|
||||||
<Button type="submit" color="primary" variant="contained" className={classes.formButton}>{isSubmitting ? 'Submission In Progress' : 'Create Project'}</Button>
|
<Button type="submit" color="primary" variant="contained" className={classes.formButton}>{isSubmitting ? 'Ethereum Submission In Progress' : 'Create Project'}</Button>
|
||||||
</form>
|
</form>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@ import { toEther } from '../../utils/conversions'
|
||||||
import { getTokenLabel } from '../../utils/currencies'
|
import { getTokenLabel } from '../../utils/currencies'
|
||||||
import { timeSinceBlock } from '../../utils/dates'
|
import { timeSinceBlock } from '../../utils/dates'
|
||||||
import { getFiles } from '../../utils/ipfs'
|
import { getFiles } from '../../utils/ipfs'
|
||||||
|
import { getImageType } from '../../utils/images'
|
||||||
import { useProjectData } from './hooks'
|
import { useProjectData } from './hooks'
|
||||||
|
|
||||||
const styles = theme => ({
|
const styles = theme => ({
|
||||||
|
@ -153,8 +154,7 @@ const formatMedia = content => {
|
||||||
return src
|
return src
|
||||||
}
|
}
|
||||||
|
|
||||||
const formatAvatar = content => {
|
const formatAvatar = (content, type) => {
|
||||||
const type = 'image/gif'
|
|
||||||
const blob = new Blob([content], {type})
|
const blob = new Blob([content], {type})
|
||||||
const src = URL.createObjectURL(blob)
|
const src = URL.createObjectURL(blob)
|
||||||
return src
|
return src
|
||||||
|
@ -184,8 +184,10 @@ const getAvatarSrc = assets => {
|
||||||
if (!assets) return null
|
if (!assets) return null
|
||||||
const { avatar } = getProjectManifest(assets)
|
const { avatar } = getProjectManifest(assets)
|
||||||
if (avatar.includes('http')) return avatar
|
if (avatar.includes('http')) return avatar
|
||||||
|
const type = getImageType(avatar)
|
||||||
return formatAvatar(
|
return formatAvatar(
|
||||||
assets.find(a => a.name === getFile(avatar)).content
|
assets.find(a => a.name === getFile(avatar)).content,
|
||||||
|
type
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,6 @@ const typeMap = {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getImageType = file => {
|
export const getImageType = file => {
|
||||||
const { name } = file
|
const suffix = file.split('.').slice(-1)[0].toLowerCase()
|
||||||
const suffix = name.split('.').slice(-1)[0].toLowerCase()
|
|
||||||
return typeMap[suffix] ? typeMap[suffix] : 'image/jpeg'
|
return typeMap[suffix] ? typeMap[suffix] : 'image/jpeg'
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,3 +79,8 @@ export const getFiles = CID => {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const isWeb = str => str.includes('http')
|
||||||
|
export const formatMedia = str => {
|
||||||
|
return isWeb(str) ? str : `/root/${str}`
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue