Guest User

Untitled

a guest
Apr 28th, 2017
26
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.29 KB | None | 0 0
  1. import React from 'react';
  2.  
  3. export default class EditUserForm extends React.Component {
  4. constructor() {
  5. super();
  6.  
  7. this.state = {
  8. firstName: '',
  9. lastName: '',
  10. userName: '',
  11. role: '',
  12. department: '',
  13. email: '',
  14. password:''
  15. };
  16.  
  17. // this.handleChange = this.handleChange.bind(this);
  18. }
  19.  
  20. componentWillReceiveProps(nextProps) {
  21. this.setState({
  22. firstName: nextProps.user.firstname,
  23. lastName: nextProps.user.lastname,
  24. userName: nextProps.user.username,
  25. role: nextProps.user.roles_name,
  26. // department: nextProps.user.department_id,
  27. email: nextProps.user.email,
  28. // password: nextProps.user.password
  29. });
  30. }
  31.  
  32. handleChange(e) {
  33. // let firstName = e.target.firstname;
  34. // let lastName = e.target.lastName;
  35. // let userName = e.target.userName;
  36. // let role = e.target.role;
  37. // let email = e.target.email;
  38.  
  39. this.state({
  40. [e.target.name]: 'test',
  41. // [e.target.name]: e.target.value,
  42. // [lastName]: e.target.value
  43. // [userName]: e.target.value
  44. // [role]: e.target.value
  45. // [email]: e.target.value
  46. })
  47. }
  48.  
  49.  
  50. sendUser() {
  51. this.props.onClick(this.state);
  52. }
  53.  
  54. render() {
  55.  
  56. return(
  57. <div>
  58. <form className="form-horizontal" role="form" method="POST">
  59. {/*{{ csrf_field() }}*/}
  60. <div className="col-md-12">
  61. <div className="form-group{{ $errors->has('firstname') ? ' has-error' : '' }}">
  62. <label htmlFor="firstname" className="col-md-4">First Name</label>
  63.  
  64. <div className="col-md-8">
  65. <input id="firstname" type="text" className="form-control" name="firstName"
  66. onChange={this.handleChange} value={this.state.firstName} required />
  67.  
  68. {/*@if ($errors->has('firstname'))*/}
  69. {/*<span className="help-block">*/}
  70. {/*<strong>{{ $errors->first('firstname') }}</strong>*/}
  71. {/*</span>*/}
  72. {/*@endif*/}
  73. </div>
  74. </div>
  75. </div>
  76. <div className="col-md-12">
  77. <div className="form-group{{ $errors->has('lasttname') ? ' has-error' : '' }}">
  78. <label htmlFor="firstname" className="col-md-4">Last Name</label>
  79.  
  80. <div className="col-md-8">
  81. <input id="firstname" type="text" className="form-control" name="lastName"
  82. onChange={this.handleChange} value={this.state.lastName} required />
  83.  
  84. {/*@if ($errors->has('firstname'))*/}
  85. {/*<span className="help-block">*/}
  86. {/*<strong>{{ $errors->first('firstname') }}</strong>*/}
  87. {/*</span>*/}
  88. {/*@endif*/}
  89. </div>
  90. </div>
  91. </div>
  92. <div className="col-md-12">
  93. <div className="form-group{{ $errors->has('firstname') ? ' has-error' : '' }}">
  94. <label htmlFor="firstname" className="col-md-4">User Name</label>
  95.  
  96. <div className="col-md-8">
  97. <input id="firstname" type="text" className="form-control" name="userName"
  98. onChange={this.handleChange} value={this.state.userName} required />
  99.  
  100. {/*@if ($errors->has('firstname'))*/}
  101. {/*<span className="help-block">*/}
  102. {/*<strong>{{ $errors->first('firstname') }}</strong>*/}
  103. {/*</span>*/}
  104. {/*@endif*/}
  105. </div>
  106. </div>
  107. </div>
  108. <div className="col-md-12">
  109. <div className="form-group{{ $errors->has('role') ? ' has-error' : '' }}">
  110. <label htmlFor="role" className="col-md-4">Role</label>
  111.  
  112. <div className="col-md-8">
  113. <input id="role" type="text" className="form-control" name="role"
  114. onChange={this.handleChange} value={this.state.role} required />
  115.  
  116. {/*@if ($errors->has('firstname'))*/}
  117. {/*<span className="help-block">*/}
  118. {/*<strong>{{ $errors->first('firstname') }}</strong>*/}
  119. {/*</span>*/}
  120. {/*@endif*/}
  121. </div>
  122. </div>
  123. </div>
  124. <div className="col-md-12">
  125. <div className="form-group{{ $errors->has('email') ? ' has-error' : '' }}">
  126. <label htmlFor="email" className="col-md-4">E-mail Address</label>
  127.  
  128. <div className="col-md-8">
  129. <input id="email" type="text" className="form-control" name="email"
  130. onChange={this.handleChange} value={this.state.email} required />
  131.  
  132. {/*@if ($errors->has('firstname'))*/}
  133. {/*<span className="help-block">*/}
  134. {/*<strong>{{ $errors->first('firstname') }}</strong>*/}
  135. {/*</span>*/}
  136. {/*@endif*/}
  137. </div>
  138. </div>
  139. </div>
  140. </form>
  141. </div>
  142. )
  143. }
  144. }
Add Comment
Please, Sign In to add comment