-
Notifications
You must be signed in to change notification settings - Fork 16
/
Join.js
92 lines (80 loc) · 3.02 KB
/
Join.js
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
import React from 'react';
import Axios from 'axios';
import Config from '../../Config';
import ReCAPTCHA from 'react-google-recaptcha';
class Join extends React.Component {
constructor(props) {
super(props);
this.state = {
error: []
};
}
register(event) {
event.preventDefault();
var form = new FormData(this.refs.form);
Axios.post('join', form).then((response) => {
console.log(response.data);
if (response.data.success) {
console.log("Success");
this.props.openPopup("Welcome!", "Your account has been registered successfully. We're glad to have you on board!");
this.props.close();
} else {
this.setState({error: response.data.error});
console.log(response.data.error);
console.log("Failure");
}
});
}
recaptchaOnChange(value) {
console.log("Captcha value:", value);
}
render() {
if (!this.props.open) {
this.state = {
error: []
};
return null;
}
if (this.state.error.length) {
var alert = (
<div className="alert">{this.state.error}</div>
);
}
return (
<div className="join">
<form onSubmit={this.register.bind(this)} ref="form">
<div className="prompt-close" onClick={this.props.close}>✖</div>
<div className="prompt-title">Join {Config.server_name}</div>
<div>
<label htmlFor="name">Name</label>
<input className="text" name="name" type="text" />
</div>
<div>
<label htmlFor="email">Email</label>
<input className="text" name="email" type="email" />
</div>
<div>
<label htmlFor="mapleid">MapleID</label>
<input className="text" name="mapleid" type="text" />
</div>
<div>
<label htmlFor="password">Password</label>
<input className="password" name="password" type="password" />
</div>
<div>
<label htmlFor="confirm">Confirm</label>
<input className="confirm" name="password_confirmation" type="password" />
</div>
<div className="repatcha-container">
<ReCAPTCHA className="recaptcha" ref="recaptcha" onChange={this.recaptchaOnChange} sitekey={Config.recaptcha_key} />
</div>
{alert}
<div>
<input className="button" type="submit" value="Join" />
</div>
</form>
</div>
);
}
}
export default Join;