Update contact.page.js (#18171)

Co-authored-by: Eric <eashaw@sailsjs.com>
This commit is contained in:
Mike McNeil 2024-04-10 12:36:49 -05:00 committed by GitHub
parent ffddd76b9c
commit 8d810a3a03
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -48,7 +48,11 @@ parasails.registerPage('contact', {
if(this.formToShow === 'contact'){
this.formToDisplay = this.formToShow;
}
if(this.prefillFormDataFromUserRecord){
if(this.primaryBuyingSituation){ // If the user has a priamry buying situation set in their sesssion, pre-fill the form.
// Note: this will be overriden if the user is logged in and has a primaryBuyingSituation set in the database.
this.formData.primaryBuyingSituation = this.primaryBuyingSituation;
}
if(this.prefillFormDataFromUserRecord){// prefill from database
this.formDataToPrefillForLoggedInUsers.emailAddress = this.me.emailAddress;
this.formDataToPrefillForLoggedInUsers.firstName = this.me.firstName;
this.formDataToPrefillForLoggedInUsers.lastName = this.me.lastName;
@ -59,12 +63,9 @@ parasails.registerPage('contact', {
}
this.formData = _.clone(this.formDataToPrefillForLoggedInUsers);
}
if(window.location.search){
if(window.location.search){// auto-clear query string (TODO: Document why we're doing this further. I think this shouldn't exist in the frontend code, instead in the hook. Because analytics corruption.)
window.history.replaceState({}, document.title, '/contact' );
}
if(this.primaryBuyingSituation){
this.formData.primaryBuyingSituation = this.primaryBuyingSituation;// prefill form
}
},
mounted: async function() {
//…