import{X as L,r as l,j as e,S as A,x as b,A as E}from"./app-Bovtsm3z.js";import{A as B}from"./AdminLayout-qQzairgc.js";import H from"./DetailDataTable-BMQjliYw.js";import{C as I,a as $,b as O,c as F}from"./card-rHI0F0mm.js";import{B as i}from"./button-CzS7pkis.js";import{D as K,a as M,b as Q,c as R,d as U,e as z}from"./dialog-CyCeB8PJ.js";import{T as J,a as X,b as j,c,d as q,e as n}from"./table-tL4Lt2GO.js";import{C as G}from"./checkbox-Dx2STbJW.js";import{I as V}from"./input-pA_PbStL.js";import{F as W}from"./file-down-yF0isjzP.js";import{S as Y}from"./scroll-ChuSqgzD.js";import{C as y}from"./circle-plus-B-rm4AsW.js";import{C as Z}from"./calendar-fQVxHf-C.js";import{M as ee}from"./map-pin-yH6pN3Bq.js";import{U as se}from"./user-WETxQ59A.js";import{B as p}from"./book-open-DDw5V3J-.js";import{D as ae}from"./download-C9zY8Cdu.js";import{C as re}from"./clock-D315rA-9.js";import{S as te}from"./search-C5SBEPl3.js";import"./utils-CytzSlOG.js";import"./dropdown-menu-BQ7y87VX.js";import"./index-CawRJkUp.js";import"./toaster-Bkg8UDi4.js";import"./x-DeL5iMbH.js";import"./createLucideIcon-DacnXw-F.js";import"./Combination-Buc5F2BK.js";import"./index-BhHHdEWH.js";import"./chevron-right-CbL5EKOI.js";import"./users-aDCm0kGh.js";import"./graduation-cap-yGLmwRzV.js";import"./useSorting-BMuQ7wL3.js";import"./useDebouncedSearch-C3eUVB62.js";import"./chevron-left-BKa8e32F.js";import"./select-CrNdvawf.js";import"./index-QA9gyqW5.js";import"./eye-tzF_8mFc.js";function Qe({pelatihan:r,peserta:ie}){const v=L().props.auth.user,[w,d]=l.useState(!1),[x,g]=l.useState([]),[m,C]=l.useState([]),[o,k]=l.useState(""),[h,u]=l.useState([]),D=async()=>{try{const a=await(await fetch(route("admin.pelatihan.available-peserta",{id:r.id}))).json();C(a),u(a)}catch(s){console.error("Error fetching available peserta:",s)}};l.useEffect(()=>{if(m.length>0){const s=m.filter(a=>{var f,N;const t=o.toLowerCase();return a.nik&&a.nik.toLowerCase().includes(t)||a.nama_lengkap&&a.nama_lengkap.toLowerCase().includes(t)||((f=a.user)==null?void 0:f.nama)&&a.user.nama.toLowerCase().includes(t)||a.email&&a.email.toLowerCase().includes(t)||((N=a.user)==null?void 0:N.email)&&a.user.email.toLowerCase().includes(t)||a.no_hp&&a.no_hp.toLowerCase().includes(t)});u(s)}},[o,m]);const P=()=>{D(),d(!0)},S=s=>{g(a=>a.includes(s)?a.filter(t=>t!==s):[...a,s])},_=()=>{x.length>0?E.post(route("admin.pelatihan.add-peserta",{id:r.id}),{peserta_ids:x},{onSuccess:()=>{d(!1),g([])}}):d(!1)},T=s=>{switch(s){case"beginner":return"bg-green-100 text-green-800";case"intermediate":return"bg-yellow-100 text-yellow-800";case"advanced":return"bg-red-100 text-red-800";default:return"bg-gray-100 text-gray-800"}};return e.jsxs(B,{user:v,children:[e.jsx(A,{title:"Pelatihan"}),e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("h1",{className:"text-lg font-bold md:text-2xl",children:"Detail Pelatihan"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("a",{href:route("admin.pelatihan.export-peserta",{id:r.id}),target:"_blank",children:e.jsxs(i,{children:[e.jsx(W,{className:"w-4 h-4"})," Export Peserta"]})}),e.jsx("a",{href:route("admin.pelatihan.print-sertifikat",{id:r.id}),target:"_blank",children:e.jsxs(i,{children:[e.jsx(Y,{className:"w-4 h-4 "})," Print Sertifikat"]})}),e.jsx(b,{href:route("admin.pelatihan.edit",{id:r.id}),children:e.jsxs(i,{children:[e.jsx(y,{})," Edit Pelatihan"]})})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"bg-white rounded-lg shadow overflow-hidden",children:[e.jsx("div",{className:"p-6 border-b border-gray-200",children:e.jsxs("div",{className:"flex justify-between items-start",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold text-gray-900 mb-2",children:r.title}),e.jsx("span",{className:`inline-flex items-center px-3 py-1 rounded-full text-sm font-medium ${T(r.level)} capitalize`,children:r.level})]}),e.jsx("div",{className:"flex items-center",children:e.jsx("span",{className:`px-3 py-1 rounded-full text-sm font-medium ${r.status?"bg-green-100 text-green-800":"bg-red-100 text-red-800"}`,children:r.status?"Active":"Inactive"})})]})}),e.jsxs("div",{className:"p-6 grid grid-cols-1 md:grid-cols-2 gap-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-start space-x-3",children:[e.jsx(Z,{className:"w-5 h-5 text-gray-400 mt-1"}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium text-gray-500",children:"Durasi"}),e.jsxs("p",{className:"text-base text-gray-900",children:[new Date(r.start_date).toLocaleDateString()," - ",new Date(r.end_date).toLocaleDateString()]})]})]}),e.jsxs("div",{className:"flex items-start space-x-3",children:[e.jsx(ee,{className:"w-5 h-5 text-gray-400 mt-1"}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium text-gray-500",children:"Lokasi"}),e.jsxs("p",{className:"text-base text-gray-900",children:[r.province.name,", ",r.regency.name]})]})]}),e.jsxs("div",{className:"flex items-start space-x-3",children:[e.jsx(se,{className:"w-5 h-5 text-gray-400 mt-1"}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium text-gray-500",children:"Instruktur"}),e.jsx("p",{className:"text-base text-gray-900",children:r.instructor.nama})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-lg font-medium text-gray-900 mb-2",children:"Deskripsi"}),e.jsx("p",{className:"text-gray-600",children:r.description}),e.jsx("div",{children:e.jsx("img",{src:`${route("storage.images")}?path=${r.thumbnail}`,alt:"Thumbnail",className:"w-full rounded-lg"})})]})]}),e.jsxs("div",{className:"p-6 border-t border-gray-200",children:[e.jsxs("div",{className:"flex items-center space-x-2 mb-4",children:[e.jsx(p,{className:"w-5 h-5 text-gray-400"}),e.jsx("h3",{className:"text-lg font-medium text-gray-900",children:"Materi"})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:r.pelatihan_materis.map(s=>e.jsxs("div",{className:"border rounded-lg p-4 flex justify-between",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium text-gray-900",children:s.name}),e.jsxs("p",{className:"text-sm text-gray-500 mt-1",children:["Kode: ",s.code]}),e.jsx("p",{className:"text-sm text-gray-600 mt-2",children:s.description})]}),e.jsx("div",{children:e.jsx("a",{href:`${route("storage.file")}?path=${s.file}`,target:"_blank",children:e.jsx(ae,{className:"w-5 h-5 text-gray-400"})})})]},s.id))})]}),e.jsxs("div",{className:"p-6 border-t border-gray-200",children:[e.jsxs("div",{className:"flex items-center space-x-2 mb-4",children:[e.jsx(re,{className:"w-5 h-5 text-gray-400"}),e.jsx("h3",{className:"text-lg font-medium text-gray-900",children:"Jadwal"})]}),e.jsx("div",{className:"space-y-4",children:r.pelatihan_jadwals.map(s=>e.jsxs("div",{className:"border rounded-lg p-4",children:[e.jsxs("div",{className:"flex justify-between items-start",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium text-gray-900",children:s.name}),e.jsxs("p",{className:"text-sm text-gray-500 mt-1",children:["Kode: ",s.code]})]}),e.jsxs("div",{className:"text-end",children:[e.jsx("p",{className:"text-sm text-gray-500",children:new Date(s.course_date).toLocaleDateString()}),e.jsx("a",{href:route("admin.pelatihan.absensi",{pelatihan_jadwal_id:s.id}),children:e.jsxs(i,{children:[e.jsx(p,{})," Absensi"]})})]})]}),e.jsx("p",{className:"text-sm text-gray-600 mt-2",children:s.description})]},s.id))})]})]}),e.jsxs(I,{children:[e.jsx($,{children:e.jsx(O,{children:e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("h1",{className:"text-lg font-bold md:text-2xl",children:"Peserta Pelatihan"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(i,{onClick:P,children:[e.jsx(y,{})," Tambah Peserta"]}),e.jsx(b,{href:route("admin.pelatihan.tugas",{id:r.id}),children:e.jsxs(i,{children:[e.jsx(p,{})," Tugas Peserta"]})})]})]})})}),e.jsx(F,{children:e.jsx(H,{pelatihanId:r.id})})]})]}),e.jsx(K,{open:w,onOpenChange:d,children:e.jsxs(M,{className:"max-w-4xl",children:[e.jsxs(Q,{children:[e.jsx(R,{children:"Tambah Peserta Pelatihan"}),e.jsx(U,{children:"Pilih peserta yang ingin ditambahkan ke pelatihan ini."})]}),e.jsxs("div",{className:"flex items-center space-x-2 my-4",children:[e.jsx(te,{className:"w-4 h-4 text-gray-400"}),e.jsx(V,{type:"text",placeholder:"Cari peserta berdasarkan nama, NIK, email, atau no. HP",value:o,onChange:s=>k(s.target.value),className:"flex-1"})]}),e.jsx("div",{className:"max-h-[60vh] overflow-y-auto",children:e.jsxs(J,{children:[e.jsx(X,{children:e.jsxs(j,{children:[e.jsx(c,{className:"w-12",children:"Pilih"}),e.jsx(c,{children:"NIK"}),e.jsx(c,{children:"Nama"}),e.jsx(c,{children:"Email"}),e.jsx(c,{children:"No. HP"})]})}),e.jsx(q,{children:h&&h.length>0?h.map(s=>{var a,t;return e.jsxs(j,{children:[e.jsx(n,{children:e.jsx(G,{checked:x.includes(s.id),onCheckedChange:()=>S(s.id)})}),e.jsx(n,{children:s.nik||"-"}),e.jsx(n,{children:s.nama_lengkap||((a=s.user)==null?void 0:a.nama)}),e.jsx(n,{children:s.email||((t=s.user)==null?void 0:t.email)}),e.jsx(n,{children:s.no_hp||"-"})]},s.id)}):e.jsx(j,{children:e.jsx(n,{colSpan:5,className:"h-24 text-center",children:o?"Tidak ada peserta yang sesuai dengan pencarian.":"Tidak ada peserta yang tersedia."})})})]})}),e.jsxs(z,{className:"mt-4",children:[e.jsx(i,{variant:"outline",onClick:()=>d(!1),children:"Batal"}),e.jsx(i,{onClick:_,children:"Simpan"})]})]})})]})}export{Qe as default};
Anons79 File Manager Version 1.0, Coded By Anons79
Email: [email protected]