Skip to content
This repository has been archived by the owner on Mar 25, 2022. It is now read-only.

Commit

Permalink
Fixed B13 and B14, AppliedT84
Browse files Browse the repository at this point in the history
  • Loading branch information
camillelagramastarshot12 committed Feb 6, 2019
1 parent 61137b7 commit 6b9a5c8
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 25 deletions.
45 changes: 22 additions & 23 deletions packages/moloch-frontend/src/components/ProposalDetail.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,15 @@ const ProgressBar = ({ yes, no }) => (

const MemberAvatar = ({ member, shares }) => {
return (
<Grid.Column mobile={4} tablet={3} computer={3} textAlign="center" className="member_avatar" title={member}>
<Link to={`/members/${member}`} className="uncolored">
<Image src={hood} centered />
<p className="name">{!member ? '' : (member.length > 10 ? member.substring(0, 10) + '...' : member)}</p>
<Grid.Column mobile={4} tablet={3} computer={3} textAlign="center" className="member_avatar" title={member}>
<Link to={`/members/${member}`} className="uncolored">
<Image src={hood} centered />
<p className="name">{!member ? '' : (member.length > 10 ? member.substring(0, 10) + '...' : member)}</p>

</Link>
</Grid.Column>
)};
</Link>
</Grid.Column>
)
};

class ProposalDetail extends Component {
constructor(props) {
Expand Down Expand Up @@ -109,7 +110,7 @@ class ProposalDetail extends Component {
}

loadData(responseJson) {
this.setState({ proposal_detail: (responseJson.items.member ? responseJson.items.member : responseJson.items), isAccepted: (responseJson.items.status === 'accepted' ? true : false) });
this.setState({ proposal_detail: (responseJson.items.member ? responseJson.items.member : responseJson.items), isAccepted: (responseJson.items.member.status === 'accepted' || responseJson.items.member.status === 'active' ? true : false) });
let voters = this.state.proposal_detail.voters ? this.state.proposal_detail.voters : [];
let userHasVoted = voters.find(voter => voter.member === this.state.loggedUser) ? true : false;
this.setState({ userHasVoted });
Expand All @@ -131,7 +132,7 @@ class ProposalDetail extends Component {
case 'no':
totalNumberVotedNo += voter.shares;
break;
default:
default:
break;
}
}
Expand Down Expand Up @@ -187,7 +188,7 @@ class ProposalDetail extends Component {
.then((responseJson) => {
if (responseJson.type === "POST_EVENTS_SUCCESS") {
self.calculateVote(proposal.voters);
self.setState({ isAccepted: (responseJson.items.payload.status === 'accepted' ? true : false) });
self.setState({ isAccepted: true });
switch (eventName) {
case 'Project proposal voted':
case 'Membership proposal voted':
Expand Down Expand Up @@ -294,19 +295,17 @@ class ProposalDetail extends Component {
<ProgressBar yes={this.state.votedYes} no={this.state.votedNo}></ProgressBar>
</Grid.Column>
</Grid>
{this.state.userShare && this.state.status === 'inprogress' && (this.state.memberStatus === 'àctive' || this.state.memberStatus === 'founder') ?
<Grid columns="equal" centered>
<Grid.Column textAlign="center" mobile={16} tablet={5} computer={5} >
<Button className="btn" color='grey' disabled={this.state.userHasVoted || this.state.isAccepted} onClick={this.handleNo}>Vote No</Button>
</Grid.Column>
<Grid.Column textAlign="center" mobile={16} tablet={5} computer={5} >
<Button className="btn" color='grey' disabled={this.state.userHasVoted || this.state.isAccepted} onClick={this.handleYes}>Vote Yes</Button>
</Grid.Column>
<Grid.Column textAlign="center" mobile={16} tablet={5} computer={5} >
<Button className="btn" color='grey' onClick={this.handleProcess} disabled={ (this.state.isAccepted ? true : (this.state.votedYes > 50) ? false : true) }>Process Proposal</Button>
</Grid.Column>
</Grid> : null}

<Grid columns="equal" centered>
<Grid.Column textAlign="center" mobile={16} tablet={5} computer={5} >
<Button className="btn" color='grey' disabled={this.state.userHasVoted || this.state.isAccepted || !(this.state.userShare && this.state.status === 'inprogress' && (this.state.memberStatus === 'àctive' || this.state.memberStatus === 'founder'))} onClick={this.handleNo}>Vote No</Button>
</Grid.Column>
<Grid.Column textAlign="center" mobile={16} tablet={5} computer={5} >
<Button className="btn" color='grey' disabled={this.state.userHasVoted || this.state.isAccepted || !(this.state.userShare && this.state.status === 'inprogress' && (this.state.memberStatus === 'àctive' || this.state.memberStatus === 'founder'))} onClick={this.handleYes}>Vote Yes</Button>
</Grid.Column>
<Grid.Column textAlign="center" mobile={16} tablet={5} computer={5} >
<Button className="btn" color='grey' onClick={this.handleProcess} disabled={(this.state.isAccepted || (this.state.userShare && this.state.status === 'inprogress' && (this.state.memberStatus === 'àctive' || this.state.memberStatus === 'founder')) ? true : (this.state.votedYes > 50) ? false : true)}>Process Proposal</Button>
</Grid.Column>
</Grid>
</Grid.Column>
</Grid>
</Segment>
Expand Down
12 changes: 10 additions & 2 deletions packages/moloch-frontend/src/components/ProposalList.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,17 @@ const ProposalCard = ({ proposal }) => {


const ProposalList = (props) => {
let hasItem = false;
// eslint-disable-next-line array-callback-return
Object.keys(props.proposals).map((key, idx) => {
if(props.proposals[key].length > 0){
hasItem = true;
return true;
}
});
return (
<div id="proposal_list">
{Object.keys(props.proposals).length > 0 ? null : <>
{hasItem > 0 ? null : <>
<Grid columns={16} verticalAlign="middle">
<Grid.Column mobile={16} tablet={8} computer={8} textAlign="left">
<>No proposals to show.</>
Expand Down Expand Up @@ -120,7 +128,7 @@ const ProposalList = (props) => {
<p className="subtext">{props.proposals[key].length} Proposal{props.proposals[key].length > 1 ? 's' : ''}</p>
<p className="title">{(key.charAt(0).toUpperCase() + key.slice(1)).match(/[A-Z][a-z]+|[0-9]+/g).join(" ")}</p>
</Grid.Column>
{idx === 0 && !props.proposals['inProgress'] ?
{idx === 0 && props.proposals['inProgress'].length === 0 ?
<Grid.Column mobile={16} tablet={8} computer={4} textAlign="right" floated="right" className="submit_button">
<Link to={props.userShare && (props.memberStatus === 'àctive' || props.memberStatus === 'founder') ? '/projectproposalsubmission' : '/proposals'} className="link">
<Button size='large' color='red' disabled={props.userShare && (props.memberStatus === 'àctive' || props.memberStatus === 'founder') ? false : true}>Project Proposal</Button>
Expand Down

0 comments on commit 6b9a5c8

Please sign in to comment.