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

Commit

Permalink
applying variant logic
Browse files Browse the repository at this point in the history
  • Loading branch information
yeseniamolinab committed Apr 19, 2022
1 parent 72e2b58 commit 4b3259d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
1 change: 1 addition & 0 deletions app/javascript/components/Payment/Payment.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ export class Payment extends Component {
emitTransactionSubmitted() {
const userId =
window.champaign.personalization.member.id || Cookie.get('__bpmx');
console.log('userId', userId);
const eventPayload = {
user_id: userId,
page_id: this.props.page.id,
Expand Down
21 changes: 18 additions & 3 deletions app/javascript/plugins/fundraiser/FundraiserView.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import Cookie from 'js-cookie';
import { localCurrencies } from './utils';
import unintendedDonationsExperiment from '../../experiments/unintended-donations';
import { setExperimentVariant } from '../../state/experiments';
import { resetMember } from '../../state/member/reducer';

import {
changeAmount,
Expand Down Expand Up @@ -53,9 +54,21 @@ export class FundraiserView extends Component {
}
}

async componentDidUpdate(prevProps) {
console.log('prevProps', prevProps.experiments);
console.log('this.props', this.props);
componentDidUpdate(prevProps) {
if (
prevProps.experiments.length == 0 &&
this.props.experiments.length > 0
) {
const { variant } =
this.props.experiments.find(
e => (e.experimentId = unintendedDonationsExperiment.experimentId)
) || {};
console.log(this.props);
if (variant && variant === '1' && this.props.idMismatch) {
this.props.resetMember();
this.props.changeStep(0);
}
}
}

selectAmount(amount) {
Expand Down Expand Up @@ -225,9 +238,11 @@ export const mapStateToProps = state => ({
!state.fundraiser.disableSavedPayments,
supportedLocalCurrency: state.fundraiser.supportedLocalCurrency,
experiments: state.abTests.experiments,
idMismatch: state.fundraiser.id_mismatch,
});

export const mapDispatchToProps = dispatch => ({
resetMember: () => dispatch(resetMember()),
changeStep: step => dispatch(changeStep(step)),
selectAmount: amount => dispatch(changeAmount(amount)),
selectCurrency: currency => dispatch(changeCurrency(currency)),
Expand Down

0 comments on commit 4b3259d

Please sign in to comment.