1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[47661],{24338:(e,t,a)=>{"use strict";a.d(t,{A:()=>i});var r=a(37876),s=a(14232),n=a(48230),l=a.n(n);function i(e){let{data:t,loading:a,currentPage:n,pageSize:i,onPageChange:o,showCustomerColumns:c=!1}=e,[d,m]=(0,s.useState)("transactionDate"),[x,u]=(0,s.useState)("desc"),g=e=>{d===e?u("asc"===x?"desc":"asc"):(m(e),u("asc"))},p=(0,s.useMemo)(()=>[...t].sort((e,t)=>{let a,r;switch(d){case"amount":a=e.amount,r=t.amount;break;case"transactionDate":a=e.transactionDate?new Date(e.transactionDate).getTime():0,r=t.transactionDate?new Date(t.transactionDate).getTime():0;break;case"customerName":a=e.customerName||"",r=t.customerName||"";break;default:a=0,r=0}return"string"==typeof a?"asc"===x?a.localeCompare(r):r.localeCompare(a):"asc"===x?a-r:r-a}),[t,d,x]),h=e=>{let{field:t}=e;return d!==t?(0,r.jsx)("span",{className:"text-gray-400 text-xs",children:"â"}):"asc"===x?(0,r.jsx)("span",{className:"text-blue-600 text-xs",children:"â"}):(0,r.jsx)("span",{className:"text-blue-600 text-xs",children:"â"})};return(0,r.jsxs)("div",{className:"bg-white rounded-lg shadow overflow-hidden",children:[a?(0,r.jsx)("div",{className:"p-6 text-center text-gray-500",children:"Loading revenue data..."}):0===t.length?(0,r.jsx)("div",{className:"p-6 text-center text-gray-500",children:"No revenue data found for this page."}):(0,r.jsx)("div",{className:"overflow-x-auto",children:(0,r.jsxs)("table",{className:"min-w-full divide-y divide-gray-200",children:[(0,r.jsx)("thead",{className:"bg-gray-50",children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-700 uppercase tracking-wider",children:"No"}),c&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-700 uppercase tracking-wider",children:(0,r.jsxs)("button",{onClick:()=>g("customerName"),className:"flex items-center gap-1 hover:text-gray-900",children:["Customer Name",(0,r.jsx)(h,{field:"customerName"})]})}),(0,r.jsx)("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-700 uppercase tracking-wider",children:"Email"})]}),(0,r.jsx)("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-700 uppercase tracking-wider",children:"Source"}),(0,r.jsx)("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-700 uppercase tracking-wider",children:"Source Type"}),(0,r.jsx)("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-700 uppercase tracking-wider",children:"Status"}),(0,r.jsx)("th",{className:"px-6 py-3 text-right text-xs font-medium text-gray-700 uppercase tracking-wider",children:(0,r.jsxs)("button",{onClick:()=>g("amount"),className:"flex items-center justify-end gap-1 hover:text-gray-900 w-full",children:["Amount",(0,r.jsx)(h,{field:"amount"})]})}),(0,r.jsx)("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-700 uppercase tracking-wider",children:"Currency"}),(0,r.jsx)("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-700 uppercase tracking-wider",children:(0,r.jsxs)("button",{onClick:()=>g("transactionDate"),className:"flex items-center gap-1 hover:text-gray-900",children:["Transaction Date",(0,r.jsx)(h,{field:"transactionDate"})]})})]})}),(0,r.jsx)("tbody",{className:"bg-white divide-y divide-gray-200",children:p.map((e,t)=>{var a,s;return(0,r.jsxs)("tr",{className:t%2==0?"bg-white":"bg-gray-50",children:[(0,r.jsx)("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-600",children:(n-1)*i+t+1}),c&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("td",{className:"px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900",children:e.customerId?(0,r.jsx)(l(),{href:"/admin/customers/".concat(e.customerId,"?tab=fees-billing"),className:"text-blue-600 hover:text-blue-800 hover:underline",children:e.customerName}):e.customerName}),(0,r.jsx)("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-600",children:e.customerEmail})]}),(0,r.jsx)("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-600",children:e.source}),(0,r.jsx)("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-600",children:e.sourceType||"â"}),(0,r.jsx)("td",{className:"px-6 py-4 whitespace-nowrap",children:(0,r.jsx)("span",{className:"px-2 py-1 text-xs font-semibold rounded ".concat(function(e){let t=(null==e?void 0:e.toLowerCase())||"";return"completed"===t||"active"===t?"bg-green-100 text-green-800":"pending"===t?"bg-yellow-100 text-yellow-800":"failed"===t?"bg-red-100 text-red-800":"bg-gray-100 text-gray-800"}(e.status||"")),children:e.status||"â"})}),(0,r.jsx)("td",{className:"px-6 py-4 whitespace-nowrap text-sm font-semibold text-gray-900 text-right",children:(a=e.amount,s=e.currency,new Intl.NumberFormat("en-US",{style:"currency",currency:s||"USD",minimumFractionDigits:2,maximumFractionDigits:2}).format(a))}),(0,r.jsx)("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-600",children:e.currency||"USD"}),(0,r.jsx)("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-600",children:function(e){if(!e)return"â";try{return new Date(e).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"})}catch(t){return e}}(e.transactionDate)})]},e.id)})})]})}),!a&&(0,r.jsxs)("div",{className:"bg-white px-6 py-3 flex items-center justify-between border-t border-gray-200",children:[(0,r.jsxs)("div",{className:"text-sm text-gray-500",children:["Page ",n," ⢠Showing ",p.length," items"]}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("button",{onClick:()=>o(Math.max(1,n-1)),disabled:1===n,className:"px-3 py-1 border border-gray-300 rounded text-sm disabled:opacity-50 disabled:cursor-not-allowed hover:bg-gray-50",children:"Previous"}),(0,r.jsxs)("span",{className:"px-3 py-1 text-sm",children:["Page ",n]}),(0,r.jsx)("button",{onClick:()=>o(n+1),disabled:p.length<i,className:"px-3 py-1 border border-gray-300 rounded text-sm disabled:opacity-50 disabled:cursor-not-allowed hover:bg-gray-50",children:"Next"})]})]})]})}},57181:(e,t,a)=>{"use strict";a.r(t),a.d(t,{default:()=>x});var r=a(37876),s=a(77328),n=a.n(s),l=a(14232),i=a(37497);function o(e){let{onMonthChange:t,onClear:a}=e,[s,n]=(0,l.useState)("");return(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("label",{htmlFor:"month-picker",className:"font-medium text-gray-700",children:"Select Month:"}),(0,r.jsx)("input",{id:"month-picker",type:"month",value:s,onChange:e=>{let r=e.target.value;if(n(r),!r)return void a();let{from:s,to:l}
1=function(e){let[t,a]=e.split("-"),r=Number(a)-1,s=new Date(Number(t),r,1),n=new Date(Number(t),r+1,1);return{from:"".concat(s.getFullYear(),"-").concat(String(s.getMonth()+1).padStart(2,"0"),"-01"),to:"".concat(n.getFullYear(),"-").concat(String(n.getMonth()+1).padStart(2,"0"),"-01")}}(r);t(s,l)},className:"px-4 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500"}),s&&(0,r.jsx)("button",{onClick:()=>{n(""),a()},className:"px-3 py-2 text-sm text-gray-600 hover:text-gray-900 hover:bg-gray-100 rounded-md transition-colors",children:"Clear"})]})}var c=a(24338),d=a(53403),m=a(29498);function x(){let[e,t]=(0,l.useState)({}),[a,s]=(0,l.useState)(1),[x,u]=(0,l.useState)(10),[g,p]=(0,l.useState)(!1),[h,y]=(0,l.useState)(null),{data:f,loading:b,error:N,refetch:j}=function(e){let[t,a]=(0,l.useState)({data:[],loading:!1,error:null,totalRevenue:0,transactionCount:0,averageFeeAmount:0}),r=(0,l.useMemo)(()=>{var t,a;return{from:null==e?void 0:e.from,to:null==e?void 0:e.to,pageSize:null!=(t=null==e?void 0:e.pageSize)?t:100,pageNumber:null!=(a=null==e?void 0:e.pageNumber)?a:1}},[null==e?void 0:e.from,null==e?void 0:e.to,null==e?void 0:e.pageSize,null==e?void 0:e.pageNumber]),s="".concat(r.from,"|").concat(r.to,"|").concat(r.pageSize,"|").concat(r.pageNumber),n=(0,l.useCallback)(async()=>{a(e=>({...e,loading:!0,error:null}));try{let e=await d.KD.getAggregatedRevenue(r);if(e.success&&e.data){let t=e.data.items||[],r=t.reduce((e,t)=>e+(t.amount||0),0),s=t.length>0?r/t.length:0;a({data:t,loading:!1,error:null,totalRevenue:r,transactionCount:t.length,averageFeeAmount:s})}else a(t=>({...t,loading:!1,error:e.error||"Failed to fetch revenue data"}))}catch(e){a(t=>({...t,loading:!1,error:e instanceof Error?e.message:"An error occurred"}))}},[r]);return(0,l.useEffect)(()=>{n()},[s]),{...t,refetch:n}}({from:e.from,to:e.to,pageSize:x,pageNumber:a}),w=!!(e.from&&e.to),v=async()=>{if(e.from&&e.to){p(!0),y(null);try{await m.KD.exportAggregatedRevenue({from:e.from,to:e.to})}catch(a){var t;let e=null==a||null==(t=a.response)?void 0:t.data;y(("string"==typeof(null==e?void 0:e.message)?e.message:null)||(a instanceof Error?a.message:"Export failed"))}finally{p(!1)}}};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(n(),{children:[(0,r.jsx)("title",{children:"Fees Management | Vault22 Admin"}),(0,r.jsx)("meta",{name:"description",content:"Unified fees management dashboard"})]}),(0,r.jsx)(i.A,{requireRoles:["Admin","Wealth Manager"],children:(0,r.jsxs)("div",{className:"space-y-6",children:[(0,r.jsxs)("div",{className:"bg-white rounded-lg shadow p-6",children:[(0,r.jsx)("h1",{className:"text-3xl font-bold text-gray-900",children:"Fees Management"}),(0,r.jsx)("p",{className:"text-gray-600 mt-2",children:"Unified view of all fee income across GTN, tier subscriptions, and Vault22 platform fees."})]}),(0,r.jsxs)("div",{className:"bg-white rounded-lg shadow p-6",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[(0,r.jsxs)("div",{className:"flex items-center gap-4",children:[(0,r.jsx)(o,{onMonthChange:(e,a)=>{t({from:e,to:a}),s(1)},onClear:()=>{t({}),s(1)}}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("label",{htmlFor:"page-size",className:"font-medium text-gray-700",children:"Per page:"}),(0,r.jsxs)("select",{id:"page-size",value:x,onChange:e=>{u(Number(e.target.value)),s(1)},className:"px-4 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500",children:[(0,r.jsx)("option",{value:10,children:"10"}),(0,r.jsx)("option",{value:20,children:"20"}),(0,r.jsx)("option",{value:50,children:"50"}),(0,r.jsx)("option",{value:100,children:"100"})]})]})]}),(0,r.jsx)("button",{onClick:j,className:"px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700 transition-colors",children:"Refresh"}),(0,r.jsx)("button",{onClick:v,disabled:!w||g,title:w?g?"Export in progress":void 0:"Select a month to enable export",className:"px-4 py-2 bg-green-600 text-white rounded-md hover:bg-green-700 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:g?"Exportingâ¦":"Export CSV"})]}),h&&(0,r.jsx)("p",{className:"mt-2 text-sm text-red-600",children:h})]}),N&&(0,r.jsxs)("div",{className:"bg-red-50 border border-red-200 rounded-lg p-4",children:[(0,r.jsx)("p",{className:"text-red-700 font-medium",children:"Error loading revenue data"}),(0,r.jsx)("p",{className:"text-red-600 text-sm",children:N})]}),!N&&(0,r.jsx)(c.A,{data:f,loading:b,currentPage:a,pageSize:x,onPageChange:s,showCustomerColumns:!0})]})})]})}},72225:(e,t,a)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/admin/fees-management",function(){return a(57181)}])}},e=>{e.O(0,[37497,90636,46593,38792],()=>e(e.s=72225)),_N_E=e.O()}]);
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.