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. 29
      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;

29
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 { generatePollHash, generateHash } from '../../utils/hashUtils';
import { POLL_OPTIONS, POLL_QUESTION } from '../../constants/orbit/PollsDatabaseKeys';
import PollDataInvalid from './PollDataInvalid';
const { contracts: { [VOTING_CONTRACT]: { methods: { getPoll: { cacheCall: getPollChainData } } } } } = drizzle;
const { orbit } = breeze;
@ -144,17 +145,23 @@ const PollView = (props) => {
return (
<Container id="topic-poll-container" textAlign="left">
<Header as="h3">
<Grid>
<Grid.Column width={1}><Icon name="chart pie" size="large" /></Grid.Column>
<Grid.Column width={15}>
{loading
? <Placeholder><Placeholder.Line length="very long" /></Placeholder>
: pollQuestion}
</Grid.Column>
</Grid>
</Header>
<Tab panes={panes} />
{!loading && pollHashValid
? (
<>
<Header as="h3">
<Grid>
<Grid.Column width={1}><Icon name="chart pie" size="large" /></Grid.Column>
<Grid.Column width={15}>
{loading
? <Placeholder><Placeholder.Line length="very long" /></Placeholder>
: pollQuestion}
</Grid.Column>
</Grid>
</Header>
<Tab panes={panes} />
</>
)
: <PollDataInvalid />}
</Container>
);
};

Loading…
Cancel
Save