User Redux
User Redux
checkValidateInput = () => {
let isValid = true;
let arrCheck = ['email', 'password', 'name', 'phoneNumber', 'address']
for (let i = 0; i < arrCheck.length; i++) {
if (!this.state[arrCheck[i]]) {
isValid = false;
alert('nhap day du thong tin')
break
}
}
return isValid
}
})
}
render() {
let { password, email, name, phonenumber, address, gender } = this.state
return (
<div className='user-redux-container'>
<div className="title" >
THÊM MỚI NGƯỜI DÙNG
</div>
<div className='user-redux-body'>
<div className='container'>
<div className='row'>
<div className='col-3'>
<label>Email</label>
<input className='form-control' type='email'
value={email}
onChange={(e) => { this.onChangeInput(e,
'email') }}
disabled={this.state.action ===
CRUD_ACTIONS.EDIT ? true : false}
/>
</div>
<div className='col-3'>
<label>Password</label>
<input className='form-control' type='password'
value={password}
onChange={(e) => { this.onChangeInput(e,
'password') }}
disabled={this.state.action ===
CRUD_ACTIONS.EDIT ? true : false}
/>
</div>
<div className='col-3'>
<label>Name</label>
<input className='form-control' type='text'
value={name}
onChange={(e) => { this.onChangeInput(e,
'name') }}
/>
</div>
<div className='col-3'>
<label>Address</label>
<input className='form-control' type='text'
value={address}
onChange={(e) => { this.onChangeInput(e,
'address') }}
/>
</div>
<div className='col-3'>
<label>PhoneNumber</label>
<input className='form-control' type='text'
value={phonenumber}
onChange={(e) => { this.onChangeInput(e,
'phoneNumber') }}
/>
</div>
<div className='col-3'>
<label>Gender</label>
<select className='form-control'
onChange={(e) => { this.onChangeInput(e,
'gender') }}
value={gender}
>
<option>NAM</option>
<option>NU</option>
</select>
</div>
{/* <div className='col-3'>
<label>Vị Trí</label>
<select className='form-control'
onChange={(e) => { this.onChangeInput(e,
'position') }}
value={position}
>
{positions && positions.length > 0 &&
positions.map((item, index) => {
return (
<option
key={index}
value={item.keyMap}
>
{item.valueVi}
</option>
)
})}
</select>
</div> */}
{/* <div className='col-6'>
<label>roleId</label>
<select className='form-control'
onChange={(e) => { this.onChangeInput(e,
'role') }}
value={role}
>
{roles && roles.length > 0 &&
roles.map((item, index) => {
return (
<option
key={index}
value={item.keyMap}
>
{item.valueVi}
</option>
)
})}
</select>
</div> */}
<div className='col-6'>
<label>Image</label>
<div className='preview-img-container'>
<input id='previewImg' type='file' hidden
onChange={(e) =>
this.handleOnchangeImage(e)}
/>
<label className='label-upload'
htmlFor='previewImg'> Tải Ảnh <i className='fas fa-upload'></i></label>
<div className='preview-image'
style={{ backgroundImage: `url(${this.state.previewImg})` }}>
</div>
</div>
</div>
<div className='col-12 mt-3'>
<button className={this.state.action ===
CRUD_ACTIONS.EDIT ? 'btn btn-warning' : 'btn btn-primary'}
onClick={() => this.handleSaveUser()}
>
{this.state.action === CRUD_ACTIONS.EDIT ?
'Save Change' : 'Save'}
</button>
</div>
<div className='col-12 mb-5'>
</div>
</div>
</div>
</div>
</div>
)
}