Skip to content
This repository has been archived by the owner on Mar 27, 2023. It is now read-only.

Commit

Permalink
Refactor existingMember to read from redux store
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
vincemtnz committed May 29, 2018
1 parent eeab98e commit 2967bcb
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions app/javascript/member-facing/backbone/action_form.js
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -193,7 +192,6 @@ const ActionForm = Backbone.View.extend({
},

clearForm() {
this.existingMember = false;
this.store.dispatch(resetMember());
if (this.consentNeeded) {
champaign.store.dispatch(resetState());
Expand Down

0 comments on commit 2967bcb

Please sign in to comment.