import{t as e}from"./useQuery-DoHBdk1I.js";import{a as t,i as n,n as r,r as i,t as a}from"./select-B-7XEvhS.js";import{t as o}from"./download-YHnOYBTr.js";import{Pt as s,T as c,ct as l,h as u,jt as d,r as f,u as p,ut as m,x as h}from"./index-cYnyErBl.js";import{n as g}from"./skeleton-BYSy5H0w.js";import{a as _,c as v,i as y,n as b,o as x,r as S,s as C,t as w}from"./table-CgoZ-Hky.js";import{t as T}from"./badge-CwXg11fa.js";var E=s(d(),1),D={getAll:e=>f.get(`/pilihan-sekolah`,{params:e}),exportExcel:()=>f.get(`/pilihan-sekolah/export`,{responseType:`blob`})},O=m(),k={sma:`bg-blue-50 text-blue-700 border-blue-200`,smk:`bg-purple-50 text-purple-700 border-purple-200`,ma:`bg-green-50 text-green-700 border-green-200`,perguruan_tinggi:`bg-amber-50 text-amber-700 border-amber-200`,lainnya:`bg-gray-50 text-gray-600 border-gray-200`};function A({jenjang:e}){return(0,O.jsx)(T,{variant:`outline`,className:`text-xs font-medium ${k[e]??k.lainnya}`,children:c(e)})}function j(){let[s,c]=(0,E.useState)(`all`),[d,f]=(0,E.useState)(1),{data:m,isLoading:T}=e({queryKey:[`pilihan-sekolah`,s,d],queryFn:()=>D.getAll({jenjang:s===`all`?``:s,page:d,per_page:20}).then(e=>e.data)}),k=async()=>{let e=l.loading(`Menyiapkan file Excel...`);try{let t=await D.exportExcel(),n=URL.createObjectURL(t.data);Object.assign(document.createElement(`a`),{href:n,download:`rekap-pilihan-sekolah.xlsx`}).click(),URL.revokeObjectURL(n),l.success(`File berhasil diunduh.`,{id:e})}catch{l.error(`Gagal mengekspor.`,{id:e})}},j=m?.data??[];return(0,O.jsxs)(`div`,{children:[(0,O.jsx)(g,{title:`Pilihan Sekolah Lanjutan`,description:`${m?.meta?.total??0} siswa sudah mengisi pilihan`,actions:(0,O.jsxs)(p,{size:`sm`,onClick:k,className:`gap-1.5`,children:[(0,O.jsx)(o,{className:`h-3.5 w-3.5`}),` Export Excel`]})}),(0,O.jsx)(`div`,{className:`flex gap-2.5 mb-4`,children:(0,O.jsxs)(a,{value:s,onValueChange:e=>{c(e||`all`),f(1)},children:[(0,O.jsx)(n,{className:`w-48 h-9 text-sm`,children:(0,O.jsx)(t,{placeholder:`Semua Jenjang`})}),(0,O.jsxs)(r,{children:[(0,O.jsx)(i,{value:`all`,children:`Semua Jenjang`}),(0,O.jsx)(i,{value:`sma`,children:`SMA`}),(0,O.jsx)(i,{value:`smk`,children:`SMK`}),(0,O.jsx)(i,{value:`ma`,children:`MA`}),(0,O.jsx)(i,{value:`perguruan_tinggi`,children:`Perguruan Tinggi`}),(0,O.jsx)(i,{value:`lainnya`,children:`Lainnya`})]})]})}),(0,O.jsx)(`div`,{className:`rounded-2xl border border-border bg-card shadow-sm overflow-hidden`,children:T?(0,O.jsx)(v,{rows:6,cols:6}):j.length===0?(0,O.jsx)(C,{icon:u,heading:`Belum ada pilihan sekolah`,subtext:`Siswa yang lulus dapat mengisi pilihan sekolah lanjutan melalui halaman publik.`}):(0,O.jsxs)(w,{children:[(0,O.jsx)(_,{children:(0,O.jsx)(x,{className:`bg-muted/40 hover:bg-muted/40 border-b border-border`,children:[`NISN`,`Nama Siswa`,`Kelas`,`Nama Sekolah`,`Jenjang`,`Tanggal`].map(e=>(0,O.jsx)(y,{className:`text-[11px] font-bold uppercase tracking-wider text-muted-foreground`,children:e},e))})}),(0,O.jsx)(b,{children:j.map(e=>(0,O.jsxs)(x,{className:`hover:bg-muted/20 transition-colors border-border/60`,children:[(0,O.jsx)(S,{children:(0,O.jsx)(`span`,{className:`font-mono text-xs tracking-widest text-muted-foreground bg-muted/60 px-2 py-0.5 rounded-md`,children:e.nisn})}),(0,O.jsx)(S,{className:`font-medium text-sm`,children:e.nama}),(0,O.jsx)(S,{className:`text-sm text-muted-foreground`,children:e.kelas}),(0,O.jsx)(S,{className:`text-sm font-medium`,children:e.nama_sekolah}),(0,O.jsx)(S,{children:(0,O.jsx)(A,{jenjang:e.jenjang})}),(0,O.jsx)(S,{className:`text-sm text-muted-foreground`,children:h(e.created_at)})]},e.id))})]})}),m?.meta&&m.meta.last_page>1&&(0,O.jsxs)(`div`,{className:`flex items-center justify-between mt-4`,children:[(0,O.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Halaman `,d,` dari `,m.meta.last_page]}),(0,O.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,O.jsx)(p,{variant:`outline`,size:`sm`,className:`h-8 px-3 text-xs`,disabled:d===1,onClick:()=>f(e=>e-1),children:`← Prev`}),(0,O.jsx)(p,{variant:`outline`,size:`sm`,className:`h-8 px-3 text-xs`,disabled:d>=m.meta.last_page,onClick:()=>f(e=>e+1),children:`Next →`})]})]})]})}export{j as default};