import{r as N,u as L,b as w,j as e}from"./vendor-BKmmeuxg.js";import{D as _}from"./datetime-picker-ZgzPotAT.js";import{I as i}from"./input-error-LaPr_4wd.js";import{L as F}from"./loading-button-BnTVAMJ7.js";import{B as E}from"./button-BpNwv2aE.js";import{C as T}from"./checkbox-BBZKtHnN.js";import{D as q,a as H,b as I,c as A,d as B,e as M,f as O}from"./dialog-B2gN9MvT.js";import{I as d}from"./input-DM0goJrn.js";import{L as s}from"./label-HmIcv5Yx.js";import{S as P}from"./scroll-area-C8HGru-R.js";import{o as c}from"./inertia-SZXqLvQm.js";import{k as R}from"./richtor-CRcM6Du2.js";import"./utils-DxSsnXxD.js";import"./popover-B4kBsMuI.js";import"./select-CD9o3HN1.js";import"./use-lang-YfV87_zl.js";import"./index-WW_1X1qx.js";const le=({title:k,assignment:a,handler:b})=>{const[f,m]=N.useState(!1),{props:p}=L(),{translate:D}=p,{dashboard:x,input:h,button:n}=D,{data:t,setData:l,post:v,put:y,reset:j,errors:o,processing:C}=w({title:(a==null?void 0:a.title)||"",course_id:p.course.id,total_mark:(a==null?void 0:a.total_mark)||"",pass_mark:(a==null?void 0:a.pass_mark)||"",retake:(a==null?void 0:a.retake)||1,summary:(a==null?void 0:a.summary)||"",deadline:a!=null&&a.deadline?new Date(a.deadline):new Date,late_submission:(a==null?void 0:a.late_submission)||!1,late_total_mark:(a==null?void 0:a.late_total_mark)||0,late_deadline:a!=null&&a.late_deadline?new Date(a.late_deadline):""}),S=r=>{r.preventDefault(),a?y(route("assignment.update",a.id),{onSuccess:()=>{j(),m(!1)}}):v(route("assignment.store"),{onSuccess:()=>{j(),m(!1)}})};return e.jsxs(q,{open:f,onOpenChange:m,children:[e.jsx(H,{children:b}),e.jsx(I,{className:"p-0",children:e.jsxs(P,{className:"max-h-[90vh] p-6",children:[e.jsx(A,{className:"mb-6",children:e.jsx(B,{children:k})}),e.jsxs("form",{onSubmit:S,className:"space-y-4 p-0.5",children:[e.jsxs("div",{children:[e.jsx(s,{children:h.title}),e.jsx(d,{required:!0,type:"text",name:"title",value:t.title,placeholder:"Enter assignment title",onChange:r=>c(r,l)}),e.jsx(i,{message:o.title})]}),e.jsxs("div",{children:[e.jsx(s,{children:"Deadline"}),e.jsx(_,{date:t.deadline,setDate:r=>l("deadline",r)}),e.jsx(i,{message:o.deadline})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx(s,{children:x.total_mark}),e.jsx(d,{required:!0,type:"number",name:"total_mark",value:t.total_mark,onChange:r=>c(r,l)}),e.jsx(i,{message:o.total_mark})]}),e.jsxs("div",{children:[e.jsx(s,{children:x.pass_mark}),e.jsx(d,{required:!0,type:"number",name:"pass_mark",value:t.pass_mark,onChange:r=>c(r,l)}),e.jsx(i,{message:o.pass_mark})]}),e.jsxs("div",{children:[e.jsx(s,{children:h.retake_attempts}),e.jsx(d,{min:"1",required:!0,type:"number",name:"retake",value:t.retake,placeholder:"00",onChange:r=>c(r,l)}),e.jsx(i,{message:o.retake})]})]}),e.jsxs("div",{children:[e.jsx(s,{htmlFor:"summary",children:"Summary"}),e.jsx(R,{ssr:!0,output:"html",placeholder:{paragraph:"Type assignment summary here...",imageCaption:"Type caption for image (optional)"},contentMinHeight:256,contentMaxHeight:640,initialContent:t.summary,onContentChange:r=>l(u=>({...u,summary:r}))}),e.jsx(i,{message:o.summary})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(T,{id:"late_submission",checked:t.late_submission,onCheckedChange:r=>l(u=>({...u,late_submission:r}))}),e.jsx(s,{htmlFor:"late_submission",className:"cursor-pointer",children:"Allow Late Submission"})]}),t.late_submission&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx(s,{children:"Late Submission Mark"}),e.jsx(d,{type:"number",name:"late_total_mark",value:t.late_total_mark,placeholder:"Enter marks for late submission",onChange:r=>c(r,l)}),e.jsx(i,{message:o.late_total_mark})]}),e.jsxs("div",{children:[e.jsx(s,{children:"Late Submission Deadline"}),e.jsx(_,{date:t.late_deadline?new Date(t.late_deadline):new Date,setDate:r=>l("late_deadline",r)}),e.jsx(i,{message:o.late_deadline})]})]}),e.jsxs(M,{className:"flex justify-end space-x-2 pt-4",children:[e.jsx(O,{asChild:!0,children:e.jsx(E,{type:"button",variant:"outline",children:n.close})}),e.jsx(F,{loading:C,children:n.submit})]})]})]})})]})};export{le as default};
