From d7370bd6399d4afdb12eeec8b8c6a8fb693ead4a Mon Sep 17 00:00:00 2001 From: dalemcgrew Date: Thu, 26 Sep 2024 10:48:53 -0700 Subject: [PATCH] Joining a challenge now works. Inviting an invitee works as well. Updates to ChallengeHeaderSimple. Should be able to publish a challenge without a photo now. --- .../Challenge/JoinChallengeButton.jsx | 23 ++- .../InviteFriendToChallengeInput.jsx | 2 +- .../ChallengeCardForListBody.jsx | 83 +++++---- .../ChallengeListRoot/ChallengeCardList.jsx | 10 +- .../ChallengeParticipantList.jsx | 7 +- .../ChallengeParticipantListRoot.jsx | 4 +- .../Navigation/ChallengeHeaderSimple.jsx | 30 ++-- .../components/Style/ChallengeCardStyles.jsx | 170 ++++++++++++++++++ .../pages/Challenge/ChallengeHomePage.jsx | 32 +--- .../ChallengeInviteCustomizeMessage.jsx | 4 +- .../ChallengeInviteFriends.jsx | 3 +- .../ChallengeInviteFriendsJoin.jsx | 40 ++--- .../ChallengeStart/ChallengeStartPreview.jsx | 9 +- 13 files changed, 290 insertions(+), 127 deletions(-) create mode 100644 src/js/common/components/Style/ChallengeCardStyles.jsx diff --git a/src/js/common/components/Challenge/JoinChallengeButton.jsx b/src/js/common/components/Challenge/JoinChallengeButton.jsx index 191266926..f8825b1d9 100644 --- a/src/js/common/components/Challenge/JoinChallengeButton.jsx +++ b/src/js/common/components/Challenge/JoinChallengeButton.jsx @@ -7,6 +7,7 @@ import historyPush from '../../utils/historyPush'; import { renderLog } from '../../utils/logging'; import AppObservableStore from '../../stores/AppObservableStore'; import ChallengeStore from '../../stores/ChallengeStore'; +import ChallengeParticipantActions from '../../actions/ChallengeParticipantActions'; import ReadyStore from '../../../stores/ReadyStore'; import VoterStore from '../../../stores/VoterStore'; import { getChallengeValuesFromIdentifiers } from '../../utils/challengeUtils'; @@ -50,7 +51,7 @@ class JoinChallengeButton extends React.Component { this.setState({ challengeSEOFriendlyPath, }); - } else { + } else if (challengeSEOFriendlyPathFromProps) { this.setState({ challengeSEOFriendlyPath: challengeSEOFriendlyPathFromProps, }); @@ -64,7 +65,7 @@ class JoinChallengeButton extends React.Component { // voterCanEditThisChallenge, voterIsChallengeParticipant, }); - } else { + } else if (challengeWeVoteIdFromProps) { voterIsChallengeParticipant = ChallengeStore.getVoterIsChallengeParticipant(challengeWeVoteIdFromProps); this.setState({ challengeWeVoteId: challengeWeVoteIdFromProps, @@ -114,14 +115,12 @@ class JoinChallengeButton extends React.Component { goToJoinChallenge = () => { const challengeBasePath = this.getChallengeBasePath(); // console.log('goToJoinChallenge challengeBasePath: ', challengeBasePath); - const { voterFirstName, voterPhotoUrlLarge } = this.state; + const { challengeWeVoteId, voterFirstName, voterPhotoUrlLarge } = this.state; const upcomingGoogleCivicElectionId = VoterStore.electionId(); const voterPlanCreatedForThisElection = ReadyStore.getVoterPlanTextForVoterByElectionId(upcomingGoogleCivicElectionId); - console.log('upcomingGoogleCivicElectionId: ', upcomingGoogleCivicElectionId, 'voterPlanCreatedForThisElection: ', voterPlanCreatedForThisElection); - const itemsAreMissing = !(voterFirstName) || !(voterPhotoUrlLarge) || !(voterPlanCreatedForThisElection); // Temporarily assume we have something we need from voter + // console.log('upcomingGoogleCivicElectionId: ', upcomingGoogleCivicElectionId, 'voterPlanCreatedForThisElection: ', voterPlanCreatedForThisElection); + const itemsAreMissing = !(voterFirstName) || !(voterPhotoUrlLarge) || (upcomingGoogleCivicElectionId && !(voterPlanCreatedForThisElection)); if (VoterStore.getVoterIsSignedIn()) { - // TODO: Make API call that joins this challenge - let joinChallengeNextStepPath = ''; if (itemsAreMissing) { joinChallengeNextStepPath = `${challengeBasePath}join-challenge`; @@ -131,7 +130,15 @@ class JoinChallengeButton extends React.Component { const { location: { pathname: currentPathname } } = window; AppObservableStore.setSetUpAccountBackLinkPath(currentPathname); AppObservableStore.setSetUpAccountEntryPath(joinChallengeNextStepPath); - historyPush(joinChallengeNextStepPath); + if (itemsAreMissing) { + historyPush(joinChallengeNextStepPath); + } else { + ChallengeParticipantActions.challengeParticipantSave(challengeWeVoteId); + // Delay the redirect, so we have time to fire the above API call first + this.timer = setTimeout(() => { + historyPush(joinChallengeNextStepPath); + }, 500); + } } else { this.setState({ goToNextStepAfterSignIn: true, diff --git a/src/js/common/components/ChallengeInviteeListRoot/InviteFriendToChallengeInput.jsx b/src/js/common/components/ChallengeInviteeListRoot/InviteFriendToChallengeInput.jsx index dd2229ec9..577e87b7a 100755 --- a/src/js/common/components/ChallengeInviteeListRoot/InviteFriendToChallengeInput.jsx +++ b/src/js/common/components/ChallengeInviteeListRoot/InviteFriendToChallengeInput.jsx @@ -40,7 +40,7 @@ const InviteFriendToChallengeInput = ({ classes, challengeWeVoteId, externalUniq