create manifest json formatter
This commit is contained in:
parent
dc20621312
commit
3c7124c967
|
@ -54,6 +54,36 @@ const styles = theme => ({
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const createJSON = values => {
|
||||||
|
const {
|
||||||
|
title,
|
||||||
|
subtitle,
|
||||||
|
creator,
|
||||||
|
avatar,
|
||||||
|
goal,
|
||||||
|
goalToken,
|
||||||
|
video,
|
||||||
|
isPlaying,
|
||||||
|
description
|
||||||
|
} = values
|
||||||
|
|
||||||
|
const manifest = {
|
||||||
|
title,
|
||||||
|
subtitle,
|
||||||
|
creator,
|
||||||
|
avatar,
|
||||||
|
goal,
|
||||||
|
goalToken,
|
||||||
|
description,
|
||||||
|
media: {
|
||||||
|
isPlaying,
|
||||||
|
url: video,
|
||||||
|
type: 'video'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return JSON.stringify(manifest)
|
||||||
|
}
|
||||||
|
|
||||||
const Title = ({ className }) => (
|
const Title = ({ className }) => (
|
||||||
<div className={className}>
|
<div className={className}>
|
||||||
<div style={{ alignSelf: 'center' }}>Create Project</div>
|
<div style={{ alignSelf: 'center' }}>Create Project</div>
|
||||||
|
@ -64,8 +94,22 @@ const Title = ({ className }) => (
|
||||||
const SubmissionSection = ({ classes }) => {
|
const SubmissionSection = ({ classes }) => {
|
||||||
return (
|
return (
|
||||||
<Formik
|
<Formik
|
||||||
initialValues={{ projectName: '' }}
|
initialValues={{
|
||||||
onSubmit={console.log}
|
title: '',
|
||||||
|
subtitle: '',
|
||||||
|
creator: '',
|
||||||
|
avatar: '',
|
||||||
|
goal: '',
|
||||||
|
goalToken: '',
|
||||||
|
video: '',
|
||||||
|
isPlaying: false,
|
||||||
|
description: ''
|
||||||
|
}}
|
||||||
|
onSubmit={async (values, { resetForm }) => {
|
||||||
|
const manifest = createJSON(values)
|
||||||
|
console.log({manifest})
|
||||||
|
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
{({
|
{({
|
||||||
values,
|
values,
|
||||||
|
@ -87,15 +131,15 @@ const SubmissionSection = ({ classes }) => {
|
||||||
input: classes.textInput
|
input: classes.textInput
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
id="projectName"
|
id="title"
|
||||||
name="projectName"
|
name="title"
|
||||||
label="Enter Project Name"
|
label="Enter Project Name"
|
||||||
placeholder="Enter Project Name"
|
placeholder="Enter Project Name"
|
||||||
margin="normal"
|
margin="normal"
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
onBlur={handleBlur}
|
onBlur={handleBlur}
|
||||||
value={values.projectName || ''}
|
value={values.title || ''}
|
||||||
/>
|
/>
|
||||||
<TextField
|
<TextField
|
||||||
className={classes.textField}
|
className={classes.textField}
|
||||||
|
@ -104,15 +148,15 @@ const SubmissionSection = ({ classes }) => {
|
||||||
input: classes.textInput
|
input: classes.textInput
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
id="subTitle"
|
id="subtitle"
|
||||||
name="subTitle"
|
name="subtitle"
|
||||||
label="Enter a sub heading description for your project"
|
label="Enter a sub heading description for your project"
|
||||||
placeholder="Enter a sub heading description for your project"
|
placeholder="Enter a sub heading description for your project"
|
||||||
margin="normal"
|
margin="normal"
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
onBlur={handleBlur}
|
onBlur={handleBlur}
|
||||||
value={values.subTitle || ''}
|
value={values.subtitle || ''}
|
||||||
/>
|
/>
|
||||||
<TextField
|
<TextField
|
||||||
className={classes.textField}
|
className={classes.textField}
|
||||||
|
@ -203,10 +247,10 @@ const SubmissionSection = ({ classes }) => {
|
||||||
className={classes.formControl}
|
className={classes.formControl}
|
||||||
control={
|
control={
|
||||||
<Switch
|
<Switch
|
||||||
id="autoPlay"
|
id="isPlaying"
|
||||||
checked={values.autoPlay}
|
checked={values.isPlaying}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
value={values.autoPlay}
|
value={values.isPlaying}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
label="Autoplay video?"
|
label="Autoplay video?"
|
||||||
|
@ -224,7 +268,7 @@ const SubmissionSection = ({ classes }) => {
|
||||||
onBlur={handleBlur}
|
onBlur={handleBlur}
|
||||||
value={values.description || ''}
|
value={values.description || ''}
|
||||||
/>
|
/>
|
||||||
<Button color="primary" variant="contained" className={classes.formButton}>Create Project</Button>
|
<Button type="submit" color="primary" variant="contained" className={classes.formButton}>Create Project</Button>
|
||||||
</form>
|
</form>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue