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