PageSourceSearch

https://app.zumma.ai/assets/BudgetsDashboardPage-BTIUPgUm.js

js zumma.ai collected 2026-10-05 13:23:42 UTC 10,359 bytes, 3 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/UpdateBudgetModal-BboBbu5F.js","assets/chakra-vendor-BG7fa7aC.js","assets/react-vendor-DCR6dG3j.js","assets/index-IwqWA-LW.js","assets/ui-vendor-DKBTneaj.js","assets/redux-vendor-I8Hjtlmz.js","assets/query-vendor-C3PAO0Y9.js","assets/date-vendor-De8bstCQ.js","assets/index-CRqRm7Fj.css","assets/forms-vendor-BvaLZRHC.js","assets/Tags-BaPFtdxl.js","assets/PageLayout-afSuZqex.js","assets/Title-UupNOzFg.js","assets/DownloadExpensesModal-D68EZz-N.js","assets/User-DlaCX0EM.js","assets/values-Cc2GHmxn.js","assets/TagGroups-B9_tW4mo.js","assets/useExpenseFilterOptions-CLk11xeC.js","assets/invoices-BirLTNj1.js","assets/business-BuCGELZ1.js","assets/DateRangePicker-Wl9iAbzO.js","assets/SwitchField-CyK15dY5.js","assets/phoneCountries-D8VM3Pq5.js","assets/phoneCountries-BiEHmSmm.css","assets/NoProductScreen-B7Zz5mII.js","assets/CreateBudgetModal-DT36iHkP.js"])))=>i.map(i=>d[i]);
2import{j as e,E as y,F as g,P as K,q as D,S as Q,a as Y,C as T,al as J,am as X,an as Z,ao as v,ap as ee,a1 as z,aM as te,t as se,aN as ae,w as re,y as ne,z as oe,ad as L,ay as de,az as ie,aA as le,aB as A}from"./chakra-vendor-BG7fa7aC.js";import{R as o,r as M}from"./react-vendor-DCR6dG3j.js";import{P as k}from"./PageLayout-afSuZqex.js";import{T as ce,S as w}from"./Title-UupNOzFg.js";import{R as ue,aI as S,bl as ge,bm as pe,bn as me,bo as q,bp as he,bq as H,x as V,k as G,b as h,aQ as b,t as j,K as xe,W as fe,br as F,an as $,bs as je,bt as be,G as E,_ as U,bu as ye,u as N,bv as Se,bw as Be,a_ as Ce,bx as _e}from"./index-IwqWA-LW.js";import{T as De}from"./Tags-BaPFtdxl.js";import{DownloadExpensesModal as Oe}from"./DownloadExpensesModal-D68EZz-N.js";import{N as Me}from"./NoProductScreen-B7Zz5mII.js";import{h as W}from"./date-vendor-De8bstCQ.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},s=new t.Error().stack;s&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[s]="1aaf52f0-c75f-4240-ab0f-b001ddbf716b",t._sentryDebugIdIdentifier="sentry-dbid-1aaf52f0-c75f-4240-ab0f-b001ddbf716b")}catch{}})();const P=t=>({requestHandler:ue(t),async getBudgets(s=!0){var n;try{const a=new URLSearchParams;a.append("active_only",s.toString());const r=await this.requestHandler.get(`budgets?${a.toString()}`);return(n=r==null?void 0:r.data)!=null&&n.data?(S.dispatch(H(r.data.data)),r.data.data):[]}catch(a){return console.error(a),S.dispatch(H([])),[]}},async getBudgetOverview(s,n){try{const a=new URLSearchParams;a.append("start_date",q(s)),a.append("end_date",q(n));const r=await this.requestHandler.get(`budgets/overview?${a.toString()}`);return r!=null&&r.data?(S.dispatch(he(r.data)),r.data):null}catch(a){return console.error(a),null}},async createBudget(s){const a=(await this.requestHandler.post("budgets",s)).data;return S.dispatch(me(a)),a},async updateBudget(s,n){const r=(await this.requestHandler.patch(`budgets/${s}`,n)).data;return S.dispatch(pe(r)),r},async deleteBudget(s){const n=await this.requestHandler.delete(`budgets/${s}`);return S.dispatch(ge(s)),n.data}}),Re=o.memo(({data:t,isLoading:s})=>{var m;const{budget:n,spent:a,prorated_amount:r}=t,d=r>0?Math.min(a/r*100,100):0,i=a>r,c=i?"red":d>80?"orange":"green";return e.jsx(y,{isLoaded:!s,children:e.jsx(V,{children:e.jsx(G,{children:e.jsxs(g,{flexDir:"column",gap:"0.5rem",children:[e.jsxs(g,{justifyContent:"space-between",alignItems:"center",children:[e.jsx(h,{fontWeight:600,fontSize:"1rem",children:((m=n.tag)==null?void 0:m.name)||"Sin etiqueta"}),e.jsxs(h,{fontSize:"0.85rem",color:j.text[3],children:[b(a)," / ",b(r)]})]}),e.jsx(K,{value:d,size:"sm",borderRadius:"full",colorScheme:c}),e.jsxs(g,{justifyContent:"space-between",alignItems:"center",children:[e.jsxs(h,{fontSize:"0.8rem",color:j.text[3],children:[d.toFixed(0),"% usado"]}),e.jsx(h,{fontSize:"0.8rem",color:i?j.error[1]:j.text[3],fontWeight:i?600:400,children:i?`Excedido por ${b(a-r)}`:`Restante: ${b(r-a)}`})]})]})})})})}),R=o.memo(({title:t,body:s,isLoading:n})=>e.jsx(y,{isLoaded:!n,children:e.jsx(V,{children:e.jsxs(G,{children:[e.jsx(h,{fontSize:"0.85rem",color:j.text[3],children:t}),e.jsx(h,{fontSize:{base:"1.4rem",md:"1.6rem",xl:"1.8rem"},fontWeight:600,children:s})]})})})),Te=({overview:t,isLoading:s,dateValue:n,onDateChange:a})=>{const r=o.useMemo(()=>{var i;if(!(t!=null&&t.budgets))return[];const d=new Map;for(const c of t.budgets){const m=((i=c.budget.tag)==null?void 0:i.name)||"Sin etiqueta",u=d.get(m);u?(u.spent+=c.spent,u.prorated_amount+=c.prorated_amount):d.set(m,{budget:{...c.budget},spent:c.spent,prorated_amount:c.prorated_amount})}return Array.from(d.values())},[t]);return e.jsxs(D,{spacing:"1rem",children:[e.jsx(xe,{label:"Filtrar por fecha",value:n,onChange:a,maxDate:null}),e.jsxs(Q,{columns:{base:1,md:3},gap:"1rem",children:[e.jsx(R,{title:"Total Presupuestado",body:b((t==null?void 0:t.total_budgeted)||0),isLoading:s}),e.jsx(R,{title:"Total Gastado",body:b((t==null?void 0:t.total_spent)||0),isLoading:s}),e.jsx(R,{title:"Restante",body:b((t==null?void 0:t.remaining)||0),isLoading:s})]}),e.jsx(Y,{maxH:"500px",overflowY:"auto",children:e.jsx(D,{spacing:"0.75rem",children:s?e.jsxs(e.Fragment,{children:[e.jsx(y,{height:"80px",borderRadius:"md"}),e.jsx(y,{height:"80px",borderRadius:"md"}),e.jsx(y,{height:"80px",borderRadius:"md"})]}):r.length>0?r.map(d=>{var i;return e.jsx(Re,{data:d},((i=d.budget.tag)==null?void 0:i.name)||"sin-etiqueta")}):e.jsx(g,{justifyContent:"center",py:"3rem",children:e.jsx(h,{color:j.text[3],children:"No hay presupuestos para este periodo"})})})})]})},Ee=M.lazy(()=>U(()=>import("./UpdateBudgetModal-BboBbu5F.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24])).then(t=>({default:t.UpdateBudgetModal}))),Pe=({budgets:t,isLoading:s,onSuccess:n})=>{const[a,r]=o.useState(null),[d,i]=o.useState(null),c=o.useRef(null),m=fe(
2),u=T(),p=T(),O=o.useMemo(()=>{var l;const x=new Map;for(const f of t){const _=((l=f.tag)==null?void 0:l.name)||"Sin etiqueta",I=x.get(_)||[];I.push(f),x.set(_,I)}return x},[t]),B=async()=>{if(d!==null)try{await P({useLoader:!1}).deleteBudget(d),m.success("Presupuesto eliminado"),n()}catch{m.error("Error al eliminar presupuesto")}finally{i(null),p.onClose()}},C=()=>{n(),u.onClose()};return e.jsxs(e.Fragment,{children:[e.jsx(D,{spacing:"1rem",children:s?e.jsxs(D,{spacing:"0.75rem",children:[e.jsx(y,{height:"60px",borderRadius:"md"}),e.jsx(y,{height:"60px",borderRadius:"md"}),e.jsx(y,{height:"60px",borderRadius:"md"})]}):O.size>0?e.jsx(J,{allowMultiple:!0,children:Array.from(O.entries()).map(([x,l])=>e.jsxs(X,{children:[e.jsxs(Z,{py:"0.75rem",children:[e.jsx(g,{flex:"1",alignItems:"center",justifyContent:"space-between",mr:"0.5rem",children:e.jsxs(g,{flexDir:"column",gap:"0.15rem",alignItems:"flex-start",children:[e.jsx(h,{fontWeight:600,fontSize:"1rem",children:x}),e.jsxs(h,{fontSize:"0.8rem",color:j.text[3],children:[l.length," ",l.length===1?"presupuesto":"presupuestos"]})]})}),e.jsx(v,{})]}),e.jsx(ee,{pb:"1rem",children:e.jsx(D,{spacing:"0.5rem",children:l.map(f=>{var _;return e.jsxs(g,{alignItems:"center",justifyContent:"space-between",p:"0.5rem 0.75rem",borderRadius:"md",bg:(_=j.neutro)==null?void 0:_[1],children:[e.jsxs(g,{gap:"0.75rem",alignItems:"center",children:[e.jsx(z,{size:"sm",children:b(f.max_amount)}),e.jsxs(z,{size:"sm",children:[F(f.start_date)," - ",F(f.end_date)]})]}),e.jsxs(g,{gap:"0.5rem",children:[e.jsx($,{"aria-label":"Editar",icon:e.jsx(je,{}),variant:"tertiary",onClick:()=>{r(f),u.onOpen()}}),e.jsx($,{"aria-label":"Eliminar",icon:e.jsx(be,{}),variant:"deny",onClick:()=>{i(f.id),p.onOpen()}})]})]},f.id)})})})]},x))}):e.jsx(g,{justifyContent:"center",py:"3rem",children:e.jsx(h,{color:j.text[3],children:"No hay presupuestos creados"})})}),e.jsx(M.Suspense,{fallback:null,children:u.isOpen&&e.jsx(Ee,{isOpen:u.isOpen,onClose:u.onClose,onSuccess:C,budget:a})}),e.jsx(te,{isOpen:p.isOpen,leastDestructiveRef:c,onClose:p.onClose,children:e.jsx(se,{children:e.jsxs(ae,{children:[e.jsx(re,{fontSize:"lg",fontWeight:"bold",children:"Eliminar Presupuesto"}),e.jsx(ne,{children:"¿Estás seguro de que deseas eliminar este presupuesto?"}),e.jsxs(oe,{children:[e.jsx(E,{ref:c,onClick:p.onClose,variant:"tertiary",children:"Cancelar"}),e.jsx(E,{variant:"deny",onClick:B,ml:3,children:"Eliminar"})]})]})})})]})},Ie=M.lazy(()=>U(()=>import("./CreateBudgetModal-DT36iHkP.js"),__vite__mapDeps([25,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24])).then(t=>({default:t.CreateBudgetModal}))),ze=o.memo(({onSuccess:t,isDisabled:s})=>{const{isOpen:n,onOpen:a,onClose:r}=T();return e.jsxs(e.Fragment,{children:[e.jsx(E,{variant:"tertiary",onClick:a,isDisabled:s,children:e.jsxs(g,{alignItems:"center",gap:"0.3rem",children:[e.jsx(ye,{}),"Crear Presupuesto"]})}),e.jsx(M.Suspense,{fallback:null,children:n&&e.jsx(Ie,{isOpen:n,onClose:r,onSuccess:t})})]})}),Le=()=>{const t=N(Se),s=N(Be),[n,a]=L(!0),[r,d]=o.useState(null),[i,c]=o.useState([]),[m,u]=L(!0),[p,O]=o.useState([W().startOf("month").toDate(),W().endOf("month").toDate()]),B=o.useCallback(async()=>{if(Ce(p)){a.on();try{const l=await P({useLoader:!1}).getBudgetOverview(p[0],p[1]);d(l)}catch(l){console.error(l)}finally{a.off()}}},[p,a]),C=o.useCallback(async()=>{u.on();try{const l=await P({useLoader:!1}).getBudgets(!0);c(l)}catch(l){console.error(l)}finally{u.off()}},[u]);o.useEffect(()=>{s&&De({useLoader:!1}).getTags()},[s]),o.useEffect(()=>{s&&B()},[s,B]),o.useEffect(()=>{s&&C()},[s,C]);const x=()=>{B(),C()};return t?e.jsxs(k,{children:[e.jsxs(g,{justifyContent:"space-between",alignItems:"center",children:[e.jsx(ce,{children:"Presupuestos"}),e.jsxs(g,{gap:"0.5rem",children:[e.jsx(Oe,{mode:"budgets",isDisabled:!s}),e.jsx(ze,{onSuccess:x,isDisabled:!s})]})]}),s?e.jsxs(de,{isLazy:!0,mt:"1rem",children:[e.jsxs(ie,{children:[e.jsx(w,{children:"Overview"}),e.jsx(w,{children:"Administrar"})]}),e.jsxs(le,{children:[e.jsx(A,{px:0,children:e.jsx(Te,{overview:r,isLoading:n,dateValue:p,onDateChange:O})}),e.jsx(A,{px:0,children:e.jsx(Pe,{budgets:i,isLoading:m,onSuccess:x})})]})]}):e.jsx(Me,{icon:_e,title:"Presupuestos"})]}):e.jsx(k,{})},Ve=Object.freeze(Object.defineProperty({__proto__:null,BudgetsDashboardPage:Le},Symbol.toStringTag,{value:"Module"}));
2export{P as B,Ve as a};
3//# sourceMappingURL=BudgetsDashboardPage-BTIUPgUm.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.