import{G as I,r as _,j as a}from"./app-IOXEkjZV.js";import{B as U}from"./Combination-BNwF1qlx.js";import{I as o}from"./input-DSAKdGbg.js";import{L as d}from"./label-vrjuk6Fp.js";import{S as L}from"./switch-fwu1FH6X.js";import{S as g,a as f,b as v,c as b,d as u}from"./select-Ce0S2nMA.js";import{I as n}from"./InputError-CA_Ojqjw.js";import{T as C}from"./textarea-D2UMVNLS.js";import"./index-2qmCrqIB.js";import"./utils-CytzSlOG.js";import"./createLucideIcon-CiCxt4rN.js";import"./index-Dygw6O6N.js";import"./index-Cg-qGOAP.js";import"./index-4MJacFxF.js";function aa({peserta:e}){var N,w,F;const{data:i,setData:p,post:P,errors:l}=I(e!=null?{nama_lengkap:e.nama_lengkap,email:e.email??(e.user!=null?e.user.email:""),alamat:e.alamat,no_hp:e.no_hp,tempat_lahir:e.tempat_lahir,tanggal_lahir:e.tanggal_lahir,jenis_kelamin:e.jenis_kelamin,foto_ktp:e.foto_ktp,foto_kk:e.foto_kk,foto_profil:e.foto_profil,nik:e.nik,npwp:e.npwp,status_pekerjaan:e.status_pekerjaan,bidang_pekerjaan:e.bidang_pekerjaan,tempat_bekerja:e.tempat_bekerja,alamat_bekerja:e.alamat_bekerja,agama:e.agama,file_bukti_usaha:e.file_bukti_usaha,kriteria_usaha:e.kriteria_usaha,file_profil_usaha:e.file_profil_usaha,file_ijin_usaha:e.file_ijin_usaha,usia:e.usia,disabilitas:e.disabilitas,status_kawin:e.status_kawin,utusan_dari:e.utusan_dari,_method:"PUT",password:null,password_confirmation:null,provinsi_id:e.provinsi_id??0,kabupaten_id:e.kabupaten_id??0,kecamatan_id:e.kecamatan_id??0,kelurahan_id:e.kelurahan_id??0}:{nama_lengkap:"",email:"",alamat:"",no_hp:"",tempat_lahir:"",tanggal_lahir:new Date,jenis_kelamin:"laki-laki",foto_ktp:"",foto_kk:"",foto_profil:"",status_pekerjaan:"",bidang_pekerjaan:"",tempat_bekerja:"",alamat_bekerja:"",file_bukti_usaha:"",kriteria_usaha:"",file_profil_usaha:"",file_ijin_usaha:"",usia:0,nik:"",npwp:"",agama:"",status_kawin:"",utusan_dari:"",disabilitas:0,_method:"POST",password:null,password_confirmation:null,provinsi_id:0,kabupaten_id:0,kecamatan_id:0,kelurahan_id:0}),[c,j]=_.useState({provinces:[],cities:{},districts:{},villages:{}}),[B,K]=_.useState(null),[D,V]=_.useState(null),[$,S]=_.useState(null),M=s=>{s.preventDefault(),P(e!=null?route("admin.peserta.update",{id:e.id}):route("admin.peserta.store"),{onFinish:()=>console.log("okoc")})},t=s=>{const{name:h,value:m}=s.target;p(r=>({...r,[h]:m})),h==="provinsi_id"?(fetch(route("register.ajax-data","regencies")+`?province_id=${m}`).then(r=>r.json()).then(r=>{j({...c,cities:{...c.cities,[m]:r}})}),p(r=>({...r,kabupaten_id:0,kecamatan_id:0,kelurahan_id:0}))):h==="kabupaten_id"?(fetch(route("register.ajax-data","districts")+`?regency_id=${m}`).then(r=>r.json()).then(r=>{j({...c,districts:{...c.districts,[m]:r}})}),p(r=>({...r,kecamatan_id:0,kelurahan_id:0}))):h==="kecamatan_id"&&(fetch(route("register.ajax-data","villages")+`?district_id=${m}`).then(r=>r.json()).then(r=>{j({...c,villages:{...c.villages,[m]:r}})}),p(r=>({...r,kelurahan_id:0})))},x=s=>h=>{p(m=>({...m,[s]:h}))},y=(s,h)=>{var r;const m=(r=s.target.files)==null?void 0:r[0];if(m){const k=new FileReader;k.onloadend=()=>{h(k.result)},k.readAsDataURL(m),p(T=>({...T,[s.target.name]:m.name}))}};return _.useEffect(()=>{fetch(route("register.ajax-data","provinces")).then(s=>s.json()).then(s=>{j({...c,provinces:s}),e!=null&&e.provinsi_id!=null&&fetch(route("register.ajax-data","regencies")+`?province_id=${e.provinsi_id}`).then(h=>h.json()).then(h=>{j({...c,provinces:s,cities:{...c.cities,[e.provinsi_id]:h}}),e.kabupaten_id!=null&&fetch(route("register.ajax-data","districts")+`?regency_id=${e.kabupaten_id}`).then(m=>m.json()).then(m=>{j({...c,provinces:s,cities:{...c.cities,[e.provinsi_id]:h},districts:{...c.districts,[e.kabupaten_id]:m}}),e.kecamatan_id!=null&&fetch(route("register.ajax-data","villages")+`?district_id=${e.kecamatan_id}`).then(r=>r.json()).then(r=>{j({...c,provinces:s,cities:{...c.cities,[e.provinsi_id]:h},districts:{...c.districts,[e.kabupaten_id]:m},villages:{...c.villages,[e.kecamatan_id]:r}})})})})})},[]),a.jsxs("form",{onSubmit:M,className:"space-y-8",encType:"multipart/form-data",children:[a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx(d,{htmlFor:"nama_lengkap",children:"Nama Lengkap"}),a.jsx(o,{id:"nama_lengkap",name:"nama_lengkap",placeholder:"Masukkan nama lengkap",value:i.nama_lengkap,onChange:t})]}),a.jsx(n,{message:l.nama_lengkap})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx(d,{htmlFor:"email",children:"Email"}),a.jsx(o,{id:"email",name:"email",type:"email",placeholder:"[email protected]",value:i.email,onChange:t})]}),a.jsx(n,{message:l.email})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx(d,{htmlFor:"alamat",children:"Alamat"}),a.jsx(C,{id:"alamat",name:"alamat",placeholder:"Masukkan alamat lengkap",value:i.alamat,onChange:t})]}),a.jsx(n,{message:l.alamat})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("label",{htmlFor:"provinsi_id",className:"block text-sm font-medium text-gray-700",children:"Provinsi"}),a.jsxs("select",{name:"provinsi_id",value:i.provinsi_id,onChange:t,className:" w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent outline-hidden",children:[a.jsx("option",{value:"",children:"Pilih Provinsi"}),c.provinces.map(s=>a.jsx("option",{value:s.id,children:s.name},s.id))]}),a.jsx(n,{message:l.provinsi_id,className:"mt-2"})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("label",{htmlFor:"kabupaten_id",className:"block text-sm font-medium text-gray-700",children:"Kabupaten/Kota"}),a.jsxs("select",{name:"kabupaten_id",value:i.kabupaten_id,onChange:t,className:" w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent outline-hidden",disabled:!i.provinsi_id,children:[a.jsx("option",{value:"",children:"Pilih Kabupaten / Kota"}),i.provinsi_id&&((N=c.cities[i.provinsi_id])==null?void 0:N.map(s=>a.jsx("option",{value:s.id,children:s.name},s.id)))]}),a.jsx(n,{message:l.kabupaten_id,className:"mt-2"})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("label",{htmlFor:"kecmatan_id",className:"block text-sm font-medium text-gray-700",children:"Kecamatan"}),a.jsxs("select",{name:"kecamatan_id",value:i.kecamatan_id,onChange:t,className:" w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent outline-hidden",disabled:!i.kabupaten_id,children:[a.jsx("option",{value:"",children:"Pilih Kecamatan"}),i.kabupaten_id&&((w=c.districts[i.kabupaten_id])==null?void 0:w.map(s=>a.jsx("option",{value:s.id,children:s.name},s.id)))]}),a.jsx(n,{message:l.kecamatan_id,className:"mt-2"})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("label",{htmlFor:"kelurahan_id",className:"block text-sm font-medium text-gray-700",children:"Kelurahan/Desa"}),a.jsxs("select",{name:"kelurahan_id",value:i.kelurahan_id,onChange:t,className:" w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent outline-hidden",disabled:!i.kecamatan_id,children:[a.jsx("option",{value:"",children:"Pilih Kelurahan / Desa"}),i.kecamatan_id&&((F=c.villages[i.kecamatan_id])==null?void 0:F.map(s=>a.jsx("option",{value:s.id,children:s.name},s.id)))]}),a.jsx(n,{message:l.kelurahan_id,className:"mt-2"})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx(d,{htmlFor:"no_hp",children:"Nomor HP"}),a.jsx(o,{id:"no_hp",name:"no_hp",placeholder:"Masukkan nomor HP",value:i.no_hp,onChange:t})]}),a.jsx(n,{message:l.no_hp})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx(d,{htmlFor:"tempat_lahir",children:"Tempat Lahir"}),a.jsx(o,{id:"tempat_lahir",name:"tempat_lahir",placeholder:"Masukkan tempat lahir",value:i.tempat_lahir,onChange:t})]}),a.jsx(n,{message:l.tempat_lahir})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx(d,{htmlFor:"tanggal_lahir",children:"Tanggal Lahir"}),a.jsx(o,{id:"tanggal_lahir",type:"date",name:"tanggal_lahir",placeholder:"Masukkan Tanggal lahir",value:(i.tanggal_lahir??"").toString(),onChange:t})]}),a.jsx(n,{message:l.tanggal_lahir})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx(d,{htmlFor:"jenis_kelamin",children:"Jenis Kelamin"}),a.jsxs(g,{onValueChange:x("jenis_kelamin"),defaultValue:i.jenis_kelamin,children:[a.jsx(f,{children:a.jsx(v,{placeholder:"Pilih jenis kelamin"})}),a.jsxs(b,{children:[a.jsx(u,{value:"laki-laki",children:"Laki-laki"}),a.jsx(u,{value:"perempuan",children:"Perempuan"})]})]})]}),a.jsx(n,{message:l.jenis_kelamin})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx(d,{htmlFor:"foto_ktp",children:"Foto KTP"}),a.jsx(o,{id:"foto_ktp",name:"foto_ktp",type:"file",onChange:s=>y(s,K),accept:"image/*"})]}),a.jsx(n,{message:l.foto_ktp})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx(d,{htmlFor:"foto_kk",children:"Foto KK"}),a.jsx(o,{id:"foto_kk",name:"foto_kk",type:"file",onChange:t,accept:"image/*"})]}),a.jsx(n,{message:l.foto_kk})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx(d,{htmlFor:"foto_profil",children:"Foto Profil"}),a.jsx(o,{id:"foto_profil",name:"foto_profil",type:"file",onChange:s=>y(s,S),accept:"image/*"})]}),a.jsx(n,{message:l.foto_profil})]})]}),a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx(d,{htmlFor:"nik",children:"NIK"}),a.jsx(o,{id:"nik",name:"nik",placeholder:"Masukkan NIK",value:i.nik,onChange:t})]}),a.jsx(n,{message:l.nik})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx(d,{htmlFor:"npwp",children:"NPWP"}),a.jsx(o,{id:"npwp",name:"npwp",placeholder:"Masukkan NPWP",value:i.npwp,onChange:t})]}),a.jsx(n,{message:l.npwp})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx(d,{htmlFor:"status_pekerjaan",children:"Status Pekerjaan"}),a.jsx(o,{id:"status_pekerjaan",name:"status_pekerjaan",placeholder:"Masukkan status pekerjaan",value:i.status_pekerjaan,onChange:t})]}),a.jsx(n,{message:l.status_pekerjaan})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx(d,{htmlFor:"bidang_pekerjaan",children:"Bidang Pekerjaan"}),a.jsx(o,{id:"bidang_pekerjaan",name:"bidang_pekerjaan",placeholder:"Masukkan bidang pekerjaan",value:i.bidang_pekerjaan,onChange:t})]}),a.jsx(n,{message:l.bidang_pekerjaan})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx(d,{htmlFor:"tempat_bekerja",children:"Tempat Bekerja"}),a.jsx(o,{id:"tempat_bekerja",name:"tempat_bekerja",placeholder:"Masukkan tempat bekerja",value:i.tempat_bekerja,onChange:t})]}),a.jsx(n,{message:l.tempat_bekerja})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx(d,{htmlFor:"alamat_bekerja",children:"Alamat Bekerja"}),a.jsx(C,{id:"alamat_bekerja",name:"alamat_bekerja",placeholder:"Masukkan alamat tempat bekerja",value:i.alamat_bekerja,onChange:t})]}),a.jsx(n,{message:l.alamat_bekerja})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx(d,{htmlFor:"file_bukti_usaha",children:"File Bukti Usaha"}),a.jsx(o,{id:"file_bukti_usaha",name:"file_bukti_usaha",type:"file",onChange:t})]}),a.jsx(n,{message:l.file_bukti_usaha})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx(d,{htmlFor:"kriteria_usaha",children:"Kriteria Usaha"}),a.jsx(o,{id:"kriteria_usaha",name:"kriteria_usaha",placeholder:"Masukkan kriteria usaha",value:i.kriteria_usaha,onChange:t})]}),a.jsx(n,{message:l.kriteria_usaha})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx(d,{htmlFor:"file_profil_usaha",children:"File Profil Usaha"}),a.jsx(o,{id:"file_profil_usaha",name:"file_profil_usaha",type:"file",onChange:t})]}),a.jsx(n,{message:l.file_profil_usaha})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx(d,{htmlFor:"file_ijin_usaha",children:"File Ijin Usaha"}),a.jsx(o,{id:"file_ijin_usaha",name:"file_ijin_usaha",type:"file",onChange:t})]}),a.jsx(n,{message:l.file_ijin_usaha})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx(d,{htmlFor:"usia",children:"Usia"}),a.jsx(o,{id:"usia",name:"usia",type:"number",placeholder:"Masukkan usia",value:i.usia,onChange:t})]}),a.jsx(n,{message:l.usia})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx(d,{htmlFor:"utusan_dari",children:"Utusan Dari"}),a.jsx(o,{id:"utusan_dari",name:"utusan_dari",placeholder:"Masukkan utusan dari",value:i.utusan_dari,onChange:t})]}),a.jsx(n,{message:l.utusan_dari})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx(d,{htmlFor:"agama",children:"Agama"}),a.jsxs(g,{onValueChange:x("agama"),defaultValue:i.agama,children:[a.jsx(f,{children:a.jsx(v,{placeholder:"Pilih agama"})}),a.jsxs(b,{children:[a.jsx(u,{value:"islam",children:"Islam"}),a.jsx(u,{value:"kristen",children:"Kristen"}),a.jsx(u,{value:"katolik",children:"Katolik"}),a.jsx(u,{value:"hindu",children:"Hindu"}),a.jsx(u,{value:"buddha",children:"Buddha"}),a.jsx(u,{value:"konghucu",children:"Konghucu"})]})]})]}),a.jsx(n,{message:l.agama})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx(d,{htmlFor:"status_kawin",children:"Status Perkawinan"}),a.jsxs(g,{onValueChange:x("status_kawin"),defaultValue:i.status_kawin,children:[a.jsx(f,{children:a.jsx(v,{placeholder:"Pilih status perkawinan"})}),a.jsxs(b,{children:[a.jsx(u,{value:"belum_kawin",children:"Belum Kawin"}),a.jsx(u,{value:"kawin",children:"Kawin"}),a.jsx(u,{value:"cerai_hidup",children:"Cerai Hidup"}),a.jsx(u,{value:"cerai_mati",children:"Cerai Mati"})]})]})]}),a.jsx(n,{message:l.status_kawin})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"flex items-center space-x-2",children:[a.jsx(L,{id:"disabilitas",checked:i.disabilitas===1,onCheckedChange:s=>p(h=>({...h,disabilitas:s?1:0}))}),a.jsx(d,{htmlFor:"disabilitas",children:"Disabilitas"})]}),a.jsx(n,{message:l.disabilitas})]})]})]}),a.jsx("hr",{}),a.jsxs("div",{className:"w-full",children:[a.jsx("h2",{children:"Ubah Password"}),a.jsxs("div",{className:"flex gap-4 w-full",children:[a.jsxs("div",{children:[a.jsx("label",{htmlFor:"password",className:"block text-sm font-medium text-gray-700",children:"Password (minimal 8 karakter)"}),a.jsx("input",{type:"password",name:"password",placeholder:"Password",value:i.password??"",onChange:t,minLength:8,className:" w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent outline-hidden"}),a.jsx(n,{message:l.password})]}),a.jsxs("div",{children:[a.jsx("label",{htmlFor:"password_confirmation",className:"block text-sm font-medium text-gray-700",children:"Konfirmasi Password"}),a.jsx("input",{type:"password",name:"password_confirmation",placeholder:"Password",value:i.password_confirmation??"",onChange:t,className:" w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent outline-hidden"}),a.jsx(n,{message:l.password_confirmation})]})]})]}),a.jsx("div",{className:"flex justify-end mt-6",children:a.jsxs(U,{type:"submit",className:"w-full",children:[e!=null?"Ubah":"Tambah"," Peserta"]})})]})}export{aa as default};
Anons79 File Manager Version 1.0, Coded By Anons79
Email: [email protected]