1
- import { FC , Fragment , useState } from 'react' ;
1
+ import { FC , Fragment , useEffect , useState } from 'react' ;
2
2
import { useTranslation } from 'react-i18next' ;
3
3
import { newElection } from 'components/utils/Endpoints' ;
4
4
@@ -17,6 +17,8 @@ import RedirectToModal from 'components/modal/RedirectToModal';
17
17
import { CheckIcon , PlusSmIcon } from '@heroicons/react/outline' ;
18
18
import Tabs from './Tabs' ;
19
19
import RemoveElementModal from './RemoveElementModal' ;
20
+ import { useConfiguration } from 'components/utils/useConfiguration' ;
21
+ import BallotDisplay from 'pages/ballot/components/BallotDisplay' ;
20
22
21
23
// notifyParent must be used by the child to tell the parent if the subject's
22
24
// schema changed.
@@ -40,8 +42,15 @@ const ElectionForm: FC<ElectionFormProps> = () => {
40
42
const [ subjectIdToRemove , setSubjectIdToRemove ] = useState < ID > ( '' ) ;
41
43
const [ titleChanging , setTitleChanging ] = useState < boolean > ( true ) ;
42
44
const [ navigateDestination , setNavigateDestination ] = useState ( null ) ;
45
+ const [ marshalledConf , setMarshalledConf ] = useState < any > ( marshalConfig ( conf ) ) ;
46
+ const { configuration : previewConf , answers, setAnswers } = useConfiguration ( marshalledConf ) ;
47
+
43
48
const { MainTitle, Scaffold } = conf ;
44
49
50
+ useEffect ( ( ) => {
51
+ setMarshalledConf ( marshalConfig ( conf ) ) ;
52
+ } , [ conf ] ) ;
53
+
45
54
async function createHandler ( ) {
46
55
const data = {
47
56
Configuration : marshalConfig ( conf ) ,
@@ -149,7 +158,9 @@ const ElectionForm: FC<ElectionFormProps> = () => {
149
158
</ >
150
159
) : (
151
160
< >
152
- < div className = "mt-1 ml-3" onClick = { ( ) => setTitleChanging ( true ) } >
161
+ < div
162
+ className = "mt-1 ml-3 w-[90%] break-words"
163
+ onClick = { ( ) => setTitleChanging ( true ) } >
153
164
{ MainTitle }
154
165
</ div >
155
166
< div className = "ml-1" >
@@ -214,7 +225,14 @@ const ElectionForm: FC<ElectionFormProps> = () => {
214
225
return (
215
226
< div className = "w-screen px-4 md:px-0 mb-4 md:w-auto" >
216
227
< div className = "border rounded-md" >
217
- < div className = "h-[calc(100vh-265px)] ml-2" > preview</ div >
228
+ < div className = "ml-2 w-[95%]" >
229
+ < BallotDisplay
230
+ configuration = { previewConf }
231
+ answers = { answers }
232
+ setAnswers = { setAnswers }
233
+ userErrors = ""
234
+ />
235
+ </ div >
218
236
</ div >
219
237
</ div >
220
238
) ;
0 commit comments