-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
28bc3e9
commit 3192785
Showing
15 changed files
with
624 additions
and
173 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
Empty file.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import React, { useEffect, useState } from 'react'; | ||
import { useParams } from 'react-router-dom'; | ||
import DynamicFormGenerator from '@/components/custom/dynamicFormGenerator'; | ||
|
||
// Example database or state to store forms (replace this with your API/database) | ||
const mockFormDatabase: { [key: string]: any } = { | ||
"coal-mine-blasting-operation-record": { | ||
form_name: "Example Form", | ||
form_description: "This is a dynamically generated form.", | ||
sections: [ | ||
{ | ||
section_name: "Personal Information", | ||
fields: [ | ||
{ | ||
label: "Name", | ||
name: "name", | ||
type: "Text", | ||
placeholder: "Enter your name", | ||
required: true, | ||
}, | ||
{ | ||
label: "Email", | ||
name: "email", | ||
type: "Text", | ||
placeholder: "Enter your email", | ||
required: true, | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
}; | ||
|
||
function FormPage() { | ||
const { uniqueKey } = useParams(); // Get the uniqueKey from the URL | ||
const [formData, setFormData] = useState(null); | ||
|
||
useEffect(() => { | ||
// Fetch the form data using the uniqueKey from the URL | ||
// the url is like this http://localhost:5173/form/067c1614-4e87-4839-8012-4ef292ca9296 | ||
// but the unique key is null | ||
|
||
console.log(uniqueKey) | ||
const fetchedData = localStorage.getItem(uniqueKey?.toString()); | ||
console.log(fetchedData) | ||
|
||
if (fetchedData) { | ||
setFormData(JSON.parse(fetchedData)); // Load the form data from localStorage (or your database) | ||
} | ||
}, [uniqueKey]); | ||
|
||
if (!formData) return <p>Loading form...</p>; | ||
|
||
return ( | ||
<div> | ||
<DynamicFormGenerator formData={formData} /> | ||
</div> | ||
); | ||
} | ||
|
||
export default FormPage; |
Oops, something went wrong.