import{L as w}from"./Layout-DIVdUaBZ.js";import{T as x}from"./TextInput-DDvOh0mT.js";import{L as V}from"./LoadingButton-DQHYFAIm.js";import{i as k,Z as N,r as l,c as i,a as m,b as o,d as C,g as f,w as u,h as c,o as n,F as g,j as y,t as _,e as L}from"./app-CK3cEAAe.js";import{S as B}from"./SelectInput-CJrVPIBV.js";import{_ as S}from"./FlashMessages-ByEdcHWZ.js";import"./moment-BywspGD9.js";import"./v4-SoommWqA.js";const U={metaInfo(){return{title:this.form.name}},components:{SelectInput:B,LoadingButton:V,TextInput:x,Link:k,Head:N},layout:w,props:{title:String,category:Object,categories:{required:!1},departments:{required:!1}},remember:"form",data(){return{form:this.$inertia.form({name:this.category.name,color:this.category.color,department_id:this.category.department_id,parent_id:this.category.parent_id})}},methods:{update(){this.form.put(this.route("categories.update",this.category.id))},destroy(){confirm("Are you sure you want to delete this category?")&&this.$inertia.delete(this.route("categories.destroy",this.category.id))},restore(){confirm("Are you sure you want to restore this category?")&&this.$inertia.put(this.route("categories.restore",this.category.id))}}},D={class:"bg-white rounded-md shadow overflow-hidden max-w-3xl"},H={class:"p-8 -mr-6 -mb-8 flex flex-wrap"},I=["value"],T=["value"],j={class:"px-8 py-4 bg-gray-50 border-t border-gray-100 flex items-center"};function q(s,t,d,A,r,a){const b=l("Head"),p=l("select-input"),h=l("text-input"),v=l("loading-button");return n(),i("div",null,[m(b,{title:s.$t(d.title)},null,8,["title"]),o("div",D,[o("form",{onSubmit:t[4]||(t[4]=C((...e)=>a.update&&a.update(...e),["prevent"]))},[o("div",H,[r.form.parent_id?c("",!0):(n(),f(p,{key:0,modelValue:r.form.department_id,"onUpdate:modelValue":t[0]||(t[0]=e=>r.form.department_id=e),error:r.form.errors.department_id,class:"pr-6 pb-8 w-full",label:s.$t("Department")},{default:u(()=>[t[5]||(t[5]=o("option",{value:null},"None",-1)),(n(!0),i(g,null,y(d.departments,e=>(n(),i("option",{key:e.id,value:e.id},_(e.name),9,I))),128))]),_:1},8,["modelValue","error","label"])),r.form.department_id?c("",!0):(n(),f(p,{key:1,modelValue:r.form.parent_id,"onUpdate:modelValue":t[1]||(t[1]=e=>r.form.parent_id=e),error:r.form.errors.parent_id,class:"pr-6 pb-8 w-full",label:s.$t("Parent")},{default:u(()=>[t[6]||(t[6]=o("option",{value:null},"None",-1)),(n(!0),i(g,null,y(d.categories,e=>(n(),i("option",{key:e.id,value:e.id},_(e.name),9,T))),128))]),_:1},8,["modelValue","error","label"])),m(h,{modelValue:r.form.name,"onUpdate:modelValue":t[2]||(t[2]=e=>r.form.name=e),error:r.form.errors.name,class:"pr-6 pb-8 w-full",label:"Name"},null,8,["modelValue","error"])]),o("div",j,[o("button",{class:"text-red-600 hover:underline",tabindex:"-1",type:"button",onClick:t[3]||(t[3]=(...e)=>a.destroy&&a.destroy(...e))},"Delete Category"),m(v,{loading:r.form.processing,class:"btn-indigo ml-auto",type:"submit"},{default:u(()=>t[7]||(t[7]=[L("Update Category")])),_:1},8,["loading"])])],32)])])}const J=S(U,[["render",q]]);export{J as default};
