-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Fabian Rittmeier
committed
Jul 1, 2021
1 parent
e90f1ac
commit f321a6f
Showing
576 changed files
with
10,121 additions
and
6,296 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import React, { Component } from 'react'; | ||
import { Form, Input, Message, Button } from 'semantic-ui-react'; | ||
import Campaign from '../ethereum/campaign'; | ||
import web3 from '../ethereum/web3'; | ||
import { Router } from '../routes'; | ||
|
||
class ContributeForm extends Component { | ||
state = { | ||
value: '', | ||
errorMessage: '', | ||
loading: false | ||
}; | ||
|
||
onSubmit = async event => { | ||
event.preventDefault(); | ||
|
||
const campaign = Campaign(this.props.address); | ||
|
||
this.setState({ loading: true, errorMessage: '' }); | ||
|
||
try { | ||
const accounts = await web3.eth.getAccounts(); | ||
await campaign.methods.contribute().send({ | ||
from: accounts[0], | ||
value: web3.utils.toWei(this.state.value, 'ether') | ||
}); | ||
|
||
Router.replaceRoute(`/campaigns/${this.props.address}`); | ||
} catch (err) { | ||
this.setState({ errorMessage: err.message }); | ||
} | ||
|
||
this.setState({ loading: false, value: '' }); | ||
}; | ||
|
||
render() { | ||
return ( | ||
<Form onSubmit={this.onSubmit} error={!!this.state.errorMessage}> | ||
<Form.Field> | ||
<label>Amount to Contribute</label> | ||
<Input | ||
value={this.state.value} | ||
onChange={event => this.setState({ value: event.target.value })} | ||
label="ether" | ||
labelPosition="right" | ||
/> | ||
</Form.Field> | ||
|
||
<Message error header="Oops!" content={this.state.errorMessage} /> | ||
<Button primary loading={this.state.loading}> | ||
Contribute! | ||
</Button> | ||
</Form> | ||
); | ||
} | ||
} | ||
|
||
export default ContributeForm; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import React from 'react'; | ||
import { Menu } from 'semantic-ui-react'; | ||
import { Link } from '../routes'; | ||
|
||
export default () => { | ||
return ( | ||
<Menu style={{ marginTop: '10px' }}> | ||
<Link route="/"> | ||
<a className="item">This is fuckin awesome!</a> | ||
</Link> | ||
|
||
<Menu.Menu position="right"> | ||
<Link route="/"> | ||
<a className="item">Artwork</a> | ||
</Link> | ||
|
||
<Link route="/campaigns/new"> | ||
<a className="item">+</a> | ||
</Link> | ||
</Menu.Menu> | ||
</Menu> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import React from 'react'; | ||
import { Container } from 'semantic-ui-react'; | ||
import Head from 'next/head'; | ||
import Header from './Header'; | ||
|
||
const props = () => { | ||
return ( | ||
<Container> | ||
<Head> | ||
<link | ||
rel="stylesheet" | ||
href="//cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.2.12/semantic.min.css" | ||
/> | ||
</Head> | ||
|
||
<Header /> | ||
{props.children} | ||
</Container> | ||
); | ||
}; | ||
|
||
export default props; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
|
||
import React, { Component } from 'react'; | ||
import { Table, Button } from 'semantic-ui-react'; | ||
import web3 from '../ethereum/web3'; | ||
import Campaign from '../ethereum/campaign'; | ||
|
||
class RequestRow extends Component { | ||
onApprove = async () => { | ||
const campaign = Campaign(this.props.address); | ||
|
||
const accounts = await web3.eth.getAccounts(); | ||
await campaign.methods.approveRequest(this.props.id).send({ | ||
from: accounts[0] | ||
}); | ||
}; | ||
|
||
onFinalize = async () => { | ||
const campaign = Campaign(this.props.address); | ||
|
||
const accounts = await web3.eth.getAccounts(); | ||
await campaign.methods.finalizeRequest(this.props.id).send({ | ||
from: accounts[0] | ||
}); | ||
}; | ||
|
||
render() { | ||
const { Row, Cell } = Table; | ||
const { id, request, approversCount } = this.props; | ||
const readyToFinalize = request.approvalCount > approversCount / 2; | ||
|
||
return ( | ||
<Row | ||
disabled={request.complete} | ||
positive={readyToFinalize && !request.complete} | ||
> | ||
<Cell>{id}</Cell> | ||
<Cell>{request.description}</Cell> | ||
<Cell>{web3.utils.fromWei(request.amount, 'ether')}</Cell> | ||
<Cell>{request.recipient}</Cell> | ||
<Cell> | ||
{request.approvalCount}/{approversCount} | ||
</Cell> | ||
<Cell> | ||
{request.complete ? null : ( | ||
<Button color="green" basic onClick={this.onApprove}> | ||
Approve | ||
</Button> | ||
)} | ||
</Cell> | ||
<Cell> | ||
{request.complete ? null : ( | ||
<Button color="teal" basic onClick={this.onFinalize}> | ||
Finalize | ||
</Button> | ||
)} | ||
</Cell> | ||
</Row> | ||
); | ||
} | ||
} | ||
|
||
export default RequestRow; |
Oops, something went wrong.