Commit 965dcdd1 authored by Yannis Barlas's avatar Yannis Barlas

feat(submission form): show confirmation modal on initial submission

parent bdae8976
......@@ -87,72 +87,65 @@ const SubmissionForm = props => {
const initial = isInitialSubmissionReady(status)
const full = isFullSubmissionReady(status)
const initialSubmissionState = !initial
const dataTypeSelectionState = initial && !datatypeSelected
const fullSubmissionState = initial && datatypeSelected && !full
return (
<React.Fragment>
<InitialSubmission readOnly={readOnly} values={values} {...props} />
{initial && (
{dataTypeSelectionState && (
<DatatypeSelect article={article} values={values} {...props} />
)}
{datatypeSelected &&
{fullSubmissionState &&
values.dataType === 'geneExpression' && (
<Authorize object={article} operation="isAuthor" unauthorized={null}>
<GeneExpressionForm readOnly={readOnly} {...props} />
</Authorize>
)}
{!full && (
<React.Fragment>
<Toggle initial={false}>
<Toggle initial={false}>
{({ on, toggle }) => (
<React.Fragment>
<Button onClick={toggle}>Preview</Button>
<ArticlePreviewModal
isOpen={on}
onRequestClose={toggle}
values={values}
/>
</React.Fragment>
)}
</Toggle>
{(initialSubmissionState || fullSubmissionState) &&
isValid && (
<Toggle intial={false}>
{({ on, toggle }) => (
<React.Fragment>
<Button onClick={toggle}>Preview</Button>
<ArticlePreviewModal
<Button
/* disabled={dirty && !isValid} */
onClick={toggle}
primary
>
Submit
</Button>
<SubmissionConfirmationModal
isOpen={on}
onConfirm={handleSubmit}
onRequestClose={toggle}
values={values}
/>
</React.Fragment>
)}
</Toggle>
)}
{!datatypeSelected && (
<Button /* disabled={dirty && !isValid} */ primary type="submit">
Submit
</Button>
)}
{datatypeSelected &&
!isValid && (
<Button primary type="submit">
Submit
</Button>
)}
{datatypeSelected &&
isValid && (
<Toggle initial={false}>
{({ on, toggle }) => (
<React.Fragment>
<Button
// disabled={dirty && !isValid}
onClick={toggle}
primary
>
Submit
</Button>
<SubmissionConfirmationModal
isOpen={on}
onConfirm={handleSubmit}
onRequestClose={toggle}
/>
</React.Fragment>
)}
</Toggle>
)}
</React.Fragment>
{(dataTypeSelectionState || !isValid) && (
<Button primary type="submit">
Submit
</Button>
)}
</React.Fragment>
)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment