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