import{r as x,u as b,j as e,L as p,a as g}from"./app-BI7hSYr0.js";import{A as v}from"./AppLayout-ahz_yU39.js";import{T as a}from"./TextInput-DbVu2NWj.js";import{S as i}from"./SelectInput-CAHu3cWK.js";function C({classes:n,classrooms:o,subjects:d}){const[r,l]=x.useState(!1),s=b({classroom_id:"",subject_id:"",title:"",meeting_url:"",starts_at:"",ends_at:""});function c(t){t.preventDefault(),s.post("/school/online-classes",{onSuccess:()=>{s.reset(),l(!1)}})}function h(t,j){confirm(`حذف کلاس آنلاین «${j}»؟`)&&g.delete(`/school/online-classes/${t}`,{preserveScroll:!0})}const m=[{value:"",label:"انتخاب کلاس..."},...o.map(t=>({value:String(t.id),label:t.name}))],u=[{value:"",label:"بدون درس"},...d.map(t=>({value:String(t.id),label:t.name}))];return e.jsx(v,{title:"کلاس‌های آنلاین",children:e.jsxs("div",{className:"page-stack",children:[e.jsxs("section",{className:"section-header",children:[e.jsxs("div",{children:[e.jsx("h2",{children:"کلاس‌های آنلاین"}),e.jsx("p",{children:"ثبت لینک جلسات آنلاین برای کلاس‌ها."})]}),e.jsxs("button",{className:"btn btn-primary",type:"button",onClick:()=>l(!r),children:[e.jsx("i",{className:"bi bi-camera-video"})," کلاس جدید"]})]}),r&&e.jsxs("form",{className:"panel-card",onSubmit:c,children:[e.jsx("h2",{children:"افزودن کلاس آنلاین"}),e.jsxs("div",{className:"form-grid",children:[e.jsx(i,{label:"کلاس",options:m,value:s.data.classroom_id,onChange:t=>s.setData("classroom_id",t.target.value)}),e.jsx(i,{label:"درس (اختیاری)",options:u,value:s.data.subject_id,onChange:t=>s.setData("subject_id",t.target.value)}),e.jsx(a,{label:"عنوان جلسه",value:s.data.title,onChange:t=>s.setData("title",t.target.value),error:s.errors.title}),e.jsx(a,{label:"لینک جلسه (URL)",type:"url",value:s.data.meeting_url,onChange:t=>s.setData("meeting_url",t.target.value),error:s.errors.meeting_url}),e.jsx(a,{label:"شروع جلسه",type:"datetime-local",value:s.data.starts_at,onChange:t=>s.setData("starts_at",t.target.value)}),e.jsx(a,{label:"پایان جلسه",type:"datetime-local",value:s.data.ends_at,onChange:t=>s.setData("ends_at",t.target.value)})]}),e.jsxs("div",{className:"action-row",children:[e.jsx("button",{className:"btn btn-primary",disabled:s.processing,type:"submit",children:"ثبت"}),e.jsx("button",{className:"btn btn-ghost",type:"button",onClick:()=>l(!1),children:"لغو"})]})]}),n.length>0?e.jsx("div",{className:"table-wrap",children:e.jsxs("table",{className:"data-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"عنوان"}),e.jsx("th",{children:"کلاس"}),e.jsx("th",{children:"درس"}),e.jsx("th",{children:"شروع"}),e.jsx("th",{children:"پایان"}),e.jsx("th",{children:"ورودی‌ها"}),e.jsx("th",{children:"عملیات"})]})}),e.jsx("tbody",{children:n.map(t=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsxs("a",{href:t.meetingUrl,target:"_blank",rel:"noreferrer",className:"btn btn-ghost btn-sm",children:[e.jsx("i",{className:"bi bi-box-arrow-up-left"})," ",t.title]})}),e.jsx("td",{children:t.classroom}),e.jsx("td",{children:t.subject}),e.jsx("td",{children:t.startsAt}),e.jsx("td",{children:t.endsAt}),e.jsx("td",{style:{textAlign:"center"},children:e.jsxs(p,{href:`/school/online-classes/${t.id}/logs`,className:"badge badge-muted",style:{textDecoration:"none"},children:[t.joinCount," نفر"]})}),e.jsx("td",{children:e.jsxs("button",{className:"btn btn-danger-ghost btn-sm",type:"button",onClick:()=>h(t.id,t.title),children:[e.jsx("i",{className:"bi bi-trash"})," حذف"]})})]},t.id))})]})}):e.jsxs("section",{className:"panel-card",children:[e.jsx("h2",{children:"هنوز کلاس آنلاینی ثبت نشده"}),e.jsx("p",{children:"از دکمه «کلاس جدید» اولین جلسه را ثبت کن."})]})]})})}export{C as default};
