text: import Axios from 'axios';
  import React, { Component } from 'react';
  import Swal from 'sweetalert2'
  import toast, { Toaster } from 'react-hot-toast';
  
  class EditRider extends Component {
      constructor(props) {
          super(props);
          this.state={
              name:'',
              username:'',
              password:'',
              confirm_password:'',
              address:'',
              phone:'',
              error_string:'',
              id:this.props.match.params.id,
              status:1
          }
      }
      componentDidMount(){
         Axios.post('/api/get_rider_by_id',{ id:this.props.match.params.id}).then(res=>{
             console.log(res);
             this.setState({
                 name:res.data.name,
                 address:res.data.address,
                 username:res.data.username,
                 password:res.data.password,
                 confirm_password:res.data.password,
                 status:res.data.status,
                 phone:res.data.phone
             })
         })
      }
      address(e){
          this.setState({
              address:e.target.value
          })
      }
      name(e){
          this.setState({
              name:e.target.value
          })
      }
      phone(e){
          this.setState({
              phone:e.target.value
          })
      }
      username(e){
          this.setState({
              username:e.target.value
          })
      }
  
     
      password(e){
          this.setState({
              password:e.target.value
          })
      }
      confirm_password(e){
          this.setState({
              confirm_password:e.target.value
          })
      }
      status(e){
          this.setState({
              status:e.target.value
          })
      }
      Update_client_account(){
       
                  Axios.post('/api/update_rider',this.state).then(res=>{
                          console.log(res);
                          if(res.data.status){
                            toast.success('Rider Updated SuccessFully');
                            this.props.history.push('/admin/manage-riders')
  
                          }else{
                              this.setState({
                                  error_string:res.data.message
                              })
                              toast.error('Error - '+res.data.message);
                          }
                  })
  
          
      }
      render() {
          return (
              <div>
                  
                  <div className="container">
                  <div className="top_section_title_div">
                      <h2 className="section_title">Edit Rider Account</h2>
                  </div>
                      <div className="card mt-3 p-3">
                          <div className="row col-md-12">
                              <div class="form-group input_div col-md-6">
                                  <label className="input_label" for="exampleInputEmail1"> Name</label>
                                  <input value={this.state.name } onChange={this.name.bind(this)} type="Name" class="form-control "  aria-describedby="emailHelp"  />
                              </div>
                              <div class="form-group input_div col-md-6">
                                  <label className="input_label" for="exampleInputEmail1"> Address</label>
                                  <input value={this.state.address} onChange={this.address.bind(this)} type="Name" class="form-control "  aria-describedby="emailHelp" />
                              </div>
                              <div class="form-group input_div col-md-6">
                                  <label className="input_label" for="exampleInputEmail1">Username</label>
                                  <input disabled value={this.state.username} onChange={this.username.bind(this)}  type="email" class="form-control "  aria-describedby="emailHelp" />
                              </div>
                            
                              <div class="form-group input_div col-md-6">
                                  <label className="input_label" for="exampleInputEmail1"> Phone</label>
                                  <input value={this.state.telephone} onChange={this.phone.bind(this)}  type="email" class="form-control "  aria-describedby="emailHelp"  />
                              </div>
                          </div>
                          <div className="row col-md-12">
                              <div class="form-group input_div col-md-6">
                                  <label className="input_label" for="exampleInputEmail1">Password</label>
                                  <input value={this.state.password } onChange={this.password.bind(this)} type="email" class="form-control "  aria-describedby="emailHelp"  />
                              </div>
                              <div class="form-group input_div col-md-6">
                                  <label className="input_label" for="exampleInputEmail1">Confirm Password</label>
                                  <input value={this.state.confirm_password } onChange={this.confirm_password.bind(this)} type="email" class="form-control " aria-describedby="emailHelp"  />
                              </div>
                             
                              <div class="form-group input_div col-md-6">
                                  <label className="input_label" for="exampleInputEmail1">Status</label>
                                  <select value={this.state.status } onChange={this.status.bind(this)} type="email" class="form-control " aria-describedby="emailHelp"  
                                  >
                                      <option value = {1}>Active</option>
                                      <option value = {0}>Disabled</option>
                                  </select>
                              </div>
                          </div>
  
                          {
                              this.state.error_string != '' ?
                              <p className="text-center text-danger">{this.state.error_string}</p>
                              : null
                          }
                          <div className="mt-3 ml-3 mb-3">
                              <button onClick={this.Update_client_account.bind(this)} className="btn btn-success">Save</button>
                          </div>
                      </div>
                  </div>
                 
              </div>
          );
      }
  }
  export default EditRider;