<template>
    <form @submit.prevent="update">
        
        <div class="form-group row">
          <div class="col-md-6">
            <label for="email">Email Address</label>
            <input type="text" class="form-control" name="email" id="email" v-model="fields.email" placeholder="Enter email..."/>
            <div v-if="errors && errors.email" class="text-danger">{{ errors.email[0] }}</div>
          </div>
          <div class="col-md-6">
            <label for="surname">Surname</label>
            <input type="hidden" class="form-control" name="id" id="id" v-model="fields.id"/>
            <input type="text" class="form-control" name="surname" id="surname" v-model="fields.surname"/>
            <div v-if="errors && errors.surname" class="text-danger">{{ errors.surname[0] }}</div>
          </div>
	
          <div class="col-md-6">
            <label for="othername">Othername(s)</label>
            <input type="text" class="form-control" name="othername" id="othername" v-model="fields.othername"/>
            <div v-if="errors && errors.othername" class="text-danger">{{ errors.othername[0] }}</div>
          </div>

          <div class="col-md-6">
            <label for="username">Username(s)</label>
            <input type="text" class="form-control" name="username" id="username" v-model="fields.username"/>
            <div v-if="errors && errors.username" class="text-danger">{{ errors.username[0] }}</div>
          </div> 

          <div class="col-md-6">
            <label for="password">Password</label>
            <input type="password" class="form-control" name="password" id="password" v-model="fields.password"/>
            <div v-if="errors && errors.password" class="text-danger">{{ errors.password[0] }}</div>
          </div>
          <div class="col-md-6">
              <label for="cpassword">Confirm Password</label>
              <input type="password" class="form-control" name="password_confirmation" id="password_confirmation" v-model="fields.password_confirmation" placeholder="Confirm password..."/>
              <div v-if="errors && errors.password_confirmation" class="text-danger">{{ errors.password_confirmation[0] }}</div>
          </div>
        </div>
        <div class="form-group">
            <button type="submit" class="btn btn-success btn-round">Save</button>
            <button type="reset" class="btn btn-danger btn-round">Clear</button>
        </div>       
      
    </form>
</template>

<script>
import FormMixin from '../shared/FormMixin';

export default {
  mixins: [ FormMixin ],
   props: [
            'admindata',
        ],
        
  data() {
    return {
      'text': 'Admin Updated succesfully',
      'redirect': '/fc/admin/admin-user',
      action2: '/fc/admin/editAdmin',
      fields:{
        id: this.admindata.admin_id,
        email:this.admindata.email,
        surname:this.admindata.admin_surname,
        othername:this.admindata.admin_othername,
        username:this.admindata.admin_username,
      }

    }
    
    
  },
  mounted() {
            this.fields.id= this.admindata.admin_id;
            this.fields.email=this.admindata.email;          
            this.fields.surname=this.admindata.admin_surname;          
            this.fields.othername=this.admindata.admin_othername;
            this.fields.username==this.admindata.admin_username;
            console.log(this.admindata);
        }
}
</script>