Browse Source

feat: add invalid poll data view

develop
Apostolos Fanakis 4 years ago
parent
commit
5d3cceb478
Signed by: Apostolof GPG Key ID: 8600B4C4163B3269
  1. 16
      packages/concordia-app/src/components/PollView/PollDataInvalid/index.jsx
  2. 7
      packages/concordia-app/src/components/PollView/index.jsx

16
packages/concordia-app/src/components/PollView/PollDataInvalid/index.jsx

@ -0,0 +1,16 @@
import React from 'react';
import { Container, Header, Icon } from 'semantic-ui-react';
const PollDataInvalid = () => (
<Container id="topic-poll-data-invalid-container">
<Header as="h3">
<Icon name="warning sign" color="red" />
<Header.Content>
This topic has a poll but the data are untrusted!
<Header.Subheader>The poll data downloaded from the poster have been tampered with.</Header.Subheader>
</Header.Content>
</Header>
</Container>
);
export default PollDataInvalid;

7
packages/concordia-app/src/components/PollView/index.jsx

@ -15,6 +15,7 @@ import PollVote from './PollVote';
import { FETCH_USER_DATABASE } from '../../redux/actions/peerDbReplicationActions'; import { FETCH_USER_DATABASE } from '../../redux/actions/peerDbReplicationActions';
import { generatePollHash, generateHash } from '../../utils/hashUtils'; import { generatePollHash, generateHash } from '../../utils/hashUtils';
import { POLL_OPTIONS, POLL_QUESTION } from '../../constants/orbit/PollsDatabaseKeys'; import { POLL_OPTIONS, POLL_QUESTION } from '../../constants/orbit/PollsDatabaseKeys';
import PollDataInvalid from './PollDataInvalid';
const { contracts: { [VOTING_CONTRACT]: { methods: { getPoll: { cacheCall: getPollChainData } } } } } = drizzle; const { contracts: { [VOTING_CONTRACT]: { methods: { getPoll: { cacheCall: getPollChainData } } } } } = drizzle;
const { orbit } = breeze; const { orbit } = breeze;
@ -144,6 +145,9 @@ const PollView = (props) => {
return ( return (
<Container id="topic-poll-container" textAlign="left"> <Container id="topic-poll-container" textAlign="left">
{!loading && pollHashValid
? (
<>
<Header as="h3"> <Header as="h3">
<Grid> <Grid>
<Grid.Column width={1}><Icon name="chart pie" size="large" /></Grid.Column> <Grid.Column width={1}><Icon name="chart pie" size="large" /></Grid.Column>
@ -155,6 +159,9 @@ const PollView = (props) => {
</Grid> </Grid>
</Header> </Header>
<Tab panes={panes} /> <Tab panes={panes} />
</>
)
: <PollDataInvalid />}
</Container> </Container>
); );
}; };

Loading…
Cancel
Save