(this["webpackJsonp@coreui/coreui-free-react-admin-template"]=this["webpackJsonp@coreui/coreui-free-react-admin-template"]||[]).push([[70],{1055:function(a,n,e){"use strict";e.r(n);var i=e(638),t=e(9),d=e(1),c=e(631),r=e.n(c),s=e(632),b=e.n(s),u=e(635),l=e(634),o=e(629),h=e(627),g=e(20),j=e(656),m=e(626),_=e(17),f=b()(r.a);n.default=function(a){a.match;var n=Object(g.g)(),e=Object(d.useState)(!1),c=Object(t.a)(e,2),r=c[0],s=c[1],b=Object(d.useState)([]),O=Object(t.a)(b,2),p=O[0],x=O[1];Object(d.useEffect)((function(){Object(j.a)(x)}),[]);var v=function(){n.goBack()},k=function(){f.fire({icon:"success",title:"Tambah Data Berhasil",showConfirmButton:!1,timer:1500}).then((function(a){n.push("/epekerja/admin/master-data/sub-bidang")}))},B=function(a){var n="";for(var e in a)n+="".concat(a[e],", ");f.fire({icon:"error",title:"Tambah Data Gagal",text:n}).then((function(a){s(!1)}))},y=u.c().shape({id_bidang:u.e().required("Bidang harus dipilih!"),nama_sub_bidang:u.e().required("Sub Bidang harus diisi!"),keterangan:u.e().required("Keterangan harus diisi!")}),S=function(a){var n=new FormData;n.append("id_bidang",a.id_bidang),n.append("nama_sub_bidang",a.nama_sub_bidang),n.append("keterangan",a.keterangan);var e,t=Object(i.a)(n.entries());try{for(t.s();!(e=t.n()).done;){var d=e.value;console.log(d)}}catch(c){t.e(c)}finally{t.f()}!function(a,n,e,i){n(!0),m.a.post("admin/master-data/sub-bidang",a,{header:{"Content-Type":"multipart/form-data; boundary=".concat(a._boundary)}}).then((function(a){n(!1),e()})).catch((function(a){i(a.response.data.errors)}))}(n,s,k,B)};return Object(_.jsx)(_.Fragment,{children:Object(_.jsxs)(h.h,{children:[Object(_.jsx)(h.l,{children:Object(_.jsx)("h3",{children:"Tambah Sub Bidang"})}),Object(_.jsx)(l.a,{initialValues:{id_bidang:"",nama_sub_bidang:"",keterangan:""},validationSchema:y,onSubmit:function(a){return S(a)},children:function(a){var n=a.values,e=a.errors,i=a.touched,t=a.handleChange,d=a.handleBlur,c=a.handleSubmit;return Object(_.jsxs)(h.x,{onSubmit:c,children:[Object(_.jsx)(h.i,{children:Object(_.jsx)(h.X,{children:Object(_.jsxs)(h.n,{xs:"12",md:"6",children:[Object(_.jsxs)(h.y,{children:[Object(_.jsx)(h.L,{children:"Bidang"}),Object(_.jsxs)(h.Y,{custom:!0,name:"id_bidang",id:"id_bidang",onChange:t,onBlur:d,value:n.id_bidang,className:e.id_bidang&&i.id_bidang?"is-invalid":null,children:[Object(_.jsx)("option",{value:"",children:"-- Pilih Bidang --"}),p.length>0&&p.map((function(a,n){return Object(_.jsx)("option",{value:a.id_bidang,children:a.nama_bidang},n)}))]}),e.id_bidang&&i.id_bidang&&Object(_.jsx)("div",{className:"invalid-feedback",children:e.id_bidang})]}),Object(_.jsxs)(h.y,{children:[Object(_.jsx)(h.L,{htmlFor:"name",children:"Sub Bidang"}),Object(_.jsx)(h.E,{id:"nama_sub_bidang",name:"nama_sub_bidang",placeholder:"Masukkan sub bidang",onChange:t,onBlur:d,value:n.nama_sub_bidang,className:e.nama_sub_bidang&&i.nama_sub_bidang?"is-invalid":null}),e.nama_sub_bidang&&i.nama_sub_bidang&&Object(_.jsx)("div",{className:"invalid-feedback",children:e.nama_sub_bidang})]}),Object(_.jsxs)(h.y,{children:[Object(_.jsx)(h.L,{htmlFor:"name",children:"Keterangan"}),Object(_.jsx)(h.E,{id:"keterangan",name:"keterangan",placeholder:"Masukkan keterangan",onChange:t,onBlur:d,value:n.keterangan,className:e.keterangan&&i.keterangan?"is-invalid":null}),e.keterangan&&i.keterangan&&Object(_.jsx)("div",{className:"invalid-feedback",children:e.keterangan})]})]})})}),Object(_.jsxs)(h.j,{children:[Object(_.jsx)(h.f,{type:"submit",color:"primary",className:"mr-1",disabled:!!r,children:r?Object(_.jsx)("img",{width:21,src:o.e,alt:"load-animation"}):"Simpan"}),Object(_.jsx)(h.f,{type:"button",color:"danger",onClick:v,children:"Kembali"})]})]})}})]})})}},656:function(a,n,e){"use strict";e.d(n,"a",(function(){return t}));var i=e(626),t=function(a){i.a.get("admin/master-data/bidang").then((function(n){a(n.data.data)})).catch((function(a){}))}}}]);
//# sourceMappingURL=70.0e1d6f89.chunk.js.map