@@ -12,7 +12,7 @@ import RenderedQuestion from "../../components/Question";
1212import Loading from "../../components/Loading" ;
1313import ScrollToTop from "../../components/ScrollToTop" ;
1414
15- import { Form , FormFeatures , getForm } from "../../api/forms" ;
15+ import { Form , FormFeatures , FormWithAncillaryData , getForm } from "../../api/forms" ;
1616import { OAuthScopes } from "../../api/auth" ;
1717import colors from "../../colors" ;
1818import { unselectable } from "../../commonStyles" ;
@@ -22,6 +22,7 @@ import Navigation from "./Navigation";
2222import Success from "./SuccessPage" ;
2323import ErrorPage from "./ErrorPage" ;
2424import NotFound from "../NotFound" ;
25+ import PrecheckBox from "../../components/PrecheckBox" ;
2526
2627
2728export type RefMapType = Map < string , React . RefObject < RenderedQuestion > > ;
@@ -37,21 +38,6 @@ const formStyles = css`
3738 }
3839` ;
3940
40- const closedHeaderStyles = css `
41- margin-bottom : 2rem ;
42- padding : 1rem 4rem ;
43- border-radius : 8px ;
44-
45- text-align : center;
46- font-size : 1.5rem ;
47-
48- background-color : ${ colors . error } ;
49-
50- @media (max-width : 500px ) {
51- padding : 1rem 1.5rem ;
52- }
53- ` ;
54-
5541enum LoadingState {
5642 Pending ,
5743 Found ,
@@ -61,7 +47,7 @@ enum LoadingState {
6147function FormPage ( ) : JSX . Element {
6248 const { id} = useParams < { id : string } > ( ) ;
6349
64- const [ form , setForm ] = useState < Form > ( ) ;
50+ const [ form , setForm ] = useState < FormWithAncillaryData > ( ) ;
6551 const [ formLoading , setFormLoading ] = useState < LoadingState > ( LoadingState . Pending ) ;
6652 const [ state , setState ] = useState < string > ( FormState . INITIAL ) ;
6753
@@ -106,11 +92,9 @@ function FormPage(): JSX.Element {
10692 }
10793 }
10894
109- const open : boolean = form . features . includes ( FormFeatures . Open ) ;
110- let closed_header = null ;
111- if ( ! open ) {
112- closed_header =
113- < div css = { closedHeaderStyles } > This form is now closed. You will not be able to submit your response.</ div > ;
95+ const prechecks : JSX . Element [ ] = [ ] ;
96+ for ( const precheck of form . submission_precheck . problems ) {
97+ prechecks . push ( < PrecheckBox message = { precheck . message } severity = { precheck . severity } key = { precheck . message } /> ) ;
11498 }
11599
116100 const questions : RenderedQuestion [ ] = form . questions . map ( ( question , index ) => {
@@ -156,11 +140,11 @@ function FormPage(): JSX.Element {
156140 < div >
157141 < form id = "form" onSubmit = { handler } css = { [ formStyles , unselectable ] } >
158142 < >
159- { closed_header }
143+ { ... prechecks }
160144 { questions }
161145 </ >
162146 </ form >
163- < Navigation form_state = { open } scopes = { scopes } />
147+ < Navigation can_submit = { form . submission_precheck . can_submit } scopes = { scopes } />
164148 </ div >
165149
166150 < div css = { css `margin-bottom : 10rem ` } />
0 commit comments