diff --git a/src/js/form-util.js b/src/js/form-util.js index 9e50f166..05035607 100644 --- a/src/js/form-util.js +++ b/src/js/form-util.js @@ -128,6 +128,8 @@ export function prepareInputs (formInputs, reasonInputs, reasonFieldset, reasonA } console.log(getProfile(formInputs), reasons) + + window.localStorage.setItem('savedProfile', JSON.stringify(getProfile(formInputs))) const pdfBlob = await generatePdf(getProfile(formInputs), reasons, pdfBase) diff --git a/src/js/form.js b/src/js/form.js index 1965a8c0..c3f03c1b 100644 --- a/src/js/form.js +++ b/src/js/form.js @@ -29,6 +29,7 @@ const createFormGroup = ({ minlength, name, pattern, + value, placeholder = '', type = 'text', }) => { @@ -53,6 +54,7 @@ const createFormGroup = ({ maxlength, name, pattern, + value, placeholder, required: true, type, @@ -141,6 +143,12 @@ export function createForm () { } const appendToForm = appendTo(form) + + let savedProfile = null + try { + savedProfile = JSON.parse(window.localStorage.getItem('savedProfile')) + } catch (e) { + } const formFirstPart = formData .flat(1) @@ -152,6 +160,7 @@ export function createForm () { autofocus: index === 0, ...field, name: field.key, + value: savedProfile && savedProfile[field.key] ? savedProfile[field.key] : '', }) return formGroup