import{I as w}from"./moment-C7JtfGJw.js";import{t as k,S as v,p as V}from"./SearchInput-BQxs0-MZ.js";import{L as C}from"./Layout-BEAmuehS.js";import{m as I}from"./mapValues-BsTqcYnb.js";import{P as N}from"./Pagination-Bj-Q2plQ.js";import{Z as L,i as y,r as n,c,o as f,a as r,b as t,w as l,t as d,f as S,F as j,j as B,e as p}from"./app-BLo7SiiE.js";import{_ as H}from"./FlashMessages-DImpr6PL.js";const P={metaInfo:{title:"Categories"},components:{SearchInput:v,Icon:w,Pagination:N,Link:y,Head:L},layout:C,props:{title:String,filters:Object,categories:Object},data(){return{form:{search:this.filters.search}}},watch:{form:{deep:!0,handler:k(function(){this.$inertia.get(this.route("categories"),V(this.form),{preserveState:!0})},150)}},methods:{getCategories(){let a=this.categories.data.filter(e=>!e.parent);for(let e=0;e<this.categories.data.length;e++)if(this.categories.data[e].parent){const o=a.findIndex(m=>m.id===this.categories.data[e].parent.id);o>-1&&a.splice(o+1,0,this.categories.data[e])}return a},reset(){this.form=I(this.form,()=>null)}}},D={class:"mb-6 flex justify-between items-center"},F={class:"bg-white rounded-md shadow overflow-x-auto"},O={class:"w-full whitespace-nowrap"},R={class:"border-t px-6 py-4"},E={class:"border-t px-6 py-4"},T={class:"border-t px-6 py-4"},U={class:"border-t w-px px-4"},Z={key:0};function q(a,e,o,m,u,h){const g=n("Head"),_=n("search-input"),i=n("Link"),b=n("icon"),x=n("pagination");return f(),c("div",null,[r(g,{title:a.$t(o.title)},null,8,["title"]),t("div",D,[r(_,{modelValue:u.form.search,"onUpdate:modelValue":e[0]||(e[0]=s=>u.form.search=s),class:"w-full max-w-md mr-4",onReset:h.reset},null,8,["modelValue","onReset"]),r(i,{class:"btn-indigo",href:a.route("categories.create")},{default:l(()=>[t("span",null,d(a.$t("Create New")),1)]),_:1},8,["href"])]),t("div",F,[t("table",O,[t("tbody",null,[e[2]||(e[2]=t("tr",{class:"text-left font-bold"},[t("th",{class:"px-6 pt-6 pb-4"},"Name"),t("th",{class:"px-6 pt-6 pb-4"},"Department"),t("th",{class:"px-6 pt-6 pb-4"},"Parent")],-1)),(f(!0),c(j,null,B(h.getCategories(),s=>(f(),c("tr",{key:s.id,class:"hover:bg-gray-100 focus-within:bg-gray-100"},[t("td",R,[r(i,{class:"flex items-center focus:text-indigo-500",href:a.route("categories.edit",s.id)},{default:l(()=>[p(d(s.parent?"   — ":"")+" "+d(s.name),1)]),_:2},1032,["href"])]),t("td",E,[r(i,{class:"flex items-center focus:text-indigo-500",href:a.route("categories.edit",s.id)},{default:l(()=>[p(d(s.department?s.department.name:"-"),1)]),_:2},1032,["href"])]),t("td",T,[r(i,{class:"flex items-center focus:text-indigo-500",href:a.route("categories.edit",s.id)},{default:l(()=>[p(d(s.parent?s.parent.name:"-"),1)]),_:2},1032,["href"])]),t("td",U,[r(i,{class:"flex items-center",href:a.route("categories.edit",s.id),tabindex:"-1"},{default:l(()=>[r(b,{name:"cheveron-right",class:"block w-6 h-6 fill-gray-400"})]),_:2},1032,["href"])])]))),128)),o.categories.data.length===0?(f(),c("tr",Z,e[1]||(e[1]=[t("td",{class:"border-t px-6 py-4",colspan:"4"},"No categories found.",-1)]))):S("",!0)])])]),r(x,{class:"mt-6",links:o.categories.links},null,8,["links"])])}const W=H(P,[["render",q]]);export{W as default};
