From 0738168b81b62c444df0b7ec15b66f42fe73bc5e Mon Sep 17 00:00:00 2001 From: Clark Sell Date: Wed, 18 Oct 2023 14:36:45 -0500 Subject: [PATCH] refactor: adding snapshots to forms --- package.json | 2 +- src/_components/newsletter/HubspotForm.svelte | 4 +++- .../profiles/emergency-contact/emergencyContactForm.svelte | 4 +++- src/routes/(admin my)/my/profiles/primary/profileForm.svelte | 5 ++++- .../(admin my)/my/profiles/public/PublicProfileForm.svelte | 3 ++- .../(admin my)/my/profiles/shared/sharedProfileForm.svelte | 3 ++- 6 files changed, 15 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 7cf0afc..c5ff524 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "thatconference.com", - "version": "5.1.2", + "version": "5.1.3", "description": "THATConference.com website", "main": "index.js", "type": "module", diff --git a/src/_components/newsletter/HubspotForm.svelte b/src/_components/newsletter/HubspotForm.svelte index cfbd58c..2d74e64 100644 --- a/src/_components/newsletter/HubspotForm.svelte +++ b/src/_components/newsletter/HubspotForm.svelte @@ -19,7 +19,7 @@ data.append('recaptchaToken', token); } - const { form, enhance, constraints, errors, tainted } = superForm( + const { form, enhance, constraints, errors, tainted, capture, restore } = superForm( superValidateSync(newsletterSchema), { id: formId, @@ -35,6 +35,8 @@ } } ); + + export const snapshot = { capture, restore };
diff --git a/src/routes/(admin my)/my/profiles/emergency-contact/emergencyContactForm.svelte b/src/routes/(admin my)/my/profiles/emergency-contact/emergencyContactForm.svelte index 2624b03..d6efdae 100644 --- a/src/routes/(admin my)/my/profiles/emergency-contact/emergencyContactForm.svelte +++ b/src/routes/(admin my)/my/profiles/emergency-contact/emergencyContactForm.svelte @@ -14,7 +14,7 @@ { label: 'Yes', value: true } ]; - const { form, enhance, constraints, errors, allErrors } = superForm(sForm, { + const { form, enhance, constraints, errors, allErrors, capture, restore } = superForm(sForm, { dataType: 'json', defaultValidator: 'clear', syncFlashMessage: false, @@ -30,6 +30,8 @@ } }); + // enable the svelte snapshot + export const snapshot = { capture, restore }; let relationshipSelect = $form.relationship; let travelingWithYouSelect = yesNoDropDown.find((i) => i.value == $form.travelingWithYou); diff --git a/src/routes/(admin my)/my/profiles/primary/profileForm.svelte b/src/routes/(admin my)/my/profiles/primary/profileForm.svelte index eb699ed..9e251fd 100644 --- a/src/routes/(admin my)/my/profiles/primary/profileForm.svelte +++ b/src/routes/(admin my)/my/profiles/primary/profileForm.svelte @@ -11,7 +11,7 @@ import { Shell, DisabledShell } from '$elements/buttons'; - const { form, enhance, constraints, errors, allErrors } = superForm(sForm, { + const { form, enhance, constraints, errors, allErrors, capture, restore } = superForm(sForm, { dataType: 'json', defaultValidator: 'clear', taintedMessage: @@ -26,6 +26,9 @@ } } }); + + // enable the svelte snapshot + export const snapshot = { capture, restore };
diff --git a/src/routes/(admin my)/my/profiles/public/PublicProfileForm.svelte b/src/routes/(admin my)/my/profiles/public/PublicProfileForm.svelte index 46eeb4f..f067e30 100644 --- a/src/routes/(admin my)/my/profiles/public/PublicProfileForm.svelte +++ b/src/routes/(admin my)/my/profiles/public/PublicProfileForm.svelte @@ -22,7 +22,7 @@ const flash = getFlash(page); const { isEmpty } = lodash; - const { form, enhance, constraints, errors, allErrors } = superForm(sForm, { + const { form, enhance, constraints, errors, allErrors, capture, restore } = superForm(sForm, { dataType: 'json', validators: publicProfileSchema, syncFlashMessage: false, @@ -40,6 +40,7 @@ } }); + export const snapshot = { capture, restore }; let profileImageUploading; let slugValues = {}; let socialLinkValues = {}; diff --git a/src/routes/(admin my)/my/profiles/shared/sharedProfileForm.svelte b/src/routes/(admin my)/my/profiles/shared/sharedProfileForm.svelte index 3c544f6..10d45e0 100644 --- a/src/routes/(admin my)/my/profiles/shared/sharedProfileForm.svelte +++ b/src/routes/(admin my)/my/profiles/shared/sharedProfileForm.svelte @@ -15,7 +15,7 @@ const { countryCode } = getContext('DROP_DOWN_KEY_VALUE_PAIRS'); - const { form, enhance, constraints, errors, allErrors } = superForm(sForm, { + const { form, enhance, constraints, errors, allErrors, capture, restore } = superForm(sForm, { dataType: 'json', validators: sharedProfileFormSchema, syncFlashMessage: false, @@ -32,6 +32,7 @@ } }); + export const snapshot = { capture, restore }; let countryCodeSelect = countryCode?.options?.find(({ value }) => value === $form.country); let formattedPhoneNumber = ''; function formatPhoneNumber(event) {