"use strict";exports.id=84424,exports.ids=[84424],exports.modules={84424:(a,b,c)=>{c.r(b),c.d(b,{default:()=>m});var d=c(48249),e=c(67484),f=c(19099),g=c(3430),h=c(63754),i=c(82697),j=c(24403),k=c(40433),l=c(91115);function m(){let a=(0,f.useRouter)(),[b,c]=(0,e.useState)([]),[m,n]=(0,e.useState)([]),[o,p]=(0,e.useState)(!1),[q,r]=(0,e.useState)(""),[s,t]=(0,e.useState)(""),[u,v]=(0,e.useState)(""),[w,x]=(0,e.useState)(""),[y,z]=(0,e.useState)(()=>new Date().toISOString().slice(0,10)),[A,B]=(0,e.useState)(""),[C,D]=(0,e.useState)(""),[E,F]=(0,e.useState)("PUBLISHED"),G=async b=>{if(b.preventDefault(),u&&q.trim()){p(!0);try{let b=await (0,j.FJ)({schoolClassId:u,title:q.trim(),description:s.trim()||void 0,subjectId:w||null,assignedDate:y,dueDate:A||null,maxMarks:C?Number(C):null,status:E});(0,l.Te)("Homework created"),a.push(`${k.bw.SMS_TEACHER.HOMEWORK_EVAL}?homeworkId=${b.id}`)}catch(a){(0,l.Qg)(a instanceof Error?a.message:"Failed to create homework")}finally{p(!1)}}};return(0,d.jsx)(h.V,{title:"Add homework",description:"Assign work to your class.",children:(0,d.jsx)(i.a,{children:(0,d.jsxs)("form",{onSubmit:G,className:"space-y-4",children:[(0,d.jsx)(g.p,{label:"Title",value:q,onChange:a=>r(a.target.value),placeholder:"Homework title",required:!0}),(0,d.jsx)(i.yB,{label:"Description",children:(0,d.jsx)("textarea",{value:s,onChange:a=>t(a.target.value),rows:3,className:i.Mg,placeholder:"Instructions for students"})}),(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2",children:[(0,d.jsx)(i.yB,{label:"Class",children:(0,d.jsx)(i.Kd,{value:u,onChange:a=>v(a.target.value),required:!0,children:b.map(a=>(0,d.jsx)("option",{value:a.id,children:a.displayName},a.id))})}),(0,d.jsx)(i.yB,{label:"Subject",children:(0,d.jsxs)(i.Kd,{value:w,onChange:a=>x(a.target.value),children:[(0,d.jsx)("option",{value:"",children:"General"}),m.map(a=>(0,d.jsx)("option",{value:a.id,children:a.name},a.id))]})})]}),(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-3",children:[(0,d.jsx)(i.yB,{label:"Assigned date",children:(0,d.jsx)(i.IM,{value:y,onChange:a=>z(a.target.value)})}),(0,d.jsx)(i.yB,{label:"Due date",children:(0,d.jsx)(i.IM,{value:A,onChange:a=>B(a.target.value)})}),(0,d.jsx)(i.yB,{label:"Max marks",children:(0,d.jsx)("input",{type:"number",min:0,value:C,onChange:a=>D(a.target.value),className:i.Mg})})]}),(0,d.jsx)(i.yB,{label:"Status",children:(0,d.jsxs)(i.Kd,{value:E,onChange:a=>F(a.target.value),children:[(0,d.jsx)("option",{value:"PUBLISHED",children:"Published"}),(0,d.jsx)("option",{value:"DRAFT",children:"Draft"}),(0,d.jsx)("option",{value:"CLOSED",children:"Closed"})]})}),(0,d.jsx)(i.bE,{children:(0,d.jsx)(i.kL,{type:"submit",isLoading:o,disabled:!b.length,children:"Create homework"})})]})})})}}};