import{j as v,u as $,e as M,c as S,g as k}from"./main.465728e1.js";import{u as E}from"./category.c88b90cd.js";import{J as I,G as T,ah as z,r as i,o as m,l as p,w as e,u as g,f as n,i as w,t as C,j as N,B as P,k as F,e as V,m as L,h as j,F as A}from"./vendor.d12b5734.js";import{_ as H}from"./CategoryModal.6fabb0b3.js";const O={props:{row:{type:Object,default:null},table:{type:Object,default:null},loadData:{type:Function,default:null}},setup(y){const d=y,B=v();$();const{t:o}=I(),s=E(),h=T(),_=M(),b=S();z("utils");function x(l){s.fetchCategory(l),b.openModal({title:o("settings.expense_category.edit_category"),componentName:"CategoryModal",refreshData:d.loadData,size:"sm"})}function r(l){B.openDialog({title:o("general.are_you_sure"),message:o("settings.expense_category.confirm_delete"),yesLabel:o("general.ok"),noLabel:o("general.cancel"),variant:"danger",hideNoButton:!1,size:"lg"}).then(async()=>{if((await s.deleteCategory(l)).data.success)return d.loadData&&d.loadData(),!0;d.loadData&&d.loadData()})}return(l,t)=>{const c=i("BaseIcon"),u=i("BaseButton"),f=i("BaseDropdownItem"),a=i("BaseDropdown");return m(),p(a,null,{activator:e(()=>[g(h).name==="expenseCategorys.view"?(m(),p(u,{key:0,variant:"primary"},{default:e(()=>[n(c,{name:"DotsHorizontalIcon",class:"h-5 text-white"})]),_:1})):(m(),p(c,{key:1,name:"DotsHorizontalIcon",class:"h-5 text-gray-500"}))]),default:e(()=>[g(_).hasAbilities(g(k).EDIT_EXPENSE)?(m(),p(f,{key:0,onClick:t[0]||(t[0]=D=>x(y.row.id))},{default:e(()=>[n(c,{name:"PencilIcon",class:"w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500"}),w(" "+C(l.$t("general.edit")),1)]),_:1})):N("",!0),g(_).hasAbilities(g(k).DELETE_EXPENSE)?(m(),p(f,{key:1,onClick:t[1]||(t[1]=D=>r(y.row.id))},{default:e(()=>[n(c,{name:"TrashIcon",class:"w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500"}),w(" "+C(l.$t("general.delete")),1)]),_:1})):N("",!0)]),_:1})}}},X={class:"w-64"},G={class:"truncate"},K={setup(y){const d=E();v();const B=S(),{t:o}=I(),s=P(null),h=F(()=>[{key:"name",label:o("settings.expense_category.category_name"),thClass:"extra",tdClass:"font-medium text-gray-900"},{key:"description",label:o("settings.expense_category.category_description"),thClass:"extra",tdClass:"font-medium text-gray-900"},{key:"actions",label:"",tdClass:"text-right text-sm font-medium",sortable:!1}]);async function _({page:r,filter:l,sort:t}){let c={orderByField:t.fieldName||"created_at",orderBy:t.order||"desc",page:r},u=await d.fetchCategories(c);return{data:u.data.data,pagination:{totalPages:u.data.meta.last_page,currentPage:r,totalCount:u.data.meta.total,limit:5}}}function b(){B.openModal({title:o("settings.expense_category.add_category"),componentName:"CategoryModal",size:"sm",refreshData:s.value&&s.value.refresh})}async function x(){s.value&&s.value.refresh()}return(r,l)=>{const t=i("BaseIcon"),c=i("BaseButton"),u=i("BaseTable"),f=i("BaseSettingCard");return m(),V(A,null,[n(H),n(f,{title:r.$t("settings.expense_category.title"),description:r.$t("settings.expense_category.description")},{action:e(()=>[n(c,{variant:"primary-outline",type:"button",onClick:b},{left:e(a=>[n(t,{class:L(a.class),name:"PlusIcon"},null,8,["class"])]),default:e(()=>[w(" "+C(r.$t("settings.expense_category.add_new_category")),1)]),_:1})]),default:e(()=>[n(u,{ref:(a,D)=>{D.table=a,s.value=a},data:_,columns:g(h),class:"mt-16"},{"cell-description":e(({row:a})=>[j("div",X,[j("p",G,C(a.data.description),1)])]),"cell-actions":e(({row:a})=>[n(O,{row:a.data,table:s.value,"load-data":x},null,8,["row","table"])]),_:1},8,["columns"])]),_:1},8,["title","description"])],64)}}};export{K as default};
