Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 25 additions & 25 deletions src/js/common/components/CampaignSupport/HelpWinOrDefeatModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,39 +25,39 @@ class HelpWinOrDefeatModal extends Component {
// this.voterStoreListener = VoterStore.addListener(this.onVoterStoreChange.bind(this));
this.candidateStoreListener = CandidateStore.addListener(this.onCandidateStoreChange.bind(this));
this.measureStoreListener = MeasureStore.addListener(this.onMeasureStoreChange.bind(this));
const { ballotItemWeVoteId, politicianWeVoteId } = this.props;
const ballotItemStatSheet = SupportStore.getBallotItemStatSheet(ballotItemWeVoteId, politicianWeVoteId);
if (ballotItemStatSheet) {
const { voterOpposesBallotItem, voterSupportsBallotItem } = ballotItemStatSheet;
this.setState({
voterOpposesBallotItem,
voterSupportsBallotItem,
});
}
// const { ballotItemWeVoteId, politicianWeVoteId } = this.props;
// const ballotItemStatSheet = SupportStore.getBallotItemStatSheet(ballotItemWeVoteId, politicianWeVoteId);
// if (ballotItemStatSheet) {
// const { voterOpposesBallotItem, voterSupportsBallotItem } = ballotItemStatSheet;
// // this.setState({
// // voterOpposesBallotItem,
// // voterSupportsBallotItem,
// // });
// }

// const voter = VoterStore.getVoter();
// const voterIsSignedIn = VoterStore.getVoterIsSignedIn();
// const { voter_photo_url_medium: voterPhotoUrlMedium } = voter;

let ballotItemDisplayName = '';
// let ballotItemDisplayName = '';
// let ballotItemType;
let campaignXWeVoteId;
let isCandidate = false;
let isMeasure = false;
if (stringContains('cand', this.props.ballotItemWeVoteId)) {
const candidate = CandidateStore.getCandidateByWeVoteId(this.props.ballotItemWeVoteId);
ballotItemDisplayName = candidate.ballot_item_display_name || '';
// ballotItemDisplayName = candidate.ballot_item_display_name || '';
// ballotItemType = 'CANDIDATE';
campaignXWeVoteId = candidate.linked_campaignx_we_vote_id || '';
isCandidate = true;
} else if (stringContains('meas', this.props.ballotItemWeVoteId)) {
const measure = MeasureStore.getMeasure(this.props.ballotItemWeVoteId);
ballotItemDisplayName = measure.ballot_item_display_name || '';
// const measure = MeasureStore.getMeasure(this.props.ballotItemWeVoteId);
// ballotItemDisplayName = measure.ballot_item_display_name || '';
// ballotItemType = 'MEASURE';
isMeasure = true;
}
this.setState({
ballotItemDisplayName,
// ballotItemDisplayName,
// ballotItemType,
campaignXWeVoteId,
isCandidate,
Expand Down Expand Up @@ -94,39 +94,39 @@ class HelpWinOrDefeatModal extends Component {
if (this.state.isCandidate) {
const { ballotItemWeVoteId } = this.props;
const candidate = CandidateStore.getCandidateByWeVoteId(ballotItemWeVoteId);
const ballotItemDisplayName = candidate.ballot_item_display_name || '';
// const ballotItemDisplayName = candidate.ballot_item_display_name || '';
const campaignXWeVoteId = candidate.linked_campaignx_we_vote_id || '';
this.setState({
ballotItemDisplayName,
// ballotItemDisplayName,
campaignXWeVoteId,
});
}
}

onMeasureStoreChange () {
if (this.state.isMeasure) {
const { ballotItemWeVoteId } = this.props;
const measure = MeasureStore.getMeasure(ballotItemWeVoteId);
const ballotItemDisplayName = measure.ballot_item_display_name || '';
// const { ballotItemWeVoteId } = this.props;
// const measure = MeasureStore.getMeasure(ballotItemWeVoteId);
// const ballotItemDisplayName = measure.ballot_item_display_name || '';
this.setState({
ballotItemDisplayName,
// ballotItemDisplayName,
});
}
}

onSupportStoreChange () {
const { ballotItemWeVoteId, politicianWeVoteId } = this.props;
const ballotItemStatSheet = SupportStore.getBallotItemStatSheet(ballotItemWeVoteId, politicianWeVoteId);
let voterOpposesBallotItem = '';
let voterSupportsBallotItem = '';
// let voterOpposesBallotItem = '';
// let voterSupportsBallotItem = '';
// let voterTextStatement = '';
// let voterPositionIsPublic = '';
if (ballotItemStatSheet) {
({ voterOpposesBallotItem, voterSupportsBallotItem } = ballotItemStatSheet);
// ({ voterOpposesBallotItem, voterSupportsBallotItem } = ballotItemStatSheet);
}
this.setState({
voterOpposesBallotItem,
voterSupportsBallotItem,
// voterOpposesBallotItem,
// voterSupportsBallotItem,
});

// if (ballotItemStatSheet) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@ import { payToPromoteProcessStyles } from '../Style/CampaignSupportStyles';
import webAppConfig from '../../../config';
// import AppObservableStore, { messageService } from '../../stores/AppObservableStore';
import CampaignStore from '../../stores/CampaignStore';
// import VoterStore from '../../../stores/VoterStore';
import { getPageDetails } from '../../../utils/lookupPageNameAndPageTypeDict'; // import VoterStore from '../../../stores/VoterStore';
import { getCampaignXValuesFromIdentifiers, retrieveCampaignXFromIdentifiersIfNeeded } from '../../utils/campaignUtils';
import initializejQuery from '../../utils/initializejQuery';
import SplitIconButton from '../Widgets/SplitIconButton';
import lookupPageNameAndPageTypeDict, { getPageDetails } from '../../../utils/lookupPageNameAndPageTypeDict';
import VoterStore from '../../../stores/VoterStore';

const stripePromise = loadStripe(webAppConfig.STRIPE_API_KEY);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import PropTypes from 'prop-types';
import React, { Component } from 'react';

// Dummy PayToPromoteProcess class, which at Cordova compile time, is copied over the production class to remove any trace of Stripe from Cordova
Expand Down
41 changes: 20 additions & 21 deletions src/js/common/components/Challenge/ChallengeAbout.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,26 @@ function ChallengeAbout ({ challengeWeVoteId, showDaysLeft }) {
const [daysLeft, setDaysLeft] = React.useState(0);
const [participantNameWithHighestRank, setParticipantNameWithHighestRank] = React.useState('');

const onAppObservableStoreChange = () => {
setParticipantNameWithHighestRank(AppObservableStore.getChallengeParticipantNameWithHighestRankByChallengeWeVoteId(challengeWeVoteId));
};

const onChallengeStoreChange = () => {
if (challengeInviteesCount < ChallengeStore.getNumberOfInviteesInChallenge(challengeWeVoteId)) {
setChallengeInviteesCount(ChallengeStore.getNumberOfInviteesInChallenge(challengeWeVoteId));
}
if (challengeParticipantCount < ChallengeStore.getNumberOfParticipantsInChallenge(challengeWeVoteId)) {
setChallengeParticipantCount(ChallengeStore.getNumberOfParticipantsInChallenge(challengeWeVoteId));
}
setDaysLeft(ChallengeStore.getDaysUntilChallengeEnds(challengeWeVoteId));
setChallengeOwners(ChallengeStore.getChallengeOwnerList(challengeWeVoteId));
};
const onChallengeParticipantStoreChange = () => {
if (challengeParticipantCount < ChallengeParticipantStore.getNumberOfParticipantsInChallenge(challengeWeVoteId)) {
setChallengeParticipantCount(ChallengeParticipantStore.getNumberOfParticipantsInChallenge(challengeWeVoteId));
}
};

React.useEffect(() => {
const onAppObservableStoreChange = () => {
setParticipantNameWithHighestRank(AppObservableStore.getChallengeParticipantNameWithHighestRankByChallengeWeVoteId(challengeWeVoteId));
};

const onChallengeStoreChange = () => {
if (challengeInviteesCount < ChallengeStore.getNumberOfInviteesInChallenge(challengeWeVoteId)) {
setChallengeInviteesCount(ChallengeStore.getNumberOfInviteesInChallenge(challengeWeVoteId));
}
if (challengeParticipantCount < ChallengeStore.getNumberOfParticipantsInChallenge(challengeWeVoteId)) {
setChallengeParticipantCount(ChallengeStore.getNumberOfParticipantsInChallenge(challengeWeVoteId));
}
setDaysLeft(ChallengeStore.getDaysUntilChallengeEnds(challengeWeVoteId));
setChallengeOwners(ChallengeStore.getChallengeOwnerList(challengeWeVoteId));
};
const onChallengeParticipantStoreChange = () => {
if (challengeParticipantCount < ChallengeParticipantStore.getNumberOfParticipantsInChallenge(challengeWeVoteId)) {
setChallengeParticipantCount(ChallengeParticipantStore.getNumberOfParticipantsInChallenge(challengeWeVoteId));
}
};
const appStateSubscription = messageService.getMessage().subscribe(() => onAppObservableStoreChange());
onAppObservableStoreChange();
const challengeParticipantStoreListener = ChallengeParticipantStore.addListener(onChallengeParticipantStoreChange);
Expand All @@ -53,7 +52,7 @@ function ChallengeAbout ({ challengeWeVoteId, showDaysLeft }) {
challengeParticipantStoreListener.remove();
challengeStoreListener.remove();
};
}, [challengeWeVoteId]);
}, [challengeWeVoteId, challengeInviteesCount, challengeParticipantCount]);

// Variables to hold dummy data
const challengeDates = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ function searchFunction () {
}

// React functional component example
export default function ChallengesHomeFilterPlaceholder (props) {
export default function ChallengesHomeFilterPlaceholder () {
renderLog('ChallengesHomeFilterPlaceholder functional component');
// console.log('ChallengesHomeFilterPlaceholder props.stateCode:', props.stateCode);
return (
<span id="ChallengesHomeFilterPlaceholder">
<ChallengesHomeFilter
Expand Down
13 changes: 6 additions & 7 deletions src/js/common/components/Challenge/JoinedAndDaysLeft.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@ function JoinedAndDaysLeft ({ challengeWeVoteId, borderSwitcher, padding }) {
const [daysLeft, setDaysLeft] = React.useState(0);
const [voterIsChallengeParticipant, setVoterIsChallengeParticipant] = React.useState(false);

const onChallengeStoreChange = () => {
const daysToChallengeEnds = ChallengeStore.getDaysUntilChallengeEnds(challengeWeVoteId);
// console.log('Days to challenge ends:', daysToChallengeEnds);
setDaysLeft(Math.max(daysToChallengeEnds, 0));
setVoterIsChallengeParticipant(ChallengeStore.getVoterIsChallengeParticipant(challengeWeVoteId));
};

React.useEffect(() => {
const onChallengeStoreChange = () => {
const daysToChallengeEnds = ChallengeStore.getDaysUntilChallengeEnds(challengeWeVoteId);
// console.log('Days to challenge ends:', daysToChallengeEnds);
setDaysLeft(Math.max(daysToChallengeEnds, 0));
setVoterIsChallengeParticipant(ChallengeStore.getVoterIsChallengeParticipant(challengeWeVoteId));
};
const challengeStoreListener = ChallengeStore.addListener(onChallengeStoreChange);
onChallengeStoreChange();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class PointsExplanationModal extends Component {
constructor (props) {
super(props);
this.state = {
showTerms: false,
// showTerms: false,
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ function ThanksForViewingChallenge ({ sharedByDisplayName }) {
const [showConfetti, setShowConfetti] = useState(false);

useEffect(() => {
if (isClosing) {
const timer = setTimeout(() => {
}, 500);
return () => clearTimeout(timer);
if (!isClosing) {
return undefined;
}
const timer = setTimeout(() => {
}, 500);
return () => clearTimeout(timer);
}, [isClosing]);

useEffect(() => {
Expand Down
41 changes: 16 additions & 25 deletions src/js/common/components/Challenge/YourRank.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ import FirstChallengeParticipantListController from '../ChallengeParticipantList

function YourRank ({ classes, challengeWeVoteId, hasBackgroundColor }) {
const [clicked, setClicked] = useState(false);
const [participantsCount, setParticipantsCount] = useState(0);
const [points, setPoints] = useState(0);
// const [note, setNote] = useState("");
const [arrowImage, setArrowImage] = useState(arrow);
const [openYourRankModal, setOpenYourRankModal] = useState(false);
const [rankOfVoter, setRankOfVoter] = React.useState(0);
Expand All @@ -38,34 +35,28 @@ function YourRank ({ classes, challengeWeVoteId, hasBackgroundColor }) {
angle: 90, // Confetti moves straight up
});

const onAppObservableStoreChange = () => {
setRankOfVoter(AppObservableStore.getChallengeParticipantRankOfVoterByChallengeWeVoteId(challengeWeVoteId));
};
const handleClick = () => {
setClicked(true);
setArrowImage(arrow1);

const onChallengeParticipantStoreChange = () => {
const sortedParticipantsWithRank = ChallengeParticipantStore.getChallengeParticipantList(challengeWeVoteId);
setParticipantsCount(sortedParticipantsWithRank.length);
setRankOfVoter(AppObservableStore.getChallengeParticipantRankOfVoterByChallengeWeVoteId(challengeWeVoteId));
};
// triggerConfetti(); // Show confetti when the button is clicked (uncomment this line to show confetti when the button rank is clicked)

const handleClick = () => {
setPoints((prevPoints) => {
const newPoints = prevPoints + 1;
setClicked(true);
setArrowImage(arrow1);

// triggerConfetti(); // Show confetti when the button is clicked (uncomment this line to show confetti when the button rank is clicked)

setTimeout(() => {
setClicked(false);
setArrowImage(arrow);
}, 3000);
return newPoints;
});
setTimeout(() => {
setClicked(false);
setArrowImage(arrow);
}, 3000);
setOpenYourRankModal(!openYourRankModal);
};

React.useEffect(() => {
const onAppObservableStoreChange = () => {
setRankOfVoter(AppObservableStore.getChallengeParticipantRankOfVoterByChallengeWeVoteId(challengeWeVoteId));
};

const onChallengeParticipantStoreChange = () => {
// const sortedParticipantsWithRank = ChallengeParticipantStore.getChallengeParticipantList(challengeWeVoteId);
setRankOfVoter(AppObservableStore.getChallengeParticipantRankOfVoterByChallengeWeVoteId(challengeWeVoteId));
};
// console.log('Fetching participants for:', challengeWeVoteId);
const appStateSubscription = messageService.getMessage().subscribe(() => onAppObservableStoreChange());
onAppObservableStoreChange();
Expand Down
2 changes: 1 addition & 1 deletion src/js/common/components/Challenge/YourRankModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ YourRankModal.propTypes = {
toggleModal: PropTypes.func.isRequired,
};

const styles = (theme) => ({
const styles = () => ({
dialogPaper: {
borderRadius: '16px',
},
Expand Down
Loading