-
Notifications
You must be signed in to change notification settings - Fork 198
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2371 from Ajay-aot/Feature/FWF-3942-form-preview-…
…screen Feature/fwf 3942 form preview screen
- Loading branch information
Showing
4 changed files
with
104 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
forms-flow-web/src/components/Form/EditForm/FormPreview.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { Form } from "@aot-technologies/formio-react"; | ||
import React, { useEffect, useState } from "react"; | ||
import { useParams } from "react-router-dom"; | ||
import { useSelector } from "react-redux"; | ||
import { RESOURCE_BUNDLES_DATA } from "../../../resourceBundles/i18n.js"; | ||
import { fetchFormById } from "../../../apiManager/services/bpmFormServices.js"; | ||
import Loading from "../../../containers/Loading.js"; | ||
|
||
const FormPreview = () => { | ||
const lang = useSelector((state) => state.user.lang); | ||
const { formId } = useParams(); | ||
const [form, setForm] = useState(null); | ||
const [loading, setLoading] = useState(false); | ||
|
||
useEffect(() => { | ||
if (formId) { | ||
setLoading(true); | ||
// Fetch form data by ID | ||
fetchFormById(formId) | ||
.then((res) => { | ||
if (res.data) { | ||
const { data } = res; | ||
setForm(data); | ||
} | ||
}) | ||
.catch((err) => { | ||
console.error( | ||
"Error fetching form data:", | ||
err.response?.data || err.message | ||
); | ||
}) | ||
.finally(() => { | ||
setLoading(false); | ||
}); | ||
} | ||
}, [formId]); | ||
|
||
if (loading) { | ||
return <Loading />; | ||
} | ||
|
||
return ( | ||
<div className="form-preview-tab"> | ||
<div className="preview-header-text mb-4">{form?.title}</div> | ||
<div> | ||
<Form | ||
form={form} | ||
options={{ | ||
disableAlerts: true, | ||
noAlerts: true, | ||
language: lang, | ||
i18n: RESOURCE_BUNDLES_DATA, | ||
}} | ||
/> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default FormPreview; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters