(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7418],{73497:function(e,t,a){Promise.resolve().then(a.bind(a,35911))},58064:function(e,t,a){"use strict";Object.defineProperty(t,"$",{enumerable:!0,get:function(){return r}});let s=a(74590);function r(e){let{createServerReference:t}=a(6671);return t(e,s.callServer)}},49447:function(e,t,a){"use strict";a.d(t,{P:function(){return s}}),a(74590);var s=(0,a(58064).$)("ea78b92e3c7994400e52fb84718c0dd2e8c55b9b")},2834:function(e,t,a){"use strict";a.d(t,{ep:function(){return l},h6:function(){return n},lE:function(){return r}}),a(74590);var s=a(58064),r=(0,s.$)("0a435b7bb2545622398293f1cac55cc3a6e9d9e3"),n=(0,s.$)("9b69cb0d8f7c6bf961495639bbe89a426ed56f87"),l=(0,s.$)("c3770d011b99ba83b13abdba687e44e4c947a223")},35911:function(e,t,a){"use strict";a.d(t,{default:function(){return c}});var s=a(57437),r=a(2265),n=a(2834),l=a(49447);function c(e){let{classes:t}=e,[a,c]=(0,r.useState)(""),[d,i]=(0,r.useState)(""),[u,o]=(0,r.useState)(""),[m,x]=(0,r.useState)(""),[b,f]=(0,r.useState)(""),[h,p]=(0,r.useState)(!1),[g,v]=(0,r.useState)(null);(0,r.useEffect)(()=>{(0,l.P)().then(c)},[]);let j=async e=>{if(e.preventDefault(),!d||!u||!m||!b){v({type:"error",text:"Please fill all fields."});return}p(!0),v(null);try{let e=await (0,n.h6)({classId:Number(d),name:u,startDate:new Date(m),endDate:new Date(b)});e.success?(v({type:"success",text:e.message||"Exams created."}),o("")):v({type:"error",text:e.error||"Failed."})}catch(e){v({type:"error",text:"Error submitting."})}finally{p(!1)}};return(0,s.jsxs)("div",{className:"space-y-6 max-w-lg",children:[(0,s.jsxs)("div",{className:"border-b pb-4",children:[(0,s.jsx)("h1",{className:"text-xl font-semibold text-gray-800",children:"Exam Setup"}),(0,s.jsx)("p",{className:"text-sm text-gray-500",children:"Create subject exams for a class."}),(0,s.jsxs)("div",{className:"mt-2 text-sm text-school-green-700 font-bold",children:["Active Year: ",a||"Loading..."]})]}),(0,s.jsxs)("form",{onSubmit:j,className:"space-y-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block text-sm font-medium text-gray-700",children:"Exam Name (e.g. Mid Term)"}),(0,s.jsx)("input",{type:"text",className:"w-full p-2 border rounded",value:u,onChange:e=>o(e.target.value),placeholder:"Mid Term Exams"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block text-sm font-medium text-gray-700",children:"Class"}),(0,s.jsxs)("select",{className:"w-full p-2 border rounded",value:d,onChange:e=>i(Number(e.target.value)),children:[(0,s.jsx)("option",{value:"",children:"Select Class"}),t.map(e=>(0,s.jsx)("option",{value:e.id,children:e.name},e.id))]})]}),(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block text-sm font-medium text-gray-700",children:"Start Date"}),(0,s.jsx)("input",{type:"date",className:"w-full p-2 border rounded",value:m,onChange:e=>x(e.target.value)})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block text-sm font-medium text-gray-700",children:"End Date"}),(0,s.jsx)("input",{type:"date",className:"w-full p-2 border rounded",value:b,onChange:e=>f(e.target.value)})]})]}),g&&(0,s.jsx)("div",{className:"p-2 rounded text-sm ".concat("success"===g.type?"bg-green-100 text-green-800":"bg-red-100 text-red-800"),children:g.text}),(0,s.jsx)("button",{type:"submit",disabled:h,className:"w-full bg-school-green-600 text-white py-2 rounded hover:bg-school-green-500 disabled:opacity-50",children:h?"Creating...":"Create Exam Batch"})]})]})}}},function(e){e.O(0,[2971,7023,1744],function(){return e(e.s=73497)}),_N_E=e.O()}]);