From 2967bcb87d71b7c1e2a3ab038578f415c3e14ef5 Mon Sep 17 00:00:00 2001 From: Vincent Martinez Date: Tue, 29 May 2018 12:15:51 +0100 Subject: [PATCH] Refactor existingMember to read from redux store In action_form.js, removed references to `this.existingMember` and instead read the member from the redux store. The redux store is a initialised before the component, and is updated when the form is cleared. --- app/javascript/member-facing/backbone/action_form.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/app/javascript/member-facing/backbone/action_form.js b/app/javascript/member-facing/backbone/action_form.js index 2d7de1407..8e346431f 100644 --- a/app/javascript/member-facing/backbone/action_form.js +++ b/app/javascript/member-facing/backbone/action_form.js @@ -76,7 +76,6 @@ const ActionForm = Backbone.View.extend({ } this.$submitButton = this.$('.action-form__submit-button'); this.buttonText = this.$submitButton.text(); - this.existingMember = !!options.member.email; GlobalEvents.bindEvents(this); this.setupState(); this.enableGDPRConsent(); @@ -136,9 +135,9 @@ const ActionForm = Backbone.View.extend({ if (!this.consentNeeded) { return; } - var consent = this.state().consent; + const { member, consent } = this.state(); - if (!this.existingMember && consent.isRequired) { + if (!member && consent.isRequired) { this.$el.attr('action', this.url + '/validate'); } else { this.$el.attr('action', this.url); @@ -193,7 +192,6 @@ const ActionForm = Backbone.View.extend({ }, clearForm() { - this.existingMember = false; this.store.dispatch(resetMember()); if (this.consentNeeded) { champaign.store.dispatch(resetState());