import{x as d,o as n,N as $,J as w,a as V,j as C,u as e,a5 as B,$ as D,b as h,c as k,d as v,w as I,t as U}from"./app-583c7dce.js";import{e as _}from"./invoice-63485875.js";import{u as T}from"./useSubmitForm-184dcd88.js";import{u as A}from"./useOpenModal-94afc182.js";import{u as N}from"./useDeleteModal-484b00a2.js";import{a as E}from"./helpers-7af1206d.js";import"./useEmitter-7699a4d3.js";const L={class:"mb-4"},j={__name:"CategoryModal",props:{modalId:String,tableId:String,selectedUrl:String},emits:["close"],setup(c,{emit:s}){const t=c,i=s,{preloader:y,formData:l,errors:p,save:g,closeModal:m}=T(t,i),u=()=>{let a={...l.value,type:"category"};g(t.selectedUrl?t.selectedUrl:_,a)};return(a,b)=>{const o=d("app-input"),r=d("app-modal");return n(),$(r,{"modal-id":c.modalId,"modal-size":"large",title:c.selectedUrl?a.$t("update_category"):a.$t("add_category"),preloader:e(y),onSubmit:u,onClose:e(m)},{body:w(()=>[V("div",L,[C(o,{type:"text",id:"name",label:a.$t("name"),"label-required":"",placeholder:a.$t("name"),modelValue:e(l).name,"onUpdate:modelValue":b[0]||(b[0]=f=>e(l).name=f),errors:a.$errors(e(p),"name")},null,8,["label","placeholder","modelValue","errors"])])]),_:1},8,["modal-id","title","preloader","onClose"])}}},q={class:"content-wrapper"},H={__name:"CategoryList",setup(c){const{canAccess:s}=B(),{t}=D(),i=h("categories-table"),y=h({url:_,pageSize:5,rowLimit:10,orderBy:"desc",showGridView:!1,actionType:"dropdown",paginationType:"pagination",enableRowSelect:!1,enableBulkSelect:!1,showSearch:!0,showFilter:!1,columns:[{title:t("name"),type:"text",key:"name"},{title:t("total_products"),type:"text",key:"total_products"},{title:t("created_at"),type:"object",key:"created_at",modifier:o=>E(o)},{title:t("action"),type:"action",align:"right"}],actions:[{title:t("edit"),type:"edit",icon:"bi bi-pencil-square",modifier:()=>s("update_categories")},{title:t("delete"),type:"delete",icon:"bi bi-trash3",modifier:()=>s("delete_categories")}]}),{isModalActive:l,selectedData:p,closeModal:g}=A(),{deleteUrl:m,isDeleteModal:u,cancelled:a}=N(),b=(o,r)=>{r.type==="edit"?(l.value=!0,p.value=`${_}/${o.id}`):r.type==="delete"&&(u.value=!0,m.value=`${_}/${o.id}`)};return(o,r)=>{const f=d("app-breadcrumb"),S=d("app-datatable"),M=d("app-delete-modal");return n(),k("div",q,[C(f,{"page-title":o.$t("categories")},{"breadcrumb-actions":w(()=>[e(s)("create_categories")?(n(),k("button",{key:0,onClick:r[0]||(r[0]=I(x=>l.value=!0,["prevent"])),class:"btn btn-primary text-white"},U(o.$t("add_category")),1)):v("",!0)]),_:1},8,["page-title"]),C(S,{id:i.value,options:y.value,onAction:b},null,8,["id","options"]),e(l)?(n(),$(j,{key:0,"table-id":i.value,"modal-id":"category-modal","selected-url":e(p),onClose:e(g)},null,8,["table-id","selected-url","onClose"])):v("",!0),e(u)?(n(),$(M,{key:1,"table-id":i.value,"selected-url":e(m),onCancelled:e(a)},null,8,["table-id","selected-url","onCancelled"])):v("",!0)])}}};export{H as default};
