-
Notifications
You must be signed in to change notification settings - Fork 0
/
donate.txt
115 lines (98 loc) · 3.62 KB
/
donate.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
import React, { Component } from "react";
import { Link, withRouter } from "react-router-dom";
import PropTypes from "prop-types";
import { connect } from "react-redux";
import { updateFunds } from "../../actions/authActions";
import classnames from "classnames";
import axios from 'axios';
import BrowseProjectsAlum from './BrowseProjectsAlum';
class Donate extends Component {
constructor(props) {
super(props);
console.log(this.props.id);
this.state = {
project: '',
funds_donated: ''
}
}
onChange = e => {
this.setState({ [e.target.id]: e.target.value });
};
onSubmit = e => {
e.preventDefault();
const newProjectData = {
project_id: this.state.project._id,
funds_donated: this.state.funds_donated,
funds_required: this.state.project.funds_required - this.state.funds_donated
};
this.props.updateFunds(newProjectData,this.props.history);
};
componentDidMount() {
axios.get("/api/users/donate")
.then(res=> this.setState({project:res.data}))
.catch(err=>console.log(err))}
render() {
const { user } = this.props.auth;
const {proj} = this.props.id;
return (
<div className="container">
<div className="row">
<div className="col s8 offset-s2">
<Link to="/browseProjectsAlum" className="btn-flat waves-effect">
<i className="material-icons left">keyboard_backspace</i> Back
</Link>
{proj}
<div className="col s12" style={{ paddingLeft: "11.250px" }}>
<h4>
<b>Add new project below</b>
</h4>
{/*
<p className="grey-text text-darken-1">
Already have an account? <Link to="/login">Log in</Link>
</p>
*/}
</div>
<form noValidate onSubmit={this.onSubmit}>
<div className="input-field col s12">
<input
onChange={this.onChange}
value={this.state.funds_donated}
id="funds_donated"
type="number"
className={classnames("")}
/>
<label htmlFor="funds_donated">Please Enter the amount of funds</label>
<span className="red-text"></span>
</div>
<div className="col s12" style={{ paddingLeft: "11.250px" }}>
<button
style={{
width: "150px",
borderRadius: "3px",
letterSpacing: "1.5px",
marginTop: "1rem"
}}
type="submit"
className="btn btn-large waves-effect waves-light hoverable blue accent-3"
>
Confirm
</button>
</div>
</form>
</div>
</div>
</div>
);
}
}
Donate.propTypes = {
updateFunds: PropTypes.func.isRequired,
auth: PropTypes.object.isRequired
};
const mapStateToProps = state => ({
auth: state.auth
});
export default connect(
mapStateToProps,
{ updateFunds }
)(withRouter(Donate));