Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Parse the JSON into a JsonForm data structure and store it in state.
const rawJson = JSON.parse(git.content)
setValuesInGit({ jsonNode, rawJson })
})
.catch((e: any) => {
console.log('FAILED', e)
})
}, [id])
const fields = formOptions.fields || generateFields(valuesOnDisk.rawJson)
// TODO: This may not be necessary.
fields.push({ name: 'jsonNode', component: null })
/* eslint-disable-next-line react-hooks/rules-of-hooks */
const [, form] = useForm(
{
id,
label,
initialValues: valuesInGit,
fields,
onSubmit(data) {
return cms.api.git.onSubmit!({
files: [data.jsonNode.fileRelativePath],
message: data.__commit_message || 'Tina commit',
name: data.__commit_name,
email: data.__commit_email,
})
},
reset() {
return cms.api.git.reset({ files: [id] })
},