import{a7 as z,u as C,v as I,L as T,M as x,F as M,a5 as E,r,o as d,m as p,w as t,l as m,a as i,Q as v,p as S,t as D,K as k,f as O,k as j,c as F,J as P,N as G,H}from"./main-B9dpPbRR.js";import{u as A,_ as L}from"./NoteModal-h_90cxoW.js";import"./payment-Y8OywN76.js";const V={__name:"NoteIndexDropdown",props:{row:{type:Object,default:null},table:{type:Object,default:null},loadData:{type:Function,default:null}},setup(_){const c=_,B=z(),g=C(),{t:a}=I.useI18n(),o=A(),h=T(),y=x(),w=M();E("utils");function b(n){o.fetchNote(n),w.openModal({title:a("settings.customization.notes.edit_note"),componentName:"NoteModal",size:"md",refreshData:c.loadData})}function s(n){B.openDialog({title:a("general.are_you_sure"),message:a("settings.customization.notes.note_confirm_delete"),yesLabel:a("general.yes"),noLabel:a("general.no"),variant:"danger",hideNoButton:!1,size:"lg"}).then(async()=>{(await o.deleteNote(n)).data.success?g.showNotification({type:"success",message:a("settings.customization.notes.deleted_message")}):g.showNotification({type:"error",message:a("settings.customization.notes.already_in_use")}),c.loadData&&c.loadData()})}return(n,e)=>{const l=r("BaseIcon"),u=r("BaseButton"),N=r("BaseDropdownItem"),f=r("BaseDropdown");return d(),p(f,null,{activator:t(()=>[m(h).name==="notes.view"?(d(),p(u,{key:0,variant:"primary"},{default:t(()=>[i(l,{name:"DotsHorizontalIcon",class:"h-5 text-white"})]),_:1})):(d(),p(l,{key:1,name:"DotsHorizontalIcon",class:"h-5 text-gray-500"}))]),default:t(()=>[m(y).hasAbilities(m(v).MANAGE_NOTE)?(d(),p(N,{key:0,onClick:e[0]||(e[0]=$=>b(_.row.id))},{default:t(()=>[i(l,{name:"PencilIcon",class:"w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500"}),S(" "+D(n.$t("general.edit")),1)]),_:1})):k("",!0),m(y).hasAbilities(m(v).MANAGE_NOTE)?(d(),p(N,{key:1,onClick:e[1]||(e[1]=$=>s(_.row.id))},{default:t(()=>[i(l,{name:"TrashIcon",class:"w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500"}),S(" "+D(n.$t("general.delete")),1)]),_:1})):k("",!0)]),_:1})}}},R={__name:"NotesSetting",setup(_){const{t:c}=I.useI18n(),B=M();z();const g=A();C();const a=x(),o=O(""),h=j(()=>[{key:"name",label:c("settings.customization.notes.name"),thClass:"extra",tdClass:"font-medium text-gray-900"},{key:"type",label:c("settings.customization.notes.type"),thClass:"extra",tdClass:"font-medium text-gray-900"},{key:"actions",label:"",tdClass:"text-right text-sm font-medium",sortable:!1}]);async function y({page:s,filter:n,sort:e}){let l=H({orderByField:e.fieldName||"created_at",orderBy:e.order||"desc",page:s}),u=await g.fetchNotes(l);return{data:u.data.data,pagination:{totalPages:u.data.meta.last_page,currentPage:s,totalCount:u.data.meta.total,limit:5}}}async function w(){await B.openModal({title:c("settings.customization.notes.add_note"),componentName:"NoteModal",size:"md",refreshData:o.value&&o.value.refresh})}async function b(){o.value&&o.value.refresh()}return(s,n)=>{const e=r("BaseIcon"),l=r("BaseButton"),u=r("BaseTable"),N=r("BaseSettingCard");return d(),F(G,null,[i(L),i(N,{title:s.$t("settings.customization.notes.title"),description:s.$t("settings.customization.notes.description")},{action:t(()=>[m(a).hasAbilities(m(v).MANAGE_NOTE)?(d(),p(l,{key:0,variant:"primary-outline",onClick:w},{left:t(f=>[i(e,{class:P(f.class),name:"PlusIcon"},null,8,["class"])]),default:t(()=>[S(" "+D(s.$t("settings.customization.notes.add_note")),1)]),_:1})):k("",!0)]),default:t(()=>[i(u,{ref_key:"table",ref:o,data:y,columns:h.value,class:"mt-14"},{"cell-actions":t(({row:f})=>[i(V,{row:f.data,table:o.value,"load-data":b},null,8,["row","table"])]),_:1},8,["columns"])]),_:1},8,["title","description"])],64)}}};export{R as default};
