import{r as D,aT as S,aU as b,j as e}from"./react-vendor-xYZnmIII.js";import{I as C}from"./input-error-_LAmvivg.js";import{L as N}from"./loading-button-D7aXR3K4.js";import{J as v,K as y,M as I,e as L,N as _,O as B,L as E,I as F,Q as O,U as T,B as H}from"./ui-components-CQM92IK3.js";import{o as U}from"./inertia-FIn3q7f1.js";import"./inertia-vendor-cBbDTmhJ.js";import"./ui-vendor-Ds9iwIxa.js";import"./interactive-vendor-B1OgcAgP.js";const k=({title:i,section:s,handler:l})=>{const[n,t]=D.useState(!1),{props:a}=S(),{translate:c}=a,{dashboard:p,input:d,button:r}=c,{data:u,setData:m,post:h,put:x,errors:j,processing:g}=b({title:s?s.title:"",sort:s?s.sort:a.lastSectionSort+1,course_id:a.course.id}),f=o=>{o.preventDefault(),s?x(route("section.update",{id:s.id}),{onSuccess:()=>t(!1)}):h(route("section.store"),{onSuccess:()=>t(!1)})};return e.jsxs(v,{open:n,onOpenChange:t,children:[e.jsx(y,{children:l}),e.jsx(I,{className:"p-0",children:e.jsxs(L,{className:"max-h-[90vh] p-6",children:[e.jsx(_,{className:"mb-6",children:e.jsx(B,{children:i})}),e.jsxs("form",{onSubmit:f,className:"space-y-4 p-0.5",children:[e.jsxs("div",{children:[e.jsx(E,{children:p.section_title}),e.jsx(F,{required:!0,type:"text",name:"title",value:u.title,placeholder:d.section_title_placeholder,onChange:o=>U(o,m)}),e.jsx(C,{message:j.title})]}),e.jsxs(O,{className:"flex justify-end space-x-2 pt-4",children:[e.jsx(T,{asChild:!0,children:e.jsx(H,{type:"button",variant:"outline",children:r.close})}),e.jsx(N,{loading:g,children:r.submit})]})]})]})})]})};export{k as default};
