PageSourceSearch

https://app.refinal.ai/static/js/92.abd2aef5.chunk.js

js refinal.ai collected 2026-10-05 14:42:10 UTC 16,242 bytes, 2 lines download raw bytes

1"use strict";(self.webpackChunkrevolut_tracker_frontend=self.webpackChunkrevolut_tracker_frontend||[]).push([[92],{8092(e,t,a){a.r(t),a.d(t,{default:()=>T});var r=a(9379),s=a(5043),n=a(3216),d=a(1009),o=a(1327),l=a(6150),i=a(108),c=a(7869),x=a(4240),b=a(7734),h=a(3839),k=a(8643),p=a(2185),m=a(6026),u=a(2291),g=a(163),f=a(877),y=a(4385),j=a(8655),v=a(9725),N=a(579);const w=["week","month","quarter","year"],_={week:{label:"Weekly",badge:"info",history:12},month:{label:"Monthly",badge:"primary",history:12},quarter:{label:"Quarterly",badge:"success",history:8},year:{label:"Yearly",badge:"warning",history:5}},S=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"USD";return new Intl.NumberFormat("en-US",{style:"currency",currency:t,maximumFractionDigits:0,notation:Math.abs(e)>=1e6?"compact":"standard"}).format(e)},E=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"USD";return new Intl.NumberFormat("en-US",{style:"currency",currency:t,maximumFractionDigits:2}).format(e)},L=e=>Math.abs(e)>=1e6?"".concat((e/1e6).toFixed(1),"M"):Math.abs(e)>=1e3?"".concat((e/1e3).toFixed(0),"k"):e.toFixed(0),R=e=>{let{label:t,value:a,sub:r,highlight:s}=e;return(0,N.jsxs)("div",{className:"rounded-lg border p-4 ".concat(s?"border-brand-500/30 bg-brand-500/5 dark:border-brand-500/20":"border-stroke bg-white dark:border-strokedark dark:bg-boxdark"),children:[(0,N.jsx)("p",{className:"text-xs font-semibold uppercase tracking-wider text-body dark:text-bodydark",children:t}),(0,N.jsx)("p",{className:"mt-1.5 text-2xl font-bold ".concat(s?"text-brand-500":"text-black dark:text-white"),children:a}),r&&(0,N.jsx)("p",{className:"mt-0.5 text-xs text-body dark:text-bodydark",children:r})]})},C=e=>{let{active:t,payload:a,label:r,currency:s}=e;return t&&null!==a&&void 0!==a&&a.length?(0,N.jsxs)("div",{className:"rounded-lg border border-stroke bg-white p-3 shadow-lg dark:border-strokedark dark:bg-boxdark text-xs",children:[(0,N.jsx)("p",{className:"mb-1.5 font-semibold text-black dark:text-white",children:r}),a.map(e=>(0,N.jsxs)("div",{className:"flex items-center justify-between gap-6",children:[(0,N.jsxs)("span",{className:"flex items-center gap-1.5 text-body dark:text-bodydark",children:[(0,N.jsx)("span",{className:"inline-block h-2 w-2 rounded-full",style:{background:e.color||e.fill}}),e.name]}),(0,N.jsx)("span",{className:"font-medium text-black dark:text-white",children:E(e.value,s)})]},e.dataKey))]}):null},z=e=>{let{label:t,offset:a,onPrev:r,onNext:s,isLoading:n}=e;return(0,N.jsxs)("div",{className:"flex items-center gap-1",children:[(0,N.jsx)("button",{onClick:r,disabled:n,className:"rounded p-1 text-body hover:bg-gray-2 hover:text-black dark:hover:bg-meta-4 dark:hover:text-white disabled:opacity-40",title:"Previous period",children:(0,N.jsx)(d.irw,{size:18})}),(0,N.jsx)("span",{className:"min-w-[150px] text-center text-sm font-medium text-black dark:text-white",children:n?(0,N.jsx)("span",{className:"text-body dark:text-bodydark",children:"Loading\u2026"}):t}),(0,N.jsx)("button",{onClick:s,disabled:n||a>=0,className:"rounded p-1 text-body hover:bg-gray-2 hover:text-black dark:hover:bg-meta-4 dark:hover:text-white disabled:opacity-40",title:"Next period",children:(0,N.jsx)(d.fOo,{size:18})})]})};function M(e){var t;let{node:a,depth:r,currency:s,collapsed:n,onToggle:o}=e;const l=a.children.length>0,i=n.has(a.tag_id),c=20*r;return(0,N.jsxs)(N.Fragment,{children:[(0,N.jsxs)("tr",{className:"hover:bg-gray-2/50 dark:hover:bg-meta-4/30",children:[(0,N.jsx)("td",{className:"px-4 py-2.5 text-sm border-b border-stroke dark:border-strokedark",children:(0,N.jsxs)("div",{className:"flex items-center gap-1",style:{paddingLeft:c},children:[l?(0,N.jsx)("button",{onClick:()=>o(a.tag_id),className:"flex-shrink-0 rounded p-0.5 text-body hover:text-black dark:hover:text-white",children:i?(0,N.jsx)(d.fOo,{size:13}):(0,N.jsx)(d.fK4,{size:13})}):(0,N.jsx)("span",{className:"w-[18px] flex-shrink-0"}),(0,N.jsx)("span",{className:"font-medium text-black dark:text-white ".concat(0===r?"":"font-normal"),children:a.tag_name}),(0,N.jsx)("span",{className:"ml-1.5 text-xs text-body dark:text-bodydark capitalize",children:null===(t=a.tag_type)||void 0===t?void 0:t.toLowerCase()})]})}),(0,N.jsx)("td",{className:"px-4 py-2.5 text-sm text-success border-b border-stroke dark:border-strokedark",children:a.revenue>0?E(a.revenue,s):"\u2014"}),(0,N.jsx)("td",{className:"px-4 py-2.5 text-sm text-danger border-b border-stroke dark:border-strokedark",children:a.expenses>0?E(a.expenses,s):"\u2014"}),(0,N.jsx)("td",{className:"px-4 py-2.5 text-sm border-b border-stroke dark:border-strokedark ".concat(a.net>
1=0?"text-success":"text-danger"),children:E(a.net,s)}),(0,N.jsx)("td",{className:"px-4 py-2.5 text-sm text-body dark:text-bodydark border-b border-stroke dark:border-strokedark",children:a.transaction_count.toLocaleString()})]}),!i&&a.children.map(e=>(0,N.jsx)(M,{node:e,depth:r+1,currency:s,collapsed:n,onToggle:o},e.tag_id))]})}function F(e){let{breakdown:t,currency:a,periodLabel:n,isPeriodLoading:d}=e;const o=(0,s.useMemo)(()=>function(e){const t={};e.forEach(e=>{t[e.tag_id]=(0,r.A)((0,r.A)({},e),{},{children:[]})});const a=[];return e.forEach(e=>{e.tag_parent_id&&t[e.tag_parent_id]?t[e.tag_parent_id].children.push(t[e.tag_id]):a.push(t[e.tag_id])}),a.forEach(function e(t){t.children.forEach(e),t.children.forEach(e=>{t.revenue+=e.revenue,t.expenses+=e.expenses,t.net+=e.net,t.transaction_count+=e.transaction_count})}),a.sort((e,t)=>Math.abs(t.net)-Math.abs(e.net)),a.forEach(function e(t){t.children.sort((e,t)=>Math.abs(t.net)-Math.abs(e.net)),t.children.forEach(e)}),a}(t),[t]),[l,i]=(0,s.useState)(()=>{const e=new Set;return function t(a,r){a.forEach(a=>{a.children.length&&r>0&&e.add(a.tag_id),t(a.children,r+1)})}(o,0),e}),c=e=>{if(e)i(new Set);else{const t=new Set;function a(e){e.forEach(e=>{e.children.length&&(t.add(e.tag_id),a(e.children))})}a(o),i(t)}},x=e=>i(t=>{const a=new Set(t);return a.has(e)?a.delete(e):a.add(e),a}),b=o.some(e=>e.children.length>0);return(0,N.jsxs)("div",{className:"rounded-lg border border-stroke bg-white dark:border-strokedark dark:bg-boxdark overflow-hidden transition-opacity ".concat(d?"opacity-50":""),children:[(0,N.jsxs)("div",{className:"flex items-center justify-between border-b border-stroke px-4 py-3 dark:border-strokedark",children:[(0,N.jsxs)("h3",{className:"text-sm font-semibold text-black dark:text-white",children:["Tag breakdown \u2014 ",n]}),b&&(0,N.jsxs)("div",{className:"flex items-center gap-3",children:[(0,N.jsx)("button",{onClick:()=>c(!0),className:"text-xs text-brand-500 hover:underline",children:"Expand all"}),(0,N.jsx)("button",{onClick:()=>c(!1),className:"text-xs text-body dark:text-bodydark hover:underline",children:"Collapse all"})]})]}),(0,N.jsx)("div",{className:"overflow-x-auto",children:(0,N.jsxs)("table",{className:"w-full",children:[(0,N.jsx)("thead",{className:"bg-gray-2 dark:bg-meta-4 border-b border-stroke dark:border-strokedark",children:(0,N.jsx)("tr",{children:["Tag","Revenue","Expenses","Net","Transactions"].map(e=>(0,N.jsx)("th",{className:"px-4 py-3 text-left text-xs font-semibold uppercase tracking-wider text-body dark:text-bodydark",children:e},e))})}),(0,N.jsx)("tbody",{children:o.map(e=>(0,N.jsx)(M,{node:e,depth:0,currency:a,collapsed:l,onToggle:x},e.tag_id))})]})})]})}function T(){var e,t,a;const{id:M}=(0,n.g)(),T=(0,n.Zp)(),U=(0,j.dj)(),D=_[M],[K,A]=(0,s.useState)(null),[W,B]=(0,s.use
1State)([]),[O,P]=(0,s.useState)(!0),[G,Q]=(0,s.useState)(!1),[$,q]=(0,s.useState)(0),[I,Z]=(0,s.useState)(!1);(0,s.useEffect)(()=>{if(!w.includes(M))return;let e=!1;return P(!0),q(0),Promise.all([(0,v.U_)(M,0),(0,v.uj)(M,D.history)]).then(t=>{let[a,r]=t;e||(A(a),B(r))}).catch(()=>{e||U.error("Failed to load report")}).finally(()=>{e||P(!1)}),()=>{e=!0}},[M]);const Y=(0,s.useCallback)(async()=>{Z(!0);try{await(0,v.Ts)(M,$);const e=await(0,v.U_)(M,$);A(e),U.success("Snapshot regenerated")}catch(e){U.error("Failed to regenerate snapshot")}finally{Z(!1)}},[M,$,U]),H=(0,s.useCallback)(async e=>{Q(!0),q(e);try{const t=await(0,v.U_)(M,e);A(t)}catch(t){U.error("Could not load period data")}finally{Q(!1)}},[M,U]),J=(null===K||void 0===K?void 0:K.currency)||"USD",V=(0,s.useMemo)(()=>{var e;return null!==K&&void 0!==K&&null!==(e=K.tag_breakdown)&&void 0!==e&&e.length?K.tag_breakdown.slice(0,10).map(e=>({name:e.tag_name.length>14?e.tag_name.slice(0,13)+"\u2026":e.tag_name,Revenue:e.revenue,Expenses:e.expenses})):[]},[K]),X=K?[{name:"Revenue",value:K.revenue,fill:"#22c55e"},{name:"Expenses",value:Math.abs(K.expenses),fill:"#ef4444"}].filter(e=>e.value>0):[],ee=(null===K||void 0===K?void 0:K.revenue)>0?Math.round(K.net/K.revenue*100):null,te=(0,s.useMemo)(()=>W.map(e=>{let t=e.period_label;if(/^\w+ \d{4}$/.test(e.period_label)){const[a,r]=e.period_label.split(" ");t="".concat(a.slice(0,3)," '").concat(r.slice(2))}else if(/^Q\d \d{4}$/.test(e.period_label)){const[a,r]=e.period_label.split(" ");t="".concat(a," '").concat(r.slice(2))}else e.period_label.startsWith("Week of ")&&(t=e.period_label.replace("Week of ","").slice(0,6));return(0,r.A)((0,r.A)({},e),{},{shortLabel:t})}),[W]);return w.includes(M)?O?(0,N.jsx)("div",{className:"flex items-center justify-center py-20",children:(0,N.jsx)(y.y$,{size:"lg"})}):K?(0,N.jsxs)("div",{className:"space-y-6",children:[(0,N.jsxs)("button",{onClick:()=>T("/reports"),className:"flex items-center gap-1.5 text-sm text-body hover:text-black dark:text-bodydark dark:hover:text-white",children:[(0,N.jsx)(d.kRp,{size:15}),"Back to Reports"]}),(0,N.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[(0,N.jsxs)("div",{className:"flex items-center gap-3",children:[(0,N.jsxs)("h1",{className:"text-2xl font-bold text-black dark:text-white",children:[D.label," Report"]}),(0,N.jsx)(y.Ex,{variant:D.badge,children:D.label})]}),(0,N.jsxs)("div",{className:"flex items-center gap-2",children:[(0,N.jsx)(z,{label:null!==(e=null===K||void 0===K?void 0:K.period_label)&&void 0!==e?e:"",offset:$,onPrev:()=>H($-1),onNext:()=>H($+1),isLoading:G}),(0,N.jsxs)("button",{onClick:Y,disabled:I||G,title:"Regenerate snapshot",className:"flex items-center gap-1.5 rounded px-2.5 py-1.5 text-xs font-medium text-body hover:bg-gray-2 hover:text-black dark:text-bodydark dark:hover:bg-meta-4 dark:hover:text-white disabled:opacity-40",children:[(0,N.jsx)(d.jTZ,{size:13,className:I?"animate-spin":""}),"Regenerate"]})]})]}),(0,N.jsxs)("div",{className:"grid grid-cols-2 gap-4 sm:grid-cols-4 transition-opacity ".concat(G?"opacity-50":""),children:[(0,N.jsx)(R,{label:"Revenue",value:S(K.revenue,J)}),(0,N.jsx)(R,{label:"Expenses",value:S(Math.abs(K.expenses),J)}),(0,N.jsx)(R,{label:"Net",value:S(K.net,J),sub:null!==ee?"".concat(ee,"% margin"):null,highlight:!0}),(0,N.jsx)(R,{label:"Transactions",value:K.transaction_count.toLocaleString()})]}),te.length>1&&(0,N.jsxs)("div",{className:"rounded-lg border border-stroke bg-white dark:border-strokedark dark:bg-boxdark p-5",children:[(0,N.jsx)("h3",{className:"mb-4 text-sm font-semibold text-black dark:text-white",children:"Revenue & expenses over time"}),(0,N.jsx)(i.u,{width:"100%",height:220,children:(0,N.jsxs)(f.Q,{data:te,margin:{top:4,right:8,left:0,bottom:0},children:[(0,N.jsxs)("defs",{children:[(0,N.jsxs)("linearGradient",{id:"gradRevenue",x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,N.jsx)("stop",{offset:"5%",stopColor:"#22c55e",stopOpacity:.15}),(0,N.jsx)("stop",{offset:"95%",stopColor:"#22c55e",stopOpacity:0})]}),(0,N.jsxs)("linearGradient",{id:"gradExpenses",x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,N.jsx)("stop",{offset:"5%",
1stopColor:"#ef4444",stopOpacity:.15}),(0,N.jsx)("stop",{offset:"95%",stopColor:"#ef4444",stopOpacity:0})]})]}),(0,N.jsx)(b.d,{strokeDasharray:"3 3",stroke:"#e5e7eb",vertical:!1}),(0,N.jsx)(p.W,{dataKey:"shortLabel",tick:{fontSize:10,fill:"#8f8f8f"},axisLine:!1,tickLine:!1}),(0,N.jsx)(m.h,{tick:{fontSize:10,fill:"#8f8f8f"},axisLine:!1,tickLine:!1,tickFormatter:L,width:44}),(0,N.jsx)(l.m,{content:(0,N.jsx)(C,{currency:J})}),(0,N.jsx)(h.G,{type:"monotone",dataKey:"revenue",name:"Revenue",stroke:"#22c55e",strokeWidth:2,fill:"url(#gradRevenue)",dot:!1,activeDot:{r:4}}),(0,N.jsx)(h.G,{type:"monotone",dataKey:"expenses",name:"Expenses",stroke:"#ef4444",strokeWidth:2,fill:"url(#gradExpenses)",dot:!1,activeDot:{r:4}})]})})]}),(V.length>0||X.length>0)&&(0,N.jsxs)("div",{className:"grid grid-cols-1 gap-4 lg:grid-cols-3 transition-opacity ".concat(G?"opacity-50":""),children:[V.length>0&&(0,N.jsxs)("div",{className:"lg:col-span-2 rounded-lg border border-stroke bg-white dark:border-strokedark dark:bg-boxdark p-5",children:[(0,N.jsxs)("h3",{className:"mb-4 text-sm font-semibold text-black dark:text-white",children:["By tag \u2014 ",K.period_label]}),(0,N.jsx)(i.u,{width:"100%",height:240,children:(0,N.jsxs)(u.E,{data:V,margin:{top:4,right:8,left:0,bottom:0},barGap:2,children:[(0,N.jsx)(b.d,{strokeDasharray:"3 3",stroke:"#e5e7eb",vertical:!1}),(0,N.jsx)(p.W,{dataKey:"name",tick:{fontSize:10,fill:"#8f8f8f"},axisLine:!1,tickLine:!1}),(0,N.jsx)(m.h,{tick:{fontSize:10,fill:"#8f8f8f"},axisLine:!1,tickLine:!1,tickFormatter:e=>e>=1e3?"".concat((e/1e3).toFixed(0),"k"):e,width:38}),(0,N.jsx)(l.m,{content:(0,N.jsx)(C,{currency:J})}),(0,N.jsx)(k.y,{dataKey:"Revenue",name:"Revenue",fill:"#22c55e",radius:[3,3,0,0],maxBarSize:20}),(0,N.jsx)(k.y,{dataKey:"Expenses",name:"Expenses",fill:"#ef4444",radiu
1s:[3,3,0,0],maxBarSize:20})]})})]}),X.length>0&&(0,N.jsxs)("div",{className:"rounded-lg border border-stroke bg-white dark:border-strokedark dark:bg-boxdark p-5",children:[(0,N.jsx)("h3",{className:"mb-1 text-sm font-semibold text-black dark:text-white",children:"Revenue vs Expenses"}),(0,N.jsx)("p",{className:"mb-2 text-xs text-body dark:text-bodydark",children:K.period_label}),(0,N.jsx)("div",{className:"h-[220px]",children:(0,N.jsx)(i.u,{width:"100%",height:"100%",children:(0,N.jsxs)(g.r,{children:[(0,N.jsx)(x.F,{data:X,cx:"50%",cy:"50%",innerRadius:"52%",outerRadius:"72%",dataKey:"value",paddingAngle:3,children:X.map(e=>(0,N.jsx)(c.f,{fill:e.fill},e.name))}),(0,N.jsx)(l.m,{formatter:e=>E(e,J),contentStyle:{fontSize:11,borderRadius:6,border:"1px solid #e2e8f0"}}),(0,N.jsx)(o.s,{iconType:"circle",iconSize:9,formatter:e=>(0,N.jsx)("span",{className:"text-xs text-body dark:text-bodydark",children:e})})]})})})]})]}),(null===(t=K.tag_breakdown)||void 0===t?void 0:t.length)>0&&(0,N.jsx)(F,{breakdown:K.tag_breakdown,currency:J,periodLabel:K.period_label,isPeriodLoading:G}),!(null!==(a=K.tag_breakdown)&&void 0!==a&&a.length)&&(0,N.jsx)("div",{className:"rounded-lg border border-stroke bg-white p-8 text-center dark:border-strokedark dark:bg-boxdark",children:(0,N.jsxs)("p",{className:"text-sm text-body dark:text-bodydark",children:["No tagged transactions for ",K.period_label,". Tag your transactions to see the breakdown."]})})]}):(0,N.jsxs)("div",{className:"flex flex-col items-center justify-center py-20 text-center",children:[(0,N.jsx)("p",{className:"text-base font-medium text-black dark:text-white",children:"No data available"}),(0,N.jsx)("button",{onClick:()=>T("/reports"),className:"mt-4 text-sm text-brand-500 hover:underline",children:"Back to Reports"})]}):(0,N.jsxs)("div",{className:"flex flex-col items-center justify-center py-20 text-center",children:[(0,N.jsx)("p",{className:"text-base font-medium text-black dark:text-white",children:"Unknown period type"}),(0,N.jsx)("button",{onClick:()=>T("/reports"),className:"mt-4 text-sm text-brand-500 hover:underline",children:"Back to Reports"})]})}},9725(e,t,a){a.d(t,{Ts:()=>d,U_:()=>s,uj:()=>n});var r=a(9983);const s=async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return(await r.A.get("/reports/period/".concat(e,"/data"),{params:0!==t?{offset:t}:void 0})).data},n=async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:12;return(await r.A.get("/reports/period/".concat(e,"/history"),{params:{num_periods:t}})).data},d=async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return(await r.A.post("/reports/period/".concat(e,"/snapshot"),null,{params:0!==t?{offset:t}:void 0})).data}}}]);
2//# sourceMappingURL=92.abd2aef5.chunk.js.map

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.