import{r as b,u as D,b as S,j as e}from"./vendor-rThclpOQ.js";import{I as C}from"./input-error-Br4ngfdE.js";import{L as v}from"./loading-button-DKhpmf6V.js";import{B as N}from"./button-ZcsoqUQn.js";import{D as y,a as I,b as L,c as _,d as B,e as E,f as F}from"./dialog-CDEDwQhm.js";import{I as H}from"./input-BeqyurrI.js";import{L as O}from"./label-CtY1vfZY.js";import{S as T}from"./scroll-area-BCwyUKIK.js";import{o as q}from"./inertia-SZXqLvQm.js";import"./utils-8KAaAB9H.js";import"./index-DquVdLUg.js";const U=({title:i,section:s,handler:l})=>{const[n,t]=b.useState(!1),{props:o}=D(),{translate:c}=o,{dashboard:p,input:m,button:r}=c,{data:d,setData:u,post:h,put:x,errors:f,processing:j}=S({title:s?s.title:"",sort:s?s.sort:o.lastSectionSort+1,course_id:o.course.id}),g=a=>{a.preventDefault(),s?x(route("section.update",{id:s.id}),{onSuccess:()=>t(!1)}):h(route("section.store"),{onSuccess:()=>t(!1)})};return e.jsxs(y,{open:n,onOpenChange:t,children:[e.jsx(I,{children:l}),e.jsx(L,{className:"p-0",children:e.jsxs(T,{className:"max-h-[90vh] p-6",children:[e.jsx(_,{className:"mb-6",children:e.jsx(B,{children:i})}),e.jsxs("form",{onSubmit:g,className:"space-y-4 p-0.5",children:[e.jsxs("div",{children:[e.jsx(O,{children:p.section_title}),e.jsx(H,{required:!0,type:"text",name:"title",value:d.title,placeholder:m.section_title_placeholder,onChange:a=>q(a,u)}),e.jsx(C,{message:f.title})]}),e.jsxs(E,{className:"flex justify-end space-x-2 pt-4",children:[e.jsx(F,{asChild:!0,children:e.jsx(N,{type:"button",variant:"outline",children:r.close})}),e.jsx(v,{loading:j,children:r.submit})]})]})]})})]})};export{U as default};
