(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-3b8217a8"],{"7bfa":function(e,a,t){"use strict";t("c5f2")},c5f2:function(e,a,t){},efb6:function(e,a,t){"use strict";t.r(a);t("b0c0");var s=function(){var e=this,a=e._self._c;return a("div",{staticClass:"main-content"},[a("breadcumb",{attrs:{page:"Edit Testimoni",folder:"Testimoni",link:"/app/testimony"}}),a("b-row",[a("b-col",{attrs:{md:"12"}},[a("b-overlay",{attrs:{show:e.loading,rounded:"sm"}},[a("b-card",{ref:"formContainer"},[a("b-card",{ref:"formContainer"},[a("b-form",{on:{submit:function(a){return a.preventDefault(),e.handleUpdateTestimony.apply(null,arguments)}}},[a("b-overlay",{attrs:{show:e.loading,rounded:"sm"}},[a("b-form-group",{staticClass:"col-md-12 mb-3",attrs:{label:"Judul Testimoni","label-for":"input-1"}},[a("b-form-input",{directives:[{name:"validate",rawName:"v-validate",value:"required",expression:"'required'"}],class:{input:!0,"is-danger":e.errors.has("judul")},attrs:{placeholder:"Masukkan Judul Testimoni",name:"judul"},model:{value:e.formTestimony.title,callback:function(a){e.$set(e.formTestimony,"title",a)},expression:"formTestimony.title"}}),a("p",{directives:[{name:"show",rawName:"v-show",value:e.errors.has("judul"),expression:"errors.has('judul')"}],staticClass:"text-danger"},[e._v(" "+e._s(e.errors.first("judul"))+" ")])],1),a("b-form-group",{staticClass:"col-md-12 mb-3",attrs:{label:"Deskripsi","label-for":"input-1"}},[a("b-form-textarea",{directives:[{name:"validate",rawName:"v-validate",value:"required",expression:"'required'"}],class:{input:!0,"is-danger":e.errors.has("deskripsi")},attrs:{placeholder:"Masukkan Deskripsi Testimoni",name:"deskripsi"},model:{value:e.formTestimony.desc,callback:function(a){e.$set(e.formTestimony,"desc",a)},expression:"formTestimony.desc"}}),a("p",{directives:[{name:"show",rawName:"v-show",value:e.errors.has("deskripsi"),expression:"errors.has('deskripsi')"}],staticClass:"text-danger"},[e._v(" "+e._s(e.errors.first("deskripsi"))+" ")])],1),a("b-form-group",{staticClass:"col-md-12 mb-3",attrs:{label:"Nama","label-for":"input-1"}},[a("b-form-input",{directives:[{name:"validate",rawName:"v-validate",value:"required",expression:"'required'"}],class:{input:!0,"is-danger":e.errors.has("nama")},attrs:{placeholder:"Masukkan Nama",name:"nama"},model:{value:e.formTestimony.name,callback:function(a){e.$set(e.formTestimony,"name",a)},expression:"formTestimony.name"}}),a("p",{directives:[{name:"show",rawName:"v-show",value:e.errors.has("nama"),expression:"errors.has('nama')"}],staticClass:"text-danger"},[e._v(" "+e._s(e.errors.first("nama"))+" ")])],1),a("b-form-group",{staticClass:"col-md-12 mb-3",attrs:{label:"Pekerjaan","label-for":"input-1"}},[a("b-form-input",{directives:[{name:"validate",rawName:"v-validate",value:"required",expression:"'required'"}],class:{input:!0,"is-danger":e.errors.has("pekerjaan")},attrs:{placeholder:"Masukkan Pekerjaan",name:"pekerjaan"},model:{value:e.formTestimony.job_title,callback:function(a){e.$set(e.formTestimony,"job_title",a)},expression:"formTestimony.job_title"}}),a("p",{directives:[{name:"show",rawName:"v-show",value:e.errors.has("pekerjaan"),expression:"errors.has('pekerjaan')"}],staticClass:"text-danger"},[e._v(" "+e._s(e.errors.first("pekerjaan"))+" ")])],1),a("b-form-group",{staticClass:"col-md-12 mb-3",attrs:{label:"Upload Image","label-for":"input-1"}},[null!==e.formTestimony.image_url?a("a",{attrs:{href:e.formTestimony.image_url,target:"_blank"}},[a("img",{staticClass:"img-fluid mb-2",staticStyle:{"max-width":"250px"},attrs:{src:e.formTestimony.image_url,alt:""}})]):e._e(),a("b-form-file",{directives:[{name:"validate",rawName:"v-validate",value:"size:500",expression:"'size:500'"}],class:{input:!0,"is-danger":e.errors.has("image")},attrs:{placeholder:"Choose a file or drop it here...","drop-placeholder":"Drop file here...",accept:"image/jpg, image/jpeg, image/png",name:"image"},on:{change:e.setImage},model:{value:e.formTestimony.setImage,callback:function(a){e.$set(e.formTestimony,"setImage",a)},expression:"formTestimony.setImage"}}),a("p",{directives:[{name:"show",rawName:"v-show",value:e.errors.has("image"),expression:"errors.has('image')"}],staticClass:"text-danger"},[e._v(" "+e._s(e.errors.first("image"))+" ")])],1),a("b-form-group",{staticClass:"col-md-12 mb-3",attrs:{label:"Klien"}},[a("b-form-select",{directives:[{name:"validate",rawName:"v-validate",value:"required",expression:"'required'"}],class:{input:!0,"is-danger":e.errors.has("klien")},attrs:{options:e.sources,"value-field":"source_id","text-field":"source_name","disabled-field":"disabled",name:"klien"},model:{value:e.formTestimony.source,callback:function(a){e.$set(e.formTestimony,"source",a)},expression:"formTestimony.source"}}),a("p",{directives:[{name:"show",rawName:"v-show",value:e.errors.has("klien"),expression:"errors.has('klien')"}],staticClass:"text-danger"},[e._v(" "+e._s(e.errors.first("klien"))+" ")])],1),a("b-col",{attrs:{md:"12"}},[a("b-button",{staticClass:"mt-3",attrs:{type:"submit",variant:"primary",disabled:e.loading}},[e._v(" Save ")])],1)],1)],1)],1)],1)],1)],1)],1)],1)},r=[],i=(t("99af"),t("caad"),t("14d9"),t("2532"),{data:function(){return{formTestimony:{id:null,title:"",desc:"",name:"",job_title:"",status:!1,source:null,setImage:null,image_url:null,source_name:""},sources:[],userSource:!1,loading:!1}},mounted:function(){this.getDetailTestimony(),this.loadSources()},methods:{getDetailTestimony:function(){var e=this,a=this.$route.params.uuid;this.$http.get("".concat("https://orchestrator.bwa.id/api/v1/","testimoni/").concat(a),{headers:{Authorization:"Bearer ".concat(this.$store.getters["accessToken"])}}).then((function(a){var t=a.data;e.loading=!1,e.formTestimony={id:t.testimoni_id,title:t.testimoni_title,desc:t.testimoni_desc,name:t.testimoni_name,job_title:t.testimoni_job_title,status:t.is_active,source:t.source_id,image_url:t.testimoni_image_url,setImage:null,source_name:""},null!==e.$store.getters.accountData.source_id?(e.userSource=!0,e.loadSourceUser(t.source_id)):e.loadSources()})).catch((function(){e.loading=!1,e.$store.dispatch("error","Maaf, terjadi kesalahan")}))},loadSources:function(){var e=this;this.$http.get("".concat("https://orchestrator.bwa.id/api/v1/","white-labels"),{headers:{Authorization:"Bearer ".concat(this.$store.getters["accessToken"])}}).then((function(a){var t=a.data;e.sources=t.data,e.sources.unshift({source_id:null,source_name:"Pilih Klien",disabled:!0})})).catch((function(a){e.$store.dispatch("error","Maaf, terjadi kesalahan")}))},loadSourceUser:function(){var e=this,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";this.$http.get("".concat("https://orchestrator.bwa.id/api/v1/","white-labels/").concat(a),{headers:{Authorization:"Bearer ".concat(this.$store.getters["accessToken"])}}).then((function(a){var t=a.data;e.formTestimony.source_name=t.source_name})).catch((function(a){e.$store.dispatch("error","Maaf, terjadi kesalahan")}))},setImage:function(e){var a=e.target.files[0];if(a.size>5e5)this.formTestimony.setImage=null,e.target.value=null,this.$store.dispatch("error","file terlalu besar, harus dibawah 500 kb");else{if(!a.type.includes("image/"))return this.formTestimony.setImage=null,void alert("Please select an image file");if("function"===typeof FileReader){var t=new FileReader;t.onload=function(e){},t.readAsDataURL(a)}else this.formTestimony.setImage=null,alert("Sorry, FileReader API not supported")}},handleUpdateTestimony:function(){var e=this;this.loading=!0;var a=this.$loading.show({container:this.$refs.formContainer});this.$validator.validateAll().then((function(t){if(t){var s=new FormData;s.append("testimoni_title",e.formTestimony.title),s.append("testimoni_desc",e.formTestimony.desc),s.append("testimoni_name",e.formTestimony.name),s.append("testimoni_job_title",e.formTestimony.job_title),null!==e.formTestimony.setImage&&""!==e.formTestimony.setImage&&s.append("testimoni_image",e.formTestimony.setImage),null!==e.formTestimony.source&&s.append("source_id",e.formTestimony.source),s.append("_method","PATCH"),e.$http.post("".concat("https://orchestrator.bwa.id/api/v1/","testimoni/").concat(e.formTestimony.id),s,{headers:{Authorization:"Bearer ".concat(e.$store.getters["accessToken"])}}).then((function(t){200===t.status&&(a.hide(),e.$store.dispatch("success","testimoni berhasil diupdate"),e.$router.push("/app/testimony"),e.loading=!1)})).catch((function(t){e.loading=!1,a.hide(),e.$store.dispatch("error",t)}))}else a.hide(),e.loading=!1}))}}}),o=i,n=(t("7bfa"),t("2877")),l=Object(n["a"])(o,s,r,!1,null,"9361d63c",null);a["default"]=l.exports}}]);