Skip to content

Commit

Permalink
conflicts recovered
Browse files Browse the repository at this point in the history
  • Loading branch information
Mihir Shah committed Feb 2, 2019
2 parents 8ae93aa + b10eb38 commit 4ffb068
Show file tree
Hide file tree
Showing 8 changed files with 377 additions and 94 deletions.
20 changes: 17 additions & 3 deletions Client/src/components/Add Project/addproject.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class addproject extends Component {
if (typeof window.web3 !== 'undefined') {
console.log('web3 is enabled');
if (web3.currentProvider.isMetaMask === true) {
contract = new web3.eth.Contract(abi, address);
await this.setState({isMetaMask: true});
console.log('MetaMask is active');
} else {
Expand All @@ -33,23 +34,36 @@ class addproject extends Component {

}
addProject= async(event)=>{
contract = new web3.eth.Contract(abi, address);

console.log(contract);
event.preventDefault();
const data= new FormData(event.target);
const pname=data.get("pname");
const pdescription=data.get("pdescription");
const pcost=data.get("pcost");

const accounts = await web3.eth.getAccounts();
await(contract.methods.AddProject(pcost,pname,pdescription).send({

console.log(web3.utils.toWei(pcost));
var receipt=await(contract.methods.AddProject(pname,pdescription).send({
"from":accounts[0],
"value":web3.utils.toWei(pcost)

})
);


// console.log(receipt);

console.log(pname + pdescription + pcost);
}

projecttest=async(event)=>{

const accounts = await web3.eth.getAccounts();
const response=await contract.methods.lenP().call();
console.log(response);
}

render() {
return (
Expand Down Expand Up @@ -119,4 +133,4 @@ class addproject extends Component {

}

export default addproject;
export default addproject;
176 changes: 135 additions & 41 deletions Client/src/components/Home/home.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,141 @@
import React, { Component } from "react";
import { Grid, Row, Col,Button, Glyphicon,FormGroup,FormControl,ControlLabel,Form } from "react-bootstrap";
import Header from "../Header/header";
import {abi,address} from "../../project_contract";
import {abi2,address2} from "../../user_contarct";

//import { Card, CardTitle, CardActions, CardText } from "react-mdl";
import "./home.css";
import web3 from "../../web";
let contract;
let userContract;
class home extends Component {
state={
projects:[],

}

async componentDidMount(){
if(web3.currentProvider.isMetaMask===true){
contract=new web3.eth.Contract(abi,address);
userContract=new web3.eth.Contract(abi2,address2);
const accounts=await web3.eth.getAccounts();
const account=accounts[0];
const userNum=await userContract.methods.countUsers().call();

console.log(userNum)
var projects=[]
for(var j=0;j<userNum;j++){
const useraddr=await userContract.methods.Users(j).call();
console.log(useraddr);

const numberProjects=await contract.methods.lenC().call({
"from":useraddr
});
console.log(numberProjects);
if(numberProjects!=0){
for(var i =0;i<numberProjects;i++){

const projectres=await(contract.methods.ProjectMap(useraddr,i)).call();

var dic={};
dic[useraddr]=projectres;
projects.push(dic);


}
}



}
this.setState({projects:projects});
console.log(this.state.projects);
// for(var i=0;i<numberProjects)


}
}

Bid=async(event)=>{
event.preventDefault();
const data= new FormData(event.target);
const bid=data.get("bid");
const pname=data.get("pname");
const accounts=await web3.eth.getAccounts();
const account=accounts[0];
console.log("bid:",bid,"pname",pname);
const response= await fetch("/api/v1/auction",{
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
pname:pname,
useraddr:account,
bid:bid
}),
});


console.log(response);
}

render() {

const val=this.state.projects;
// console.log(val);
var projects=[]
val.forEach(element => {
console.log(element);
for(var key in element){
// console.log();
var projectname=element[key].pname;

projects.push(
<Grid>
<Row style={{left:"-10px"}}>
<Col xs={12}>
<div className="cards">
<div className="card">
<Grid>
<Row className="cardHeader">
<Col class="Headershift" xs={10}>
<h5>&nbsp;&nbsp; {projectname}</h5>
</Col>
< Col xs={2} >
<Form onSubmit={this.Bid}>
<FormGroup controlId="formHorizontalText">
<Col sm={10}>
<FormControl type="hidden" name="pname" id="pname" value={projectname}/>
<FormControl type="text" id="bid" name="bid" placeholder="Bid" />
<hr/>
</Col>
</FormGroup>
<Col xs={6}>
<Button type="submit" className="btn btn-success"><span class="glyphicon glyphicon-ok">&nbsp;</span>Apply</Button>{" "}
</Col>
</Form>
</Col>
</Row>
<Row className="cardDesc">
<Col xs={10}>
<p>Cost
</p>
</Col>

</Row>
</Grid>
<div className="front">
</div>
</div>
</div>
</Col>
</Row>
</Grid>
)
}
});
return (
// <div><Header/><ProgressBar active now={45} /><ProgressBar>
// <ProgressBar striped bsStyle="success" now={35} key={1} />
Expand Down Expand Up @@ -45,50 +176,13 @@ class home extends Component {
</Grid>
</div>
<div className="bodyclass">
<Grid>
<Row style={{left:"-10px"}}>
<Col xs={12}>
<div className="cards">
<div className="card">
<Grid>
<Row className="cardHeader">
<Col class="Headershift" xs={10}>
<h5>&nbsp;&nbsp; Project Name</h5>
</Col>
<Col xs={2} >
<Form>
<FormGroup controlId="formHorizontalText">
<Col sm={10}>
<FormControl type="text" id="bid" name="bid" placeholder="Bid" />
</Col>
</FormGroup>
</Form>
</Col>
</Row>
<Row className="cardDesc">
<Col xs={10}>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.

{projects}

Why do we use it?
ipsum dolor sit amet...'
</p>
</Col>
<Col xs={1}>
<Button className="btn btn-success"><span class="glyphicon glyphicon-ok">&nbsp;</span>Apply</Button>{" "}
</Col>
</Row>
</Grid>
<div className="front">
</div>
</div>
</div>
</Col>
</Row>
</Grid>
</div>
</div>
);
}
}

export default home;
export default home;
10 changes: 6 additions & 4 deletions Client/src/components/Update Profile/updateprofile.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import {Form, FormGroup,Col,FormControl,Button,ControlLabel,Grid, Row,Glyphicon}
import Header from '../Header/header';
import "./updateprofile.css";
import web3 from '../../web';
import {abi,address} from '../../user_contarct';
import {abi2,address2} from '../../main';
import {abi2,address2} from '../../user_contarct';

import ipfs from '../../ipfs';
import { Redirect } from 'react-router-dom';

Expand All @@ -19,7 +19,7 @@ class updateprofile extends Component {
async componentDidMount(){
console.log(web3.currentProvider.isMetaMask);
if(web3.currentProvider.isMetaMask === true){
contract = new web3.eth.Contract(abi, address);
contract = new web3.eth.Contract(abi2, address2);
console.log(contract);
}

Expand Down Expand Up @@ -93,7 +93,9 @@ class updateprofile extends Component {
const response=await fetch(`/api/v1/user/${account}`);
var data=await (response.json());
console.log(data.publicKey)
var count=await contract.methods.countUsers().call();


var count=await contract.methods.Users(0).call();
console.log(count);
}

Expand Down
Loading

0 comments on commit 4ffb068

Please sign in to comment.