import{r as C,b as D,j as e}from"./vendor-rThclpOQ.js";import{I}from"./icon-picker-dialog-Bko_3r6q.js";import{I as l}from"./input-error-Br4ngfdE.js";import{L as N}from"./loading-button-DKhpmf6V.js";import{B as _}from"./button-ZcsoqUQn.js";import{D as L,a as T,b as B,c as E,d as F,e as k,f as A}from"./dialog-CDEDwQhm.js";import{I as h}from"./input-BeqyurrI.js";import{L as r}from"./label-CtY1vfZY.js";import{S as H}from"./scroll-area-BCwyUKIK.js";import{S as O,a as P,b as V,c as q,d as u}from"./select-u0okJC03.js";import{T as y}from"./textarea-DM_GyfeP.js";import{u as R}from"./use-lang-BK6P2WMc.js";import{o as x}from"./inertia-SZXqLvQm.js";import"./icon-picker-B7sCh2g1.js";import"./debounce-CWHP_ANh.js";import"./tooltip-WOIaUmuC.js";import"./utils-8KAaAB9H.js";import"./index-DquVdLUg.js";const re=({title:j,category:t,handler:g})=>{const[f,c]=C.useState(!1),{input:a,button:m}=R(),{data:o,setData:i,post:d,errors:n,processing:v,reset:b}=D({title:t?t.title:"",icon:t?t.icon:"",status:t?t.status?1:0:1,description:t?t.description:"",thumbnail:null}),S=s=>{s.preventDefault(),t?d(route("exam-categories.update",t.id),{onSuccess:()=>c(!1)}):d(route("exam-categories.store"),{onSuccess:()=>{b(),c(!1)}})};return e.jsxs(L,{open:f,onOpenChange:c,children:[e.jsx(T,{children:g}),e.jsx(B,{className:"p-0",children:e.jsxs(H,{className:"max-h-[90vh] p-6",children:[e.jsx(E,{className:"mb-6",children:e.jsx(F,{children:j})}),e.jsxs("form",{onSubmit:S,className:"space-y-4 p-0.5",children:[e.jsxs("div",{children:[e.jsx(r,{children:a.title}),e.jsx(h,{required:!0,type:"text",name:"title",value:o.title,placeholder:a.title_placeholder,onChange:s=>x(s,i)}),e.jsx(l,{message:n.title})]}),e.jsxs("div",{children:[e.jsx(r,{children:a.category_icon}),e.jsx(I,{name:"icon",value:o.icon||"",placeholder:"Pick your category icon",onSelect:s=>i("icon",s)}),e.jsx(l,{message:n.icon})]}),e.jsxs("div",{children:[e.jsx(r,{children:a.category_status}),e.jsxs(O,{value:o.status.toString(),onValueChange:s=>i("status",Number(s)),children:[e.jsx(P,{children:e.jsx(V,{placeholder:a.status_placeholder})}),e.jsxs(q,{children:[e.jsx(u,{value:"1",children:"Active"}),e.jsx(u,{value:"0",children:"Inactive"})]})]})]}),e.jsxs("div",{children:[e.jsx(r,{children:a.description}),e.jsx(y,{name:"description",value:o.description,placeholder:a.description_placeholder,onChange:s=>x(s,i)}),e.jsx(l,{message:n.description})]}),e.jsxs("div",{children:[e.jsx(r,{children:a.thumbnail}),e.jsx(h,{type:"file",name:"thumbnail",accept:"image/*",onChange:s=>{var p;return i("thumbnail",(p=s.target.files)==null?void 0:p[0])}}),e.jsx(l,{message:n.thumbnail})]}),e.jsxs(k,{className:"flex justify-end space-x-2 pt-4",children:[e.jsx(A,{asChild:!0,children:e.jsx(_,{type:"button",variant:"outline",children:m.close})}),e.jsx(N,{loading:v,children:m.save_changes})]})]})]})})]})};export{re as default};
