import{d as C,o,f as _,J as E,z as t,c as a,a as e,l as A,v as V,t as N,e as m,g as L,r as S,b as F,w,F as T,m as z,H as P}from"./app-91dba96b.js";import{i as G}from"./index-0653e21c.js";import{u as H}from"./useEmitter-cde057d4.js";import{u as J}from"./useOpenModal-248d9645.js";import{u as q}from"./useDeleteModal-1f988578.js";import{n as K}from"./laravel-vue-pagination.es-47c433e6.js";import{u as U}from"./urlGenerator-87d92adb.js";import{l as Q}from"./lodash-569b8a6d.js";import{u as R}from"./useSubmitForm-bd99a12d.js";import"./appFunction-1b5b1f43.js";import"./_commonjsHelpers-725317a4.js";const W={key:1},X={class:"mb-3"},Y=e("label",{class:"name"},[L("Name "),e("span",{class:"text-danger"},"*")],-1),Z={key:0,class:"text-danger"},j={__name:"categoryModal",props:{modalId:String,selectedUrl:String},emits:["close"],setup(v,{emit:u}){const r=v,k=u,{preloader:h,pageLoader:g,errors:y,save:p,formData:n,closeModal:d}=R(r,k),b=()=>{p(r.selectedUrl?r.selectedUrl:"category",n.value)};return(i,f)=>{const $=C("app-loader"),x=C("app-modal");return o(),_(x,{"modal-id":v.modalId,"modal-size":"small",title:v.selectedUrl?"Update Category":"Add Category",preloader:t(h),onSubmit:b,onClose:t(d)},{body:E(()=>[t(g)?(o(),_($,{key:0})):(o(),a("form",W,[e("div",X,[Y,A(e("input",{type:"text",id:"name","onUpdate:modelValue":f[0]||(f[0]=D=>t(n).name=D),class:"form-control",placeholder:"Enter name"},null,512),[[V,t(n).name]]),t(y).name?(o(),a("small",Z,N(t(y).name[0]),1)):m("",!0)])]))]),_:1},8,["modal-id","title","preloader","onClose"])}}},O={class:"content"},ee={class:"container-fluid p-0"},te={class:"mb-3"},oe=e("h1",{class:"h3 d-inline align-middle"},[e("strong",null,"Category List")],-1),se={class:"search-container d-flex justify-content-end align-items-center"},ae={class:"row"},le={class:"col-12"},ne={class:"card"},ce={key:1,class:"table-responsive"},re={class:"table mb-3"},de=e("thead",null,[e("tr",null,[e("th",{scope:"col"},"Name"),e("th",{scope:"col",class:"text-end",style:{width:"5%"}},"Action")])],-1),ie={class:"table-action"},me={class:"row"},ue={key:0,class:"col-md-6"},pe=["onClick"],_e=["src"],ve={key:1,class:"col-md-6 pull-left"},he=["onClick"],ge=["src"],Ue={__name:"index",setup(v){const{isModalActive:u,selectedData:r,closeModal:k}=J(),{deleteUrl:h,isDeleteModal:g,cancelled:y}=q(),p=S({}),n=S(!1),d=S(""),b=Q.debounce(()=>{d.value?i(1,d.value):i(1)},500),i=(s=1,l="")=>{n.value=!0,G.get(`category?page=${s}&search=${l}`).then(M=>{p.value=M.data}).finally(()=>n.value=!1)},f=s=>{u.value=!0,r.value=`category/${s.id}`},$=s=>{g.value=!0,h.value=`category/${s.id}`},x=H(),D=()=>{x.on("reload-table",(s=!0)=>{s&&i()})};return F(()=>{i(),D()}),(s,l)=>{const M=C("app-loader"),I=C("app-delete-modal");return o(),a("main",O,[e("div",ee,[e("div",te,[oe,s.$canAccess("create_category")?(o(),a("a",{key:0,href:"",onClick:l[0]||(l[0]=w(c=>u.value=!0,["prevent"])),class:"btn bg-primary text-white float-end"}," Add Category ")):m("",!0)])]),e("div",se,[A(e("input",{type:"text",class:"form-control","onUpdate:modelValue":l[1]||(l[1]=c=>d.value=c),onInput:l[2]||(l[2]=c=>t(b)()),placeholder:"Search..."},null,544),[[V,d.value]])]),e("div",ae,[e("div",le,[e("div",ne,[n.value?(o(),_(M,{key:0})):(o(),a("div",ce,[e("table",re,[de,e("tbody",null,[(o(!0),a(T,null,z(p.value.data,c=>(o(),a("tr",null,[e("td",null,N(c.name),1),e("td",ie,[e("div",me,[s.$canAccess("update_category")?(o(),a("div",ue,[e("a",{onClick:w(B=>f(c),["prevent"])},[e("img",{class:"action_icon",src:t(U)("assets/img/icons/edit.svg"),alt:"Icon"},null,8,_e)],8,pe)])):m("",!0),s.$canAccess("delete_category")?(o(),a("div",ve,[e("a",{onClick:w(B=>$(c),["prevent"])},[e("img",{class:"action_icon",src:t(U)("assets/img/icons/trash.svg"),alt:"Icon"},null,8,ge)],8,he)])):m("",!0)])])]))),256))])])])),P(t(K),{data:p.value,onPaginationChangePage:i},null,8,["data"])])])]),t(u)?(o(),_(j,{key:0,"modal-id":"category-modal","selected-url":t(r),onClose:t(k)},null,8,["selected-url","onClose"])):m("",!0),t(g)?(o(),_(I,{key:1,"selected-url":t(h),onCancelled:t(y)},null,8,["selected-url","onCancelled"])):m("",!0)])}}};export{Ue as default};
