1import{r as n,aJ as g,aP as v}from"./index-zLT88wvs.js";import{P as j}from"./index-D6T1fpbh.js";import{a as y}from"./ambassador.service-DGjYCoFA.js";import{b as S,u as A,e as w}from"./DashboardRouter.component-CfwN8pQV.js";import{u as z}from"./useResponsiveColumns-DBhtZkAP.js";import"./PlusOutlined-DzQCpQq6.js";import"./PlusOutlined-ByZyTB3m.js";import"./EditOutlined-Da3qutGE.js";import"./index-DloMcKIe.js";const R=()=>{const[l,c]=n.useState(!1),[e,a]=n.useState([]),[s,d]=n.useState({currentPage:1,pageSize:10,total:0}),[u,i]=n.useState({}),o=async(t=1,r=10,b=u)=>{const h=(t-1)*r,x=r,P=w(b);try{c(!0);const m=await y.getAllAmbassadors(x,h,P),C=m?.result?.map(p=>({...p,country_name:p.country?.name,state_name:p.state?.name}));a(C||[]),d({currentPage:t,pageSize:r,total:m.totalCount}),i(b)}catch(m){console.error(m)}finally{c(!1)}};return{loading:l,ambassadors:e,pagination:s,filters:u,getAmbassadors:o,handleSearch:async t=>{o(1,s.pageSize,t)},deleteAmbassador:async t=>{try{await y.deleteAmbassadorById(t.id),S.success(A.deleted),o(s.currentPage,s.pageSize)}catch(r){S.error(`${A.error} ${r.message}`)}}}},_=[{name:"Name",key:"name",filter:"text"},{name:"Country",key:"country_name",filter:"text"},{name:"State/Region",key:"state_name",filter:"text"}];function J(){const{loading:l,ambassadors:c,pagination:e,getAmbassadors:a,handleSearch:s,deleteAmbassador:d}=R(),i={title:"Ambassadors",entity:"ambassador",columns:z(_),actions:[],hasRowSelection:!1,defaultFilter:{},data:c};return n.useEffect(()=>{a(e.currentPage,e.pageSize)},[]),g.jsx("div",{className:"content",children:l?g.jsx(v,{}):g.jsx(j,{props:{...i,onAdd:()=>a(e.currentPage,e.pageSize),onUpdate:()=>a(e.currentPage,e.pageSize),onDelete:d,pagination:e,onPaginationChange:async(o,f)=>{await a(o,f)},onSearch:s}},i.actions.join("-"))})}export{J as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.