<template>
  <v-layout row>
    <v-flex xs6 mr-1>
      <v-card>
        <v-card-title
            class="headline grey darken-1 pt-2 pb-2"
            primary-title
            style="color:white"
        >
        <h4 >Email Konfigurasi</h4>
        </v-card-title>
        <v-card-text class="pt-2 pb-2">
          <v-layout row>
            <v-flex xs6 pa-2 d-flex>
               <v-text-field
                  v-model="server"
                  label="Server"
                ></v-text-field>
            </v-flex>
            <v-flex xs6 pa-2 d-flex>
               <v-text-field
                  v-model="sender"
                  label="Pengirim"
                ></v-text-field>
            </v-flex>
          </v-layout> 
          <v-layout row>
            <v-flex xs6 pa-2 d-flex>
               <v-text-field
                  v-model="emailcc"
                  label="Email CC"
                ></v-text-field>
            </v-flex>
            <v-flex xs6 pa-2 >
                <v-text-field
                  v-model="maxretry"
                  label="Maksimal Pengulangan Pengiriman Otomatis"
                ></v-text-field>
            </v-flex>
          </v-layout>
          <v-layout row>
            <v-flex xs12 class="text-md-center" pa-2 d-flex>
              <h4>FORMAT EMAIL</h4>
            </v-flex>
          </v-layout> 
          <v-layout row>
            <v-flex xs12 pa-2 d-flex>
              <v-textarea
                filled
                solo
                background-color="amber lighten-4"
                color="orange orange-darken-4"
                label="Outline textarea"
                v-model="formatemail"
                rows="18"
              ></v-textarea>
            </v-flex>
          </v-layout> 
        </v-card-text>
        <v-divider></v-divider>
        <v-card-actions>
          <v-spacer></v-spacer>
          <v-btn color="error" flat>Baca dong !</v-btn>
          <v-btn color="black" flat>Tutup</v-btn>
        </v-card-actions>
      </v-card>
    </v-flex>
    <v-flex xs6 ml-1>
      <v-card>
        <v-card-title
            class="headline grey darken-1 pt-2 pb-2"
            primary-title
            style="color:white"
        >
        <h4 >Tampilan Email</h4>
        </v-card-title>
        <v-card-text class="pt-2 pb-2">
          <v-layout row>
            <v-flex xs12 pa-2 v-html="formatemail">
              
            </v-flex>
          </v-layout> 
          </v-layout> 
        </v-card-text>
      </v-card>
    </v-flex>
  </v-layout>
</template>

<style scoped>

</style>

<script>
module.exports = {
  data: () => ({
    sender:'Home Service<kita.sms.love@gmail.com>',
    server:'smtp.gmail.com',
    username:'kita.sms.love@gmail.com',
    password:'pgbogxyurbhhsudp',
    maxretry:0,
    emailcc:'fajri@gmail.com',
    formatemail:""
  }),
  mounted() {
      
  },
  computed: {
     
  },
  methods : {
    
  }
}
</script>
   context.commit("update_save_status", 1)
            context.commit("update_error_code", false)
            context.commit("update_error_name", false)
            try {
                prm.token = one_token()
                let resp = await api.save(prm)
                if (resp.status != "OK") {
                    context.commit("update_save_status", 3)
                    context.commit("update_save_error_message", resp.message)
                } else {
                    context.commit("update_save_status", 2)
                    context.commit("update_save_error_message", resp.message)
                    context.commit("update_save_error_message", resp.message)
                    var data = {
                        records: resp.data.records,
                        total: resp.data.total
                    }

                    if(data.total !== -1){
                        context.commit("update_errors",[])
                        context.commit("update_alert_success", true)
                        context.commit("update_dialog_form_bahan", false)
                        var msg = "Bahan " + prm.name + " sudah tersimpan dong ..."
                        context.commit("update_msg_success", msg)
                        context.dispatch("lookup", { search: "" , all:context.show_all})
                    }else{
                        context.commit("update_errors", resp.data.errors)
                     
                    }
                    
                }
            } catch (e) {
                context.commit("update_save_status", 3)
                context.commit("update_save_error_message", e.message)
                console.log(e)
            }
        },
        async update(context, prm) {
            context.commit("update_save_status", 1)
            context.commit("update_error_code", false)
            context.commit("update_error_name", false)
            try {
                prm.token = one_token()
                let resp = await api.update(prm)
                if (resp.status != "OK") {
                    context.commit("update_save_status", 3)
                    context.commit("update_save_error_message", resp.message)
                } else {
                    context.commit("update_save_status", 2)
                    context.commit("update_save_error_message", resp.message)
                    context.commit("update_save_error_message", resp.message)
                    let data = {
                        records: resp.data.records,
                        total: resp.data.total
                    }

                    if(data.total !== -1){
                        context.commit("update_error_code", false)
                        context.commit("update_error_name", false)
                        context.commit("update_alert_success", true)
                        context.commit("update_dialog_form_bahan", false)
                        var msg = "Bahan " + prm.name + " sudah terupdate dong ..."
                        context.commit("update_msg_success", msg)
                        context.dispatch("lookup", { search: "" , all:context.show_all})
                    }else{
                        if(resp.data.errorcode === 'Y'){
                            context.commit("update_error_code", true)
                        }
                        if(resp.data.errorname === 'Y'){
                            context.commit("update_error_name", true)
                        }
                    }
                    
                }
            } catch (e) {
                context.commit("update_save_status", 3)
                context.commit("update_save_error_message", e.message)
                console.log(e)
            }
        },
        async delete(context, prm) {
            context.commit("update_save_status", 1)
            try {
                let resp = await api.xdelete(one_token(),prm.bahanid)
                if (resp.status != "OK") {
                    context.commit("update_save_status", 3)
                    context.commit("update_save_error_message", resp.message)
                } else {
                    context.commit("update_save_status", 2)
                    context.commit("update_save_error_message", resp.message)
                    context.commit("update_alert_success", true)

                    var msg = "Schedule " + prm.bahanname + " sudah dihapus dong"
                    context.commit("update_msg_success", msg)
                    context.commit("update_alert_success", true)
                    context.commit("update_selected_bahan", {})
                    context.dispatch("lookup", { search: "" })
                    context.commit("sampletype/update_bahan_sampletype", [], { root: true })
                }
            } catch (e) {
                context.commit("update_save_status", 3)
                console.log(e)
            }
        }
    }
}