import{G as L,r as x,j as a}from"./app-BO9tOaz3.js";import{B as U}from"./button-CHou7zed.js";import{I as o}from"./input-BjM0W0Oh.js";import{L as t}from"./label-DmNnhObW.js";import{S as D}from"./switch-CXwNJlW4.js";import{S as k,a as g,b as f,c as v,d as u}from"./select-CWEe9lxq.js";import{I as n}from"./InputError-BzVoEjQl.js";import{T as P}from"./textarea-BVOpsEE6.js";import"./index-z5ESqc1P.js";import"./index-C6cWY2j9.js";import"./index-DmnGomn9.js";import"./index-Cze-uKba.js";import"./index-BxGoxCsJ.js";import"./Combination-CD3xNchB.js";import"./createLucideIcon-1GpxPkzE.js";function sa({peserta:e}){var w,F,C;const{data:i,setData:j,post:K,processing:y,errors:l}=L(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,tahun:(e.tahun??2025).toString()}:{nama_lengkap:"",email:"",alamat:"",no_hp:"",tempat_lahir:"",tanggal_lahir:new Date,jenis_kelamin:"laki-laki",foto_ktp:null,foto_kk:null,foto_profil:null,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,tahun:"2025"}),[c,p]=x.useState({provinces:[],cities:{},districts:{},villages:{}}),[V,S]=x.useState(null),[B,$]=x.useState(null),[E,M]=x.useState(null),T=s=>{s.preventDefault(),K(e!=null?route("admin.peserta.update",{id:e.id}):route("admin.peserta.store"),{onFinish:()=>console.log("okoc")})},d=s=>{const{name:h,value:m}=s.target;j(r=>({...r,[h]:m})),h==="provinsi_id"?(fetch(route("register.ajax-data","regencies")+`?province_id=${m}`).then(r=>r.json()).then(r=>{p({...c,cities:{...c.cities,[m]:r}})}),j(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=>{p({...c,districts:{...c.districts,[m]:r}})}),j(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=>{p({...c,villages:{...c.villages,[m]:r}})}),j(r=>({...r,kelurahan_id:0})))},_=s=>h=>{j(m=>({...m,[s]:h}))},N=(s,h)=>{var r;const m=(r=s.target.files)==null?void 0:r[0];if(m){const b=new FileReader;b.onloadend=()=>{h(b.result)},b.readAsDataURL(m),j(I=>({...I,[s.target.name]:m}))}};return x.useEffect(()=>{fetch(route("register.ajax-data","provinces")).then(s=>s.json()).then(s=>{p({...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=>{p({...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=>{p({...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=>{p({...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:T,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(t,{htmlFor:"tahun",children:"Tahun Data"}),a.jsxs(k,{onValueChange:_("tahun"),defaultValue:i.tahun,children:[a.jsx(g,{children:a.jsx(f,{placeholder:"Pilih Tahun Data"})}),a.jsxs(v,{children:[a.jsx(u,{value:"2025",children:"2025"}),a.jsx(u,{value:"2024",children:"2024"})]})]})]}),a.jsx(n,{message:l.tahun})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsxs(t,{htmlFor:"nama_lengkap",children:["Nama Lengkap ",a.jsx("small",{className:"text-red-500",children:"*"})]}),a.jsx(o,{id:"nama_lengkap",name:"nama_lengkap",placeholder:"Masukkan nama lengkap",value:i.nama_lengkap,onChange:d})]}),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(t,{htmlFor:"email",children:"Email"}),a.jsx(o,{id:"email",name:"email",type:"email",placeholder:"[email protected]",value:i.email,onChange:d})]}),a.jsx(n,{message:l.email})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx(t,{htmlFor:"alamat",children:"Alamat"}),a.jsx(P,{id:"alamat",name:"alamat",placeholder:"Masukkan alamat lengkap",value:i.alamat,onChange:d})]}),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:d,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:d,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&&((w=c.cities[i.provinsi_id])==null?void 0:w.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:d,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&&((F=c.districts[i.kabupaten_id])==null?void 0:F.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:d,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&&((C=c.villages[i.kecamatan_id])==null?void 0:C.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(t,{htmlFor:"no_hp",children:"Nomor HP"}),a.jsx(o,{id:"no_hp",name:"no_hp",placeholder:"Masukkan nomor HP",value:i.no_hp,onChange:d})]}),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(t,{htmlFor:"tempat_lahir",children:"Tempat Lahir"}),a.jsx(o,{id:"tempat_lahir",name:"tempat_lahir",placeholder:"Masukkan tempat lahir",value:i.tempat_lahir,onChange:d})]}),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(t,{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:d})]}),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(t,{htmlFor:"jenis_kelamin",children:"Jenis Kelamin"}),a.jsxs(k,{onValueChange:_("jenis_kelamin"),defaultValue:i.jenis_kelamin,children:[a.jsx(g,{children:a.jsx(f,{placeholder:"Pilih jenis kelamin"})}),a.jsxs(v,{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(t,{htmlFor:"foto_ktp",children:"Foto KTP"}),a.jsx(o,{id:"foto_ktp",name:"foto_ktp",type:"file",onChange:s=>N(s,S),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(t,{htmlFor:"foto_kk",children:"Foto KK"}),a.jsx(o,{id:"foto_kk",name:"foto_kk",type:"file",onChange:d,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(t,{htmlFor:"foto_profil",children:"Foto Profil"}),a.jsx(o,{id:"foto_profil",name:"foto_profil",type:"file",onChange:s=>N(s,M),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.jsxs(t,{htmlFor:"nik",children:["NIK ",a.jsx("small",{className:"text-red-500",children:"*"})]}),a.jsx(o,{id:"nik",name:"nik",placeholder:"Masukkan NIK",value:i.nik,type:"number",onChange:d})]}),a.jsx(n,{message:l.nik})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx(t,{htmlFor:"npwp",children:"NPWP"}),a.jsx(o,{id:"npwp",name:"npwp",placeholder:"Masukkan NPWP",value:i.npwp,onChange:d})]}),a.jsx(n,{message:l.npwp})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx(t,{htmlFor:"status_pekerjaan",children:"Status Pekerjaan"}),a.jsx(o,{id:"status_pekerjaan",name:"status_pekerjaan",placeholder:"Masukkan status pekerjaan",value:i.status_pekerjaan,onChange:d})]}),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(t,{htmlFor:"bidang_pekerjaan",children:"Bidang Pekerjaan"}),a.jsx(o,{id:"bidang_pekerjaan",name:"bidang_pekerjaan",placeholder:"Masukkan bidang pekerjaan",value:i.bidang_pekerjaan,onChange:d})]}),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(t,{htmlFor:"tempat_bekerja",children:"Tempat Bekerja"}),a.jsx(o,{id:"tempat_bekerja",name:"tempat_bekerja",placeholder:"Masukkan tempat bekerja",value:i.tempat_bekerja,onChange:d})]}),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(t,{htmlFor:"alamat_bekerja",children:"Alamat Bekerja"}),a.jsx(P,{id:"alamat_bekerja",name:"alamat_bekerja",placeholder:"Masukkan alamat tempat bekerja",value:i.alamat_bekerja,onChange:d})]}),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(t,{htmlFor:"file_bukti_usaha",children:"File Bukti Usaha"}),a.jsx(o,{id:"file_bukti_usaha",name:"file_bukti_usaha",type:"file",onChange:d})]}),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(t,{htmlFor:"kriteria_usaha",children:"Kriteria Usaha"}),a.jsx(o,{id:"kriteria_usaha",name:"kriteria_usaha",placeholder:"Masukkan kriteria usaha",value:i.kriteria_usaha,onChange:d})]}),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(t,{htmlFor:"file_profil_usaha",children:"File Profil Usaha"}),a.jsx(o,{id:"file_profil_usaha",name:"file_profil_usaha",type:"file",onChange:d})]}),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(t,{htmlFor:"file_ijin_usaha",children:"File Ijin Usaha"}),a.jsx(o,{id:"file_ijin_usaha",name:"file_ijin_usaha",type:"file",onChange:d})]}),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(t,{htmlFor:"usia",children:"Usia"}),a.jsx(o,{id:"usia",name:"usia",type:"number",placeholder:"Masukkan usia",value:i.usia,onChange:d})]}),a.jsx(n,{message:l.usia})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx(t,{htmlFor:"utusan_dari",children:"Utusan Dari"}),a.jsx(o,{id:"utusan_dari",name:"utusan_dari",placeholder:"Masukkan utusan dari",value:i.utusan_dari,onChange:d})]}),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(t,{htmlFor:"agama",children:"Agama"}),a.jsxs(k,{onValueChange:_("agama"),defaultValue:i.agama,children:[a.jsx(g,{children:a.jsx(f,{placeholder:"Pilih agama"})}),a.jsxs(v,{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(t,{htmlFor:"status_kawin",children:"Status Perkawinan"}),a.jsxs(k,{onValueChange:_("status_kawin"),defaultValue:i.status_kawin,children:[a.jsx(g,{children:a.jsx(f,{placeholder:"Pilih status perkawinan"})}),a.jsxs(v,{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(D,{id:"disabilitas",checked:i.disabilitas===1,onCheckedChange:s=>j(h=>({...h,disabilitas:s?1:0}))}),a.jsx(t,{htmlFor:"disabilitas",children:"Disabilitas"})]}),a.jsx(n,{message:l.disabilitas})]})]})]}),a.jsx("hr",{}),a.jsxs("div",{className:"w-full",children:[a.jsxs("h2",{children:[e!=null&&"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:d,minLength:8,autoComplete:"new-password",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:d,autoComplete:"new-password",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.jsx(U,{type:"submit",disabled:y,className:"w-full",children:y?"Loading...":(e!=null?"Ubah":"Tambah")+"Peserta"})})]})}export{sa as default};
Anons79 File Manager Version 1.0, Coded By Anons79
Email: [email protected]