import{r as n,j as e,a as u}from"./app-DP6lEqpE.js";import{A as p}from"./AppLayout-DveQsGoq.js";const b={submitted:"ارسال شده",late:"دیر ارسال",reviewed:"بررسی شد",returned:"بازگشت داده شد"};function g({homeworks:c}){const[m,l]=n.useState(null),[o,r]=n.useState(""),[d,a]=n.useState(null);function x(s,t){s.preventDefault();const i=new FormData;i.append("body",o),d&&i.append("file",d),u.post(`/student/homeworks/${t}`,i,{forceFormData:!0,onSuccess:()=>{l(null),r(""),a(null)}})}return e.jsx(p,{title:"تکالیف",children:e.jsxs("div",{className:"page-stack",children:[e.jsx("section",{className:"section-header",children:e.jsxs("div",{children:[e.jsxs("h2",{children:[e.jsx("i",{className:"bi bi-journal-check",style:{marginLeft:"0.5rem",color:"var(--color-primary)"}}),"تکالیف"]}),e.jsx("p",{children:"تکالیف منتشرشده برای کلاس‌های شما"})]})}),c.length===0?e.jsx("section",{className:"panel-card",children:e.jsxs("div",{style:{textAlign:"center",padding:"2rem 1rem"},children:[e.jsx("div",{className:"icon-badge",style:{width:56,height:56,fontSize:"1.5rem",margin:"0 auto 1rem"},children:e.jsx("i",{className:"bi bi-journal-check"})}),e.jsx("h2",{children:"تکلیفی وجود ندارد"}),e.jsx("p",{children:"در حال حاضر تکلیف فعالی برای کلاس‌های شما ثبت نشده است."})]})}):e.jsx("div",{className:"card-grid",children:c.map(s=>e.jsxs("article",{className:"panel-card",style:{display:"flex",flexDirection:"column",gap:"0.75rem",borderColor:s.submitted?"var(--color-primary-soft)":void 0,background:s.submitted?"var(--color-primary-soft)":void 0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"0.75rem"},children:[e.jsx("span",{className:"icon-badge",style:{flexShrink:0},children:e.jsx("i",{className:"bi bi-journal-check"})}),e.jsxs("div",{style:{flex:1},children:[e.jsx("h3",{style:{margin:0,fontSize:"1rem"},children:s.title}),e.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap",marginTop:"0.25rem"},children:[e.jsxs("span",{style:{fontSize:"0.8rem",color:"var(--color-text-muted)"},children:[e.jsx("i",{className:"bi bi-door-open",style:{marginLeft:"0.25rem"}}),s.classroom]}),s.subject!=="—"&&e.jsxs("span",{style:{fontSize:"0.8rem",color:"var(--color-text-muted)"},children:[e.jsx("i",{className:"bi bi-book",style:{marginLeft:"0.25rem"}}),s.subject]})]}),s.description&&e.jsx("p",{style:{margin:"0.4rem 0 0",fontSize:"0.875rem",color:"var(--color-text-muted)"},children:s.description})]}),s.submitted&&s.submissionStatus&&e.jsxs("span",{className:"badge badge-success",style:{flexShrink:0},children:[e.jsx("i",{className:"bi bi-check2-circle"})," ",b[s.submissionStatus]??s.submissionStatus]})]}),s.dueAt!=="—"&&e.jsxs("div",{style:{fontSize:"0.82rem",color:"var(--color-text-muted)"},children:[e.jsx("i",{className:"bi bi-calendar-x",style:{marginLeft:"0.3rem"}}),"مهلت تحویل: ",s.dueAt]}),s.submitted?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.4rem",background:"white",border:"1px solid var(--color-primary-soft)",borderRadius:"var(--radius-sm)",color:"var(--color-primary-active)",fontSize:"0.875rem",fontWeight:700,padding:"0.6rem 0.9rem"},children:[e.jsx("i",{className:"bi bi-check-circle-fill"}),"تکلیف ارسال شد",s.submittedAt&&e.jsx("span",{style:{fontWeight:400,color:"var(--color-text-muted)",marginRight:"auto",fontSize:"0.8rem"},children:s.submittedAt})]}):m===s.id?e.jsxs("form",{onSubmit:t=>x(t,s.id),style:{display:"flex",flexDirection:"column",gap:"0.6rem"},children:[e.jsx("textarea",{className:"form-control",rows:3,placeholder:"توضیحات یا متن پاسخ (اختیاری)",value:o,onChange:t=>r(t.target.value),maxLength:5e3}),s.allowFileUpload&&e.jsxs("div",{children:[e.jsxs("label",{className:"form-label",style:{fontSize:"0.85rem"},children:[e.jsx("i",{className:"bi bi-paperclip",style:{marginLeft:"0.3rem"}}),"فایل ضمیمه (اختیاری، حداکثر ۱۰ مگابایت)"]}),e.jsx("input",{type:"file",className:"form-control",onChange:t=>{var i;return a(((i=t.target.files)==null?void 0:i[0])??null)},accept:".pdf,.jpg,.jpeg,.png,.gif,.webp,.doc,.docx,.txt"})]}),e.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[e.jsxs("button",{type:"submit",className:"btn btn-primary btn-sm",children:[e.jsx("i",{className:"bi bi-send"})," ارسال تکلیف"]}),e.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:()=>{l(null),r(""),a(null)},children:"انصراف"})]})]}):e.jsxs("button",{className:"btn btn-primary",style:{textAlign:"center"},onClick:()=>l(s.id),children:[e.jsx("i",{className:"bi bi-send"})," ارسال پاسخ"]})]},s.id))})]})})}export{g as default};
