import{r as o,u as d,j as e,a as m}from"./app-BeXbqfQ0.js";import{A as h}from"./AppLayout-DFlN-unB.js";import{T as p}from"./TextInput-Blvk54Ev.js";import{S as u}from"./SelectInput-DKjLQaqG.js";const x={all:"همه",students:"دانش‌آموزان",teachers:"معلمان",parents:"اولیا"};function v({announcements:l}){const[r,t]=o.useState(!1),a=d({title:"",body:"",audience:"all",is_important:!1});function i(s){s.preventDefault(),a.post("/school/announcements",{onSuccess:()=>{a.reset(),t(!1)}})}function n(s,c){confirm(`حذف اطلاعیه «${c}»؟`)&&m.delete(`/school/announcements/${s}`,{preserveScroll:!0})}return e.jsx(h,{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:()=>t(!r),children:[e.jsx("i",{className:"bi bi-megaphone"})," اطلاعیه جدید"]})]}),r&&e.jsxs("form",{className:"panel-card",onSubmit:i,children:[e.jsx("h2",{children:"اطلاعیه جدید"}),e.jsxs("div",{className:"form-grid",children:[e.jsx(p,{label:"عنوان",value:a.data.title,onChange:s=>a.setData("title",s.target.value),error:a.errors.title}),e.jsx(u,{label:"مخاطب",value:a.data.audience,onChange:s=>a.setData("audience",s.target.value),options:[{value:"all",label:"همه"},{value:"students",label:"دانش‌آموزان"},{value:"teachers",label:"معلمان"},{value:"parents",label:"اولیا"}]})]}),e.jsxs("label",{className:"form-field",children:[e.jsx("span",{children:"متن اطلاعیه"}),e.jsx("textarea",{className:"form-textarea",rows:4,value:a.data.body,onChange:s=>a.setData("body",s.target.value),style:{resize:"vertical"}})]}),a.errors.body&&e.jsx("p",{className:"form-error",children:a.errors.body}),e.jsxs("label",{className:"check-row",children:[e.jsx("input",{type:"checkbox",checked:a.data.is_important,onChange:s=>a.setData("is_important",s.target.checked)}),e.jsx("span",{children:"اطلاعیه مهم (popup در داشبورد دانش‌آموز)"})]}),e.jsxs("div",{className:"action-row",children:[e.jsx("button",{className:"btn btn-primary",disabled:a.processing,type:"submit",children:"انتشار"}),e.jsx("button",{className:"btn btn-ghost",type:"button",onClick:()=>t(!1),children:"لغو"})]})]}),l.length>0?e.jsx("div",{className:"page-stack",children:l.map(s=>e.jsxs("article",{className:"panel-card",children:[e.jsxs("div",{className:"section-header",style:{marginBottom:"0.5rem"},children:[e.jsxs("div",{children:[e.jsxs("h3",{style:{margin:0},children:[s.isImportant&&e.jsx("span",{className:"badge badge-danger",style:{marginLeft:"0.5rem"},children:"مهم"}),s.title]}),e.jsxs("small",{style:{color:"var(--color-text-muted)"},children:[x[s.audience]||s.audience," · ",s.publishedAt," · ",s.creator]})]}),e.jsx("button",{className:"btn btn-danger-ghost btn-sm",type:"button",onClick:()=>n(s.id,s.title),children:e.jsx("i",{className:"bi bi-trash"})})]}),e.jsx("p",{style:{margin:0,whiteSpace:"pre-wrap"},children:s.body})]},s.id))}):e.jsxs("section",{className:"panel-card",children:[e.jsx("h2",{children:"اطلاعیه‌ای منتشر نشده"}),e.jsx("p",{children:"از دکمه «اطلاعیه جدید» پیام خود را به کاربران مدرسه ارسال کنید."})]})]})})}export{v as default};
