From f52201b683f369f9741bd94f09b3929d87f5aa24 Mon Sep 17 00:00:00 2001 From: Teriuihi Date: Tue, 6 Aug 2024 23:21:53 +0200 Subject: [PATCH] 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. --- src/components/form/genericForm.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/components/form/genericForm.tsx b/src/components/form/genericForm.tsx index df8e137..774d791 100644 --- a/src/components/form/genericForm.tsx +++ b/src/components/form/genericForm.tsx @@ -15,23 +15,23 @@ const GenericForm = (formData: FormData) => { const [currentStep, setCurrentStep] = useState(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'] } }); }