Populate fields and detect changes on submit.

This commit is contained in:
Chloe Herd 2023-08-15 10:15:20 -04:00
parent 17f149af43
commit 54d155be4d
2 changed files with 29 additions and 4 deletions

View file

@ -68,11 +68,22 @@ export default {
isSmsOptIn: false,
};
},
props: {},
props: {
previousCustomerValues: Object,
},
computed: {
modal() {
return this.$refs.CustomerDetailsModal;
},
haveCustomerDetailsChanged() {
return (
this.firstName !== this.previousCustomerValues?.firstName ||
this.lastName !== this.previousCustomerValues?.lastName ||
this.emailAddress !== this.previousCustomerValues?.emailAddress ||
this.phoneNumber !== this.previousCustomerValues?.phoneNumber ||
this.isSmsOptIn !== this.previousCustomerValues?.isSmsOptIn
);
},
},
methods: {
openModal() {
@ -81,12 +92,24 @@ export default {
closeModal() {
this.modal.closeModal();
},
onModalOpened() {},
onModalOpened() {
this.firstName = this.previousCustomerValues?.firstName ?? "";
this.lastName = this.previousCustomerValues?.lastName ?? "";
this.emailAddress = this.previousCustomerValues?.emailAddress ?? "";
this.phoneNumber = this.previousCustomerValues?.phoneNumber ?? "";
this.isSmsOptIn = this.previousCustomerValues?.isSmsOptIn ?? false;
},
onModalClosed() {},
setModalStatus(isOpened) {
this.isModalOpened = isOpened;
},
setContactDetails() {},
async setContactDetails() {
if (this.haveCustomerDetailsChanged) {
console.log("change detected");
}
this.closeModal();
},
},
components: {
modal,

View file

@ -89,7 +89,9 @@
<hr class="my-0" />
</div>
<customerDetailsModalQuestion ref="customerDetailsModalQuestion" />
<customerDetailsModalQuestion
ref="customerDetailsModalQuestion"
:previousCustomerValues="customerInfo" />
<funnelFooter
cmsWidgetName="FunnelFooterWidget"