import{X as S,r as t,G as w,j as e,S as C}from"./app-Dqm4owHT.js";import{A as _}from"./AdminLayout-BPEo2HGM.js";import{C as E,a as F,b as I,c as P}from"./card-doxYxJEC.js";import{S as D}from"./switch-V0KlRXvy.js";import{L as n}from"./label-Da7rPaor.js";import{I as f}from"./input-BnJy4BfI.js";import{I as c}from"./InputError-C6yxhkrz.js";import{B as j}from"./button-B8ZzRKBh.js";import{S as T,a as L,b as A,c as B,d as g}from"./select-BqCbOS6A.js";import{p as K}from"./excelUtils-DX2G9Acj.js";import{D as V}from"./download-CYM2JI_V.js";import{L as O}from"./loader-circle-CZpWlHdQ.js";import"./index-Ebf2_-ZL.js";import"./index-D3BPeFjX.js";import"./dropdown-menu-BCRVGgoO.js";import"./index-HNzDpnpF.js";import"./toaster-D9vdlzAC.js";import"./x-DjRPG20W.js";import"./createLucideIcon-Cc-ke-6N.js";import"./Combination-DterT_Fn.js";import"./index-BbqwfHyN.js";import"./chevron-right-Da1NFNyx.js";import"./users-BBYl_L7X.js";import"./graduation-cap-CAt1NeIc.js";import"./index-CZi-LSRR.js";import"./xlsx-xCRnwQcp.js";function xe(){const b=S().props.auth.user,[m,d]=t.useState(null),[Q,p]=t.useState(!1),[W,u]=t.useState(null),[G,k]=t.useState(""),{data:r,setData:l,post:y,processing:h,errors:i}=w({file:null,tahun:"2025",buat_akun:0,password_kustom:null}),N=s=>{s.preventDefault(),y(route("admin.peserta.import"))},v=async s=>{var x;const a=(x=s.target.files)==null?void 0:x[0];if(a&&!a.name.endsWith(".xlsx")&&!a.name.endsWith(".xls")){l("file",null);return}if(a){l("file",a),p(!0),u(null),console.log("excel");try{const o=await K(a);console.log(o),d(o)}catch(o){console.error("Error parsing Excel file:",o),u("Failed to parse Excel file. Please ensure it is a valid Excel format.")}finally{p(!1)}}};return t.useCallback(s=>{m&&d({...m,activeSheet:s})},[m]),t.useCallback(s=>{k(s)},[]),t.useCallback(()=>{},[]),e.jsxs(_,{user:b,header:e.jsx("h2",{className:"text-xl font-semibold leading-tight text-gray-800",children:"Import Peserta"}),children:[e.jsx(C,{title:"Import Peserta"}),e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("h1",{className:"text-lg font-bold md:text-2xl",children:"Import Peserta"}),e.jsx("a",{href:route("admin.peserta.download-template-import"),target:"_blank",children:e.jsxs(j,{children:[e.jsx(V,{})," Download Template"]})})]}),e.jsx("div",{className:"space-y-4",children:e.jsxs(E,{className:"w-full mx-auto",children:[e.jsx(F,{children:e.jsx(I,{children:"Import Peserta"})}),e.jsx(P,{children:e.jsxs("form",{onSubmit:N,method:"POST",encType:"multipart/form-data",className:"space-y-2",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(n,{htmlFor:"tahun",children:"Tahun Data"}),e.jsxs(T,{onValueChange:()=>{l("tahun",r.tahun)},defaultValue:r.tahun,children:[e.jsx(L,{children:e.jsx(A,{placeholder:"Pilih Tahun Data"})}),e.jsxs(B,{children:[e.jsx(g,{value:"2025",children:"2025"}),e.jsx(g,{value:"2024",children:"2024"})]})]})]}),e.jsx(c,{message:i.tahun})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(n,{htmlFor:"file",children:"File Excel"}),e.jsx(f,{id:"file",type:"file",name:"file",accept:".xlsx, .xls",onChange:v,className:"mt-1 block w-full"})]}),e.jsx(c,{message:i.file})]})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(D,{id:"buat_akun",checked:r.buat_akun===1,onCheckedChange:s=>l(a=>({...a,buat_akun:s?1:0}))}),e.jsx(n,{htmlFor:"buat_akun",children:"Buat Akun Otomatis"})]}),e.jsx(c,{message:i.buat_akun})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(n,{htmlFor:"file",children:"Password Kustom (Kosongkan jika ingin generate password otomatis untuk setiap akun peserta) "}),e.jsx(f,{disabled:r.buat_akun===0,id:"password_kustom",type:"password",name:"password_kustom",placeholder:"Password Kustom...",onChange:s=>l("password_kustom",s.target.value),className:"mt-1 block w-full"}),e.jsx(c,{message:i.file})]})]})}),e.jsx("div",{className:"mt-4",children:e.jsxs(j,{type:"submit",disabled:h,children:[h?e.jsx(O,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Import"]})})]})})]})})]})}export{xe as default};
Anons79 File Manager Version 1.0, Coded By Anons79
Email: [email protected]