-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathChangePasswordForm.js
More file actions
95 lines (75 loc) · 2.89 KB
/
ChangePasswordForm.js
File metadata and controls
95 lines (75 loc) · 2.89 KB
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
"use strict";
import React from 'react';
var Modal = require('../components/Modal');
var userService = require('./user/UserService');
var lib = require('../components/functions');
class ChangePasswordForm extends React.Component {
constructor(props) {
super(props);
this.state = {
user: props.user
};
}
render() {
var $this = this;
var user = $this.state.user;
var header = (
<h3 className="modal-title text-primary">Change Password</h3>
);
var body = (
<form onSubmit={e => {e.preventDefault(); $this.onSubmit.call($this)}}>
<div className="form-group">
<label htmlFor="username">Current Password</label>
<input type="password" className="form-control" id="currentPassword" placeholder="Current Password"
name="currentPassword" value={user.currentPassword} onChange={$this.onChange.bind($this)}/>
</div>
<div className="form-group">
<label htmlFor="password">New Password</label>
<input type="password" className="form-control" id="password" placeholder="New Password"
name="password" value={user.password} onChange={$this.onChange.bind($this)}/>
</div>
<div className="form-group">
<label htmlFor="password">Retype New Password</label>
<input type="password" className="form-control" placeholder="Retype New Password"
id="retypePassword" name="retypePassword" value={user.retypePassword}
onChange={$this.onChange.bind($this)}/>
</div>
<input type="submit" style={{display: 'none'}}/>
</form>
);
var footer = (
<div>
<span className="btn btn-primary pull-right"
onClick={$this.onSubmit.bind($this)}>Change</span>
<span className="btn btn-danger pull-right" style={{marginRight: '10px'}}
onClick={$this.props.onClose}>Cancel</span>
</div>
);
return (
<Modal title={header}
body={body}
footer={footer}
onClose={$this.props.onClose} isOpen={$this.props.isOpen}/>
);
}
onSubmit() {
var $this = this;
userService.changePassword($this.state.user)
.then(() => $this.setState({user: {}}))
;
}
onChange(e) {
var $this = this;
var user = $this.state.user || {};
user[e.target.name] = e.target.value;
$this.setState({
user: user
});
}
}
ChangePasswordForm.defaultProps = {
user: {},
isOpen: false,
onClose: null,
};
module.exports = ChangePasswordForm;