import{X as S,r as t,G as w,j as e,S as C}from"./app-CxR6mXVP.js";import{A as _}from"./AdminLayout-Br3kxU_M.js";import{C as E,a as F,b as I,c as P}from"./card-BUSXAYMi.js";import{S as D}from"./switch-dBMp0lbN.js";import{L as n}from"./label-EP1vquW8.js";import{I as f}from"./input-CsuTifve.js";import{I as c}from"./InputError-mdZGzeRq.js";import{B as j}from"./button-DpQP_lYd.js";import{S as T,a as L,b as A,c as B,d as g}from"./select-Bm0HKOqe.js";import{p as K}from"./excelUtils-DX2G9Acj.js";import{D as V}from"./download-J1fJP6Fc.js";import{L as O}from"./loader-circle-B56EvIyB.js";import"./utils-CytzSlOG.js";import"./dropdown-menu-DSA7ILHF.js";import"./index-BzpbaWHn.js";import"./index-Dy7KKS3_.js";import"./index-C6J07-3_.js";import"./toaster-TzmOCMaj.js";import"./x-BTmWAVnY.js";import"./createLucideIcon-BX4VOWE3.js";import"./Combination-BDsadoUX.js";import"./index-COEfcW-E.js";import"./chevron-right-DFpRS_H1.js";import"./users-BAS2Dmtn.js";import"./graduation-cap-DfxWJKg6.js";import"./index-BWgL_1QM.js";import"./xlsx-xCRnwQcp.js";function fe(){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:l,setData:r,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")){r("file",null);return}if(a){r("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:()=>{r("tahun",l.tahun)},defaultValue:l.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:l.buat_akun===1,onCheckedChange:s=>r(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:l.buat_akun===0,id:"password_kustom",type:"password",name:"password_kustom",placeholder:"Password Kustom...",onChange:s=>r("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{fe as default};
Anons79 File Manager Version 1.0, Coded By Anons79
Email: [email protected]