Rename variables for clarity and adjust download filename and contents
Renamed the parameter 'e' to 'formikValues' for better clarity in the handleSubmit function. Now load formikValues into the file that get's uploaded so it has the up to date form data. Changed the downloaded JSON filename from 'form_data.json' to 'your_form_data.json' to be more user-friendly.
This commit is contained in:
parent
9a281ed76c
commit
f52201b683
|
|
@ -15,23 +15,23 @@ const GenericForm = (formData: FormData) => {
|
|||
|
||||
const [currentStep, setCurrentStep] = useState<number>(0);
|
||||
|
||||
const handleSubmit = async (e: FormikValues) => {
|
||||
const handleSubmit = async (formikValues: FormikValues) => {
|
||||
try {
|
||||
const response = await fetch(backend, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(e)
|
||||
body: JSON.stringify(formikValues)
|
||||
})
|
||||
if (!response.ok) {
|
||||
let json: string = JSON.stringify(userInput);
|
||||
let json: string = JSON.stringify(formikValues);
|
||||
const blob = new Blob([json], {type: "application/json"});
|
||||
const url = URL.createObjectURL(blob);
|
||||
|
||||
const link = document.createElement('a');
|
||||
link.href = url;
|
||||
link.download = 'form_data.json';
|
||||
link.download = 'your_form_data.json';
|
||||
link.click();
|
||||
URL.revokeObjectURL(url);
|
||||
//TODO clean up
|
||||
|
|
@ -39,7 +39,7 @@ const GenericForm = (formData: FormData) => {
|
|||
} else {
|
||||
navigate('/verify-email', {
|
||||
state: {
|
||||
email: e['email']
|
||||
email: formikValues['email']
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user