diff --git a/packages/concordia-app/src/components/PollView/PollGuestView/index.jsx b/packages/concordia-app/src/components/PollView/PollGuestView/index.jsx new file mode 100644 index 0000000..0db3864 --- /dev/null +++ b/packages/concordia-app/src/components/PollView/PollGuestView/index.jsx @@ -0,0 +1,21 @@ +import React from 'react'; +import { Container, Header, Icon } from 'semantic-ui-react'; +import { Link } from 'react-router-dom'; + +const PollGuestView = () => ( + +
+ + + Only registered users are able to vote in polls. + + You can register in the  + signup +  page. + + +
+
+); + +export default PollGuestView; diff --git a/packages/concordia-app/src/components/PollView/index.jsx b/packages/concordia-app/src/components/PollView/index.jsx index bb2ab0d..18ff75c 100644 --- a/packages/concordia-app/src/components/PollView/index.jsx +++ b/packages/concordia-app/src/components/PollView/index.jsx @@ -16,6 +16,7 @@ import { FETCH_USER_DATABASE } from '../../redux/actions/peerDbReplicationAction import { generatePollHash, generateHash } from '../../utils/hashUtils'; import { POLL_OPTIONS, POLL_QUESTION } from '../../constants/orbit/PollsDatabaseKeys'; import PollDataInvalid from './PollDataInvalid'; +import PollGuestView from './PollGuestView'; const { contracts: { [VOTING_CONTRACT]: { methods: { getPoll: { cacheCall: getPollChainData } } } } } = drizzle; const { orbit } = breeze; @@ -92,8 +93,6 @@ const PollView = (props) => { } }, [pollHash, polls, topicId]); - // TODO: add a "Signup to enable voting" view - const userHasVoted = useMemo(() => hasSignedUp && voters .some((optionVoters) => optionVoters.includes(userAddress)), [hasSignedUp, userAddress, voters]); @@ -107,18 +106,24 @@ const PollView = (props) => { return ''; }, [pollOptions, userAddress, userHasVoted, voters]); - const pollVoteTab = useMemo(() => ( - !loading - ? ( - - ) - :
- ), [loading, pollChangeVoteEnabled, pollOptions, userHasVoted, userVoteHash]); + const pollVoteTab = useMemo(() => { + if (!hasSignedUp) { + return ; + } + + if (loading) { + return null; + } + + return ( + + ); + }, [hasSignedUp, loading, pollChangeVoteEnabled, pollOptions, userHasVoted, userVoteHash]); const pollGraphTab = useMemo(() => ( !loading @@ -130,7 +135,7 @@ const PollView = (props) => { userVoteHash={userVoteHash} /> ) - :
+ : null ), [loading, pollOptions, userHasVoted, userVoteHash, voteCounts]); const panes = useMemo(() => {