forked from finbogo-org/react-form-builder
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloadFormSubmission.jsx
More file actions
35 lines (32 loc) · 958 Bytes
/
loadFormSubmission.jsx
File metadata and controls
35 lines (32 loc) · 958 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import React, { useState, useEffect } from "react";
import { FormBuilderEventKeys } from "./src/utils";
import CreateSubmission from "./createSubmission";
export default function LoadFormSubmission() {
const [questionData, setQuestionData] = useState([]);
useEffect(() => {
window.addEventListener(
"message",
function (event) {
if (event?.data?.key === FormBuilderEventKeys.PostQuestionData) {
const formData = event.data?.questionData;
setQuestionData(formData);
}
},
false
);
}, []);
return (
<>
{!!questionData?.length && (
<div
className="d-flex justify-content-center align-items-center"
style={{ height: "100vh", padding: "20px" }}
>
<div style={{ width: "80%", maxWidth: "900px" }}>
<CreateSubmission formData={questionData} showButtons={true} />
</div>
</div>
)}
</>
);
}