From 653879e4cf8b69888a71ed7772d1abfb957ee924 Mon Sep 17 00:00:00 2001 From: Luis Sanchez Date: Tue, 11 Feb 2020 16:41:30 +1100 Subject: [PATCH] fix(customer): CHECKOUT-4596 Trim customer email --- src/app/customer/Customer.spec.tsx | 2 +- src/app/customer/Customer.tsx | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/app/customer/Customer.spec.tsx b/src/app/customer/Customer.spec.tsx index e7d7202392..8f0cdb12fa 100644 --- a/src/app/customer/Customer.spec.tsx +++ b/src/app/customer/Customer.spec.tsx @@ -122,7 +122,7 @@ describe('Customer', () => { (component.find(GuestForm) as ReactWrapper) .prop('onContinueAsGuest')({ - email: 'test@bigcommerce.com', + email: ' test@bigcommerce.com ', shouldSubscribe: true, }); diff --git a/src/app/customer/Customer.tsx b/src/app/customer/Customer.tsx index e53f8cff39..942a4cd136 100644 --- a/src/app/customer/Customer.tsx +++ b/src/app/customer/Customer.tsx @@ -134,12 +134,14 @@ class Customer extends Component { subscribeToNewsletter = noop, } = this.props; + const email = formValues.email.trim(); + if (canSubscribe && formValues.shouldSubscribe) { - subscribeToNewsletter({ email: formValues.email, firstName }); + subscribeToNewsletter({ email, firstName }); } try { - await continueAsGuest({ email: formValues.email }); + await continueAsGuest({ email }); onContinueAsGuest(); this.draftEmail = undefined;