diff --git a/src/components/v5/common/ActionSidebar/partials/Motions/steps/OutcomeStep/OutcomeStep.tsx b/src/components/v5/common/ActionSidebar/partials/Motions/steps/OutcomeStep/OutcomeStep.tsx index 9bb9cc0cfa2..fdc7e6f36ea 100644 --- a/src/components/v5/common/ActionSidebar/partials/Motions/steps/OutcomeStep/OutcomeStep.tsx +++ b/src/components/v5/common/ActionSidebar/partials/Motions/steps/OutcomeStep/OutcomeStep.tsx @@ -1,19 +1,25 @@ import React, { FC } from 'react'; -import { formatText } from '~utils/intl'; import CardWithSections from '~v5/shared/CardWithSections'; +import { UserAvatarsItem } from '~v5/shared/UserAvatars/types'; + +import { formatText } from '~utils/intl'; +import { MotionState, MotionVote } from '~utils/colonyMotions'; +import { useAppContext } from '~hooks'; + import { OutcomeStepProps } from './types'; import { useOutcomeStep } from './hooks'; import VoteStatuses from './partials/VoteStatuses'; -import { MotionState } from '~utils/colonyMotions'; -import { UserAvatarsItem } from '~v5/shared/UserAvatars/types'; const displayName = 'v5.common.ActionSidebar.partials.motions.Motion.steps.OutcomeStep'; const OutcomeStep: FC = ({ motionData, motionState }) => { + const { wallet, user } = useAppContext(); const { voteStatuses } = useOutcomeStep(motionData); + const canInteract = !!wallet && !!user; + const voters: UserAvatarsItem[] = motionData?.voterRecord.map((voter) => ({ address: voter.address, @@ -21,6 +27,25 @@ const OutcomeStep: FC = ({ motionData, motionState }) => { vote: voter.vote ?? undefined, })) || []; + const currentUserVote = voters.find( + ({ address }) => address === wallet?.address, + ); + const currentUserVoted = !!currentUserVote; + + let outcome = false; + if ( + currentUserVote?.vote === MotionVote.Yay && + motionState === MotionState.Passed + ) { + outcome = true; + } + if ( + currentUserVote?.vote === MotionVote.Nay && + motionState === MotionState.Failed + ) { + outcome = true; + } + return ( = ({ motionData, motionState }) => { key: '1', content: (
-

- {formatText({ - id: - motionState === MotionState.Passed + {canInteract && currentUserVoted && ( +

+ {formatText({ + id: outcome ? 'motion.outcomeStep.win.title' : 'motion.outcomeStep.lost.title', - })} -

+ })} + + )}
),