import{aU as j,j as e,df as u}from"./react-vendor-xYZnmIII.js";import{I as c}from"./input-error-_LAmvivg.js";import{L as b}from"./loading-button-D7aXR3K4.js";import{L as l,I as f,at as k,au as v,av as N,aw as _,ax as i,T as S,U as C,B as y}from"./ui-components-CQM92IK3.js";import"./inertia-vendor-cBbDTmhJ.js";import"./ui-vendor-Ds9iwIxa.js";import"./interactive-vendor-B1OgcAgP.js";const U=({isGraded:m,isLate:o,totalMarks:r,submission:a})=>{const{data:s,setData:d,post:p,put:g,processing:x,errors:n}=j({marks_obtained:a?a.marks_obtained:"",instructor_feedback:a?a.instructor_feedback:"",status:a?a.status:"pending"}),h=t=>{t.preventDefault(),a?g(route("assignment.submission.update",a.id)):p(route("assignment.submission.store"))};return e.jsxs("form",{onSubmit:h,className:"space-y-4 rounded-lg border p-4",children:[e.jsxs("h3",{className:"flex items-center gap-2 font-semibold",children:[e.jsx(u,{className:"text-primary h-5 w-5"}),m?"Update Grade":"Grade Submission"]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(l,{htmlFor:"marks",children:["Marks Obtained *",e.jsxs("span",{className:"text-muted-foreground ml-1 text-xs",children:["(Max: ",r,o&&e.jsx("span",{className:"text-destructive",children:" - Late Submission"}),")"]})]}),e.jsx(f,{id:"marks",type:"number",min:"0",max:r,step:"0.01",placeholder:"Enter marks",value:s.marks_obtained,onChange:t=>d("marks_obtained",t.target.value),required:!0}),o&&s.marks_obtained&&parseFloat(s.marks_obtained)>r&&e.jsxs("p",{className:"text-destructive text-xs",children:["Cannot exceed late submission maximum (",r,")"]}),e.jsx(c,{message:n.marks_obtained})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"status",children:"Status"}),e.jsxs(k,{value:s.status,onValueChange:t=>d("status",t),children:[e.jsx(v,{children:e.jsx(N,{})}),e.jsxs(_,{children:[e.jsx(i,{value:"pending",children:"Pending"}),e.jsx(i,{value:"graded",children:"Graded"}),e.jsx(i,{value:"resubmitted",children:"Resubmitted"})]})]}),e.jsx(c,{message:n.status})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"feedback",children:"Instructor Feedback (Optional)"}),e.jsx(S,{id:"feedback",placeholder:"Provide feedback to the student...",value:s.instructor_feedback||"",onChange:t=>d("instructor_feedback",t.target.value),rows:4}),e.jsx(c,{message:n.instructor_feedback})]}),s.status==="graded"&&(a==null?void 0:a.grader)&&e.jsxs("div",{className:"rounded-lg border border-green-200 bg-green-50 p-3 dark:border-green-800 dark:bg-green-950",children:[e.jsxs("p",{className:"text-sm",children:[e.jsx("span",{className:"font-medium",children:"Previously graded:"})," ",a.marks_obtained," / ",r]}),a.instructor_feedback&&e.jsxs("p",{className:"text-muted-foreground mt-1 text-sm",children:["Previous feedback: ",a.instructor_feedback]})]}),e.jsxs("div",{className:"flex justify-end gap-3 pt-4",children:[e.jsx(C,{asChild:!0,children:e.jsx(y,{variant:"outline",children:"Cancel"})}),e.jsx(b,{type:"submit",className:"gap-2",loading:x,disabled:x||!s.marks_obtained,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(u,{className:"h-4 w-4"}),m?"Update Grade":"Submit Grade"]})})]})]})};export{U as default};
