diff --git a/assets/src/scripts/components/CodelistBuilder.jsx b/assets/src/scripts/components/CodelistBuilder.jsx index 8e6b754a..a6d73654 100644 --- a/assets/src/scripts/components/CodelistBuilder.jsx +++ b/assets/src/scripts/components/CodelistBuilder.jsx @@ -137,11 +137,6 @@ class CodelistBuilder extends React.Component { return counts; } - complete() { - const counts = this.counts(); - return counts["!"] === 0 && counts["?"] === 0; - } - render() { const moreInfoModal = this.state.moreInfoModalCode && @@ -151,9 +146,7 @@ class CodelistBuilder extends React.Component { <> - {this.props.isEditable && ( - - )} + {this.props.isEditable && }

Summary

diff --git a/assets/src/scripts/components/ManagementForm.jsx b/assets/src/scripts/components/ManagementForm.jsx index 14cc3f57..5b44c249 100644 --- a/assets/src/scripts/components/ManagementForm.jsx +++ b/assets/src/scripts/components/ManagementForm.jsx @@ -1,4 +1,4 @@ -import React, { useState } from "react"; +import React, { useEffect, useState } from "react"; import { Button, ButtonGroup, @@ -9,8 +9,19 @@ import { } from "react-bootstrap"; import { getCookie } from "../_utils"; -export default function ManagementForm({ complete }) { +export default function ManagementForm({ counts }) { const [showDiscardModal, setShowDiscardModal] = useState(false); + const [isComplete, setIsComplete] = useState(false); + + useEffect( + function calculateCounts() { + if (counts["!"] === 0 && counts["?"] === 0) { + return setIsComplete(true); + } + return setIsComplete(false); + }, + [counts], + ); return ( <> @@ -23,7 +34,7 @@ export default function ManagementForm({ complete }) { /> - {complete ? ( + {isComplete ? (