import{a7 as k,u as M,v as E,L as T,M as z,F as I,a5 as P,r as c,o as m,m as p,w as e,l as g,a as s,Q as v,p as D,t as C,K as w,f as j,k as F,c as L,J as V,b as S,N as A}from"./main-B9dpPbRR.js";import{u as N}from"./category-PmZRvdLB.js";import{_ as H}from"./CategoryModal-rNWu40xq.js";const O={__name:"ExpenseCategoryIndexDropdown",props:{row:{type:Object,default:null},table:{type:Object,default:null},loadData:{type:Function,default:null}},setup(y){const i=y,x=k();M();const{t:a}=E.useI18n(),o=N(),B=T(),_=z(),h=I();P("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 m(),p(u,null,{activator:e(()=>[g(B).name==="expenseCategorys.view"?(m(),p(d,{key:0,variant:"primary"},{default:e(()=>[s(l,{name:"DotsHorizontalIcon",class:"h-5 text-white"})]),_:1})):(m(),p(l,{key:1,name:"DotsHorizontalIcon",class:"h-5 text-gray-500"}))]),default:e(()=>[g(_).hasAbilities(g(v).EDIT_EXPENSE)?(m(),p(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)?(m(),p(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})}}},X={class:"w-64"},J={class:"truncate"},U={__name:"ExpenseCategorySetting",setup(y){const i=N();k();const x=I(),{t:a}=E.useI18n(),o=j(null),B=F(()=>[{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 m(),L(A,null,[s(H),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:V(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})=>[S("div",X,[S("p",J,C(u.data.description),1)])]),"cell-actions":e(({row:u})=>[s(O,{row:u.data,table:o.value,"load-data":b},null,8,["row","table"])]),_:1},8,["columns"])]),_:1},8,["title","description"])],64)}}};export{U as default};
