1import{r as l,fn as y,b3 as S,y as v,p as t,L as x,T as g,bs as F}from"./index-C9IH3k-2.js";import{u as k,G as L,i as C,L as D}from"./MainApp-BoiAvjMg.js";import{g as $}from"./AuditConstant-C6syQHOu.js";import{B as _}from"./HelperMethods-C-ewwU_x.js";import{W as R}from"./WalletPointsFilter-D06q_Gh8.js";import{F as G}from"./Table-isZ0WXp4.js";import{T as n}from"./TemplateUtil-D1DzmWLm.js";import"./Wrapper-ChjuDa3w.js";import"./index-CmSVNJzc.js";import"./index-Bv3SRNsl.js";import"./CalendarOutlined-DyzsKNdO.js";import"./ClockCircleOutlined-Cym7vptW.js";import"./index-BOwvFOZJ.js";import"./Pagination-D1z-xPUv.js";import"./HolderOutlined-YOHjCGKZ.js";const{Text:d}=g,f=["waWalletBalance","aiWalletBalance","daysToExpiry"],z=[{text:"Active",value:"true"},{text:"Inactive",value:"false"}],M=s=>t.jsx(n,{color:s?"green":"red",children:s?"Active":"Inactive"}),le=()=>{const[s,T]=l.useState(y),[p,b]=l.useState([]),[I,m]=l.useState(!1),A=l.useRef(null),P=S(),w=k(p.map(e=>e.planSlug)),N=e=>C(w[e.planSlug]);l.useEffect(()=>{h(y)},[]);const h=async e=>{m(!0);try{const a=await v("/api/v1/reseller/wallet-plan-summary",e);a&&a.status===200&&(b(a.data.results||[]),T({...e,pagination:{...e.pagination,total:a.data.total}}))}catch(a){console.error("Failed to fetch reseller wallet/plan summary:",a),P.error({message:"Failed to load phone numbers",description:"Could not fetch the wallet & plan summary. Please try again."})}finally{m(!1)}},W=(e,a,i)=>{const c=Object.entries(a??{}).filter(([r])=>!f.includes(r)).map(([r,B])=>
1({fieldName:r,value:B})).filter(r=>r.value?.length);c.push(..._(a,f));const j=i?.order?[{fieldName:i.columnKey,dir:i.order==="descend"?"desc":"asc"}]:[];h({pagination:{current:e?.current??1,pageSize:e?.pageSize??F},search:c,order:j})},o=(e,a)=>({...$(e,a,A,(i,c)=>c()),onFilter:void 0}),u={filterDropdown:e=>t.jsx(R,{...e})},E=[{title:"Phone Number",dataIndex:"displayPhoneNumber",key:"displayPhoneNumber",...o("displayPhoneNumber","Phone Number"),render:e=>e?t.jsx(d,{copyable:!0,children:e}):"-"},{title:"Customer",dataIndex:"username",key:"username",...o("username","Username"),render:(e,a)=>t.jsxs(x,{vertical:!0,children:[t.jsx(d,{strong:!0,children:a.username||"-"}),a.email?t.jsx(d,{type:"secondary",children:a.email}):null]})},{title:"WA Wallet",dataIndex:"waWalletBalance",key:"waWalletBalance",sorter:!0,...u,render:(e,a)=>e==null?"-":t.jsx(n,{color:L(Number(e)),children:`${e} ${a.currency||""}`})},{title:"AI Wallet",dataIndex:"aiWalletBalance",key:"aiWalletBalance",sorter:!0,...u,render:(e,a)=>e==null?"-":t.jsx(n,{color:"blue",children:`${e} ${a.currency||""}`})},{title:"Plan",dataIndex:"planName",key:"planName",...o("planName","Plan Name"),render:e=>e||"-"},{title:"WABA Id",dataIndex:"whatsappBusinessAccountId",key:"whatsappBusinessAccountId",...o("whatsappBusinessAccountId","WABA Id"),render:e=>e?t.jsx(d,{copyable:!0,children:e}):"-"},{title:"Days To Expiry",dataIndex:"daysToExpiry",key:"daysToExpiry",sorter:!0,...u,render:(e,a)=>N(a)?t.jsx(n,{color:"green",children:D}):e==null?"-":t.jsx(n,{color:e<0?"red":e<=7?"orange":"green",children:`${e} days`})},{title:"WABA Active",dataIndex:"wabaActive",key:"wabaActive",filters:z,filterMultiple:!1,render:M}];return t.jsxs(x,{vertical:!0,gap:"large",children:[t.jsx(g.Title,{level:4,style:{margin:0},children:"Phone Numbers â Wallet & Plan Summary"}),t.jsx(G,{rowKey:e=>e.phoneNumberId,columns:E,dataSource:p,onChange:W,loading:I,pagination:{...s.pagination,showSizeChanger:!0,showTotal:(e,a)=>`${a[0]} - ${a[1]} of ${e} records`},scroll:{x:"max-content"}})]})};export{le 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.