import{L as w}from"./Layout-BEAmuehS.js";import{T as V}from"./TextInput-D6G3wYlu.js";import{L as x}from"./LoadingButton-fIGCYE5-.js";import{Z as k,i as N,r as s,c as a,o,a as u,b as n,d as C,h as c,f as y,w as p,F as g,j as _,t as d,e as L}from"./app-BLo7SiiE.js";import{S as B}from"./SelectInput-Bl1ROfev.js";import{_ as S}from"./FlashMessages-DImpr6PL.js";import"./moment-C7JtfGJw.js";import"./v4-SoommWqA.js";const U={metaInfo(){return{title:this.form.name}},components:{SelectInput:B,LoadingButton:x,TextInput:V,Link:N,Head:k},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(i,t,m,A,r,l){const b=s("Head"),f=s("select-input"),h=s("text-input"),v=s("loading-button");return o(),a("div",null,[u(b,{title:i.$t(m.title)},null,8,["title"]),n("div",D,[n("form",{onSubmit:t[4]||(t[4]=C((...e)=>l.update&&l.update(...e),["prevent"]))},[n("div",H,[r.form.parent_id?y("",!0):(o(),c(f,{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:i.$t("Department")},{default:p(()=>[t[5]||(t[5]=n("option",{value:null},"None",-1)),(o(!0),a(g,null,_(m.departments,e=>(o(),a("option",{key:e.id,value:e.id},d(e.name),9,I))),128))]),_:1,__:[5]},8,["modelValue","error","label"])),r.form.department_id?y("",!0):(o(),c(f,{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:i.$t("Parent")},{default:p(()=>[t[6]||(t[6]=n("option",{value:null},"None",-1)),(o(!0),a(g,null,_(m.categories,e=>(o(),a("option",{key:e.id,value:e.id},d(e.name),9,T))),128))]),_:1,__:[6]},8,["modelValue","error","label"])),u(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"])]),n("div",j,[n("button",{class:"text-red-600 hover:underline",tabindex:"-1",type:"button",onClick:t[3]||(t[3]=(...e)=>l.destroy&&l.destroy(...e))},d(i.$t("Delete Category")),1),u(v,{loading:r.form.processing,class:"btn-indigo ml-auto",type:"submit"},{default:p(()=>[L(d(i.$t("Update Category")),1)]),_:1},8,["loading"])])],32)])])}const J=S(U,[["render",q]]);export{J as default};
