1 line
16 KiB
JavaScript
1 line
16 KiB
JavaScript
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[469],{4427:function(e,t,a){Promise.resolve().then(a.bind(a,2406))},2406:function(e,t,a){"use strict";a.r(t),a.d(t,{default:function(){return v}});var s=a(7437),r=a(2265),i=a(4835),n=a(4508),l=a(8755);let d=(0,l.Z)("zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]),c=(0,l.Z)("droplets",[["path",{d:"M7 16.3c2.2 0 4-1.83 4-4.05 0-1.16-.57-2.26-1.71-3.19S7.29 6.75 7 5.3c-.29 1.45-1.14 2.84-2.29 3.76S3 11.1 3 12.25c0 2.22 1.8 4.05 4 4.05z",key:"1ptgy4"}],["path",{d:"M12.56 6.6A10.97 10.97 0 0 0 14 3.02c.5 2.5 2 4.9 4 6.5s3 3.5 3 5.5a6.98 6.98 0 0 1-11.91 4.97",key:"1sl1rz"}]]),o=(0,l.Z)("flame",[["path",{d:"M12 3q1 4 4 6.5t3 5.5a1 1 0 0 1-14 0 5 5 0 0 1 1-3 1 1 0 0 0 5 0c0-2-1.5-3-1.5-5q0-2 2.5-4",key:"1slcih"}]]),u=(0,l.Z)("wifi",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]]);var m=a(9397),x=a(525),h=a(3085);let g=(0,l.Z)("history",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);var f=a(2489);let b=[{id:"electricity",label:"Luz",icon:d,color:"text-yellow-400"},{id:"water",label:"Agua",icon:c,color:"text-blue-400"},{id:"gas",label:"Gas",icon:o,color:"text-orange-400"},{id:"internet",label:"Internet",icon:u,color:"text-cyan-400"}];function p(e){let{isOpen:t,onClose:a}=e,l=(0,i.J)(e=>e.addServiceBill),[d,c]=(0,r.useState)("electricity"),[o,u]=(0,r.useState)(""),[m,x]=(0,r.useState)(""),[h,g]=(0,r.useState)(new Date().toISOString().slice(0,7)),[p,y]=(0,r.useState)(new Date().toISOString().split("T")[0]);if(!t)return null;let v=(e=>{switch(e){case"electricity":return"kW";case"gas":case"water":return"m\xb3";default:return""}})(d),j="internet"!==d;return(0,s.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm p-4 animate-in fade-in duration-200",children:(0,s.jsxs)("div",{className:"w-full max-w-lg rounded-xl bg-slate-900 border border-slate-800 shadow-2xl overflow-hidden scale-100 animate-in zoom-in-95 duration-200",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between p-6 border-b border-slate-800",children:[(0,s.jsx)("h2",{className:"text-xl font-semibold text-white",children:"Registrar Factura de Servicio"}),(0,s.jsx)("button",{onClick:a,className:"text-slate-400 hover:text-white transition-colors",children:(0,s.jsx)(f.Z,{size:20})})]}),(0,s.jsxs)("form",{onSubmit:e=>{e.preventDefault(),o&&(l({type:d,amount:parseFloat(o),usage:m?parseFloat(m):void 0,unit:v||void 0,date:new Date(p).toISOString(),period:h,notes:""}),u(""),x(""),a())},className:"p-6 space-y-5",children:[(0,s.jsx)("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:b.map(e=>{let t=e.icon,a=d===e.id;return(0,s.jsxs)("div",{onClick:()=>c(e.id),className:(0,n.cn)("cursor-pointer p-3 rounded-xl border flex flex-col items-center gap-2 transition-all",a?"border-cyan-500 bg-cyan-500/10 ring-1 ring-cyan-500":"border-slate-800 bg-slate-950 hover:border-slate-700 hover:bg-slate-900"),children:[(0,s.jsx)(t,{className:(0,n.cn)("w-6 h-6",e.color)}),(0,s.jsx)("span",{className:(0,n.cn)("text-xs font-medium",a?"text-white":"text-slate-400"),children:e.label})]},e.id)})}),(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,s.jsxs)("div",{className:(0,n.cn)("space-y-2",!j&&"col-span-2"),children:[(0,s.jsx)("label",{className:"text-xs font-medium text-slate-400 uppercase tracking-wider",children:"Monto"}),(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsx)("span",{className:"absolute left-4 top-1/2 -translate-y-1/2 text-slate-400 font-semibold",children:"$"}),(0,s.jsx)("input",{type:"number",step:"0.01",placeholder:"0.00",value:o,onChange:e=>u(e.target.value),className:"w-full pl-8 pr-4 py-3 bg-slate-950 border border-slate-800 rounded-lg focus:ring-2 focus:ring-cyan-500/50 focus:border-cyan-500 text-white text-lg font-mono outline-none",required:!0,autoFocus:!0})]})]}),j&&(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsxs)("label",{className:"text-xs font-medium text-slate-400 uppercase tracking-wider",children:["Consumo (",v,")"]}),(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsx)("input",{type:"number",step:"0.01",placeholder:"0",value:m,onChange:e=>x(e.target.value),className:"w-full px-4 py-3 bg-slate-950 border border-slate-800 rounded-lg focus:ring-2 focus:ring-cyan-500/50 focus:border-cyan-500 text-white text-lg font-mono outline-none"}),(0,s.jsx)("span",{className:"absolute right-4 top-1/2 -translate-y-1/2 text-slate-500 text-sm font-medium",children:v})]})]})]}),(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)("label",{className:"text-xs font-medium text-slate-400 uppercase tracking-wider",children:"Periodo"}),(0,s.jsx)("input",{type:"month",value:h,onChange:e=>g(e.target.value),className:"w-full px-4 py-2.5 bg-slate-950 border border-slate-800 rounded-lg focus:ring-2 focus:ring-cyan-500/50 focus:border-cyan-500 text-white outline-none [color-scheme:dark]",required:!0})]}),(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)("label",{className:"text-xs font-medium text-slate-400 uppercase tracking-wider",children:"Fecha Pago"}),(0,s.jsx)("input",{type:"date",value:p,onChange:e=>y(e.target.value),className:"w-full px-4 py-2.5 bg-slate-950 border border-slate-800 rounded-lg focus:ring-2 focus:ring-cyan-500/50 focus:border-cyan-500 text-white outline-none [color-scheme:dark]",required:!0})]})]}),(0,s.jsx)("div",{className:"pt-2",children:(0,s.jsx)("button",{type:"submit",className:"w-full py-3 bg-cyan-500 hover:bg-cyan-400 text-white font-semibold rounded-lg shadow-lg shadow-cyan-500/20 transition-all active:scale-[0.98]",children:"Guardar Factura"})})]})]})})}let y=[{id:"electricity",label:"Luz (Electricidad)",icon:d,color:"text-yellow-400",bg:"bg-yellow-400/10"},{id:"water",label:"Agua",icon:c,color:"text-blue-400",bg:"bg-blue-400/10"},{id:"gas",label:"Gas",icon:o,color:"text-orange-400",bg:"bg-orange-400/10"},{id:"internet",label:"Internet",icon:u,color:"text-cyan-400",bg:"bg-cyan-400/10"}];function v(){let e=(0,i.J)(e=>e.serviceBills),[t,a]=(0,r.useState)(!1);return(0,s.jsxs)("div",{className:"space-y-6",children:[(0,s.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("h1",{className:"text-2xl font-bold text-white",children:"Servicios y Predicciones"}),(0,s.jsx)("p",{className:"text-slate-400 text-sm",children:"Gestiona tus consumos de Luz, Agua y Gas."})]}),(0,s.jsxs)("button",{onClick:()=>a(!0),className:"flex items-center gap-2 px-4 py-2 bg-cyan-500 hover:bg-cyan-400 text-white rounded-lg transition shadow-lg shadow-cyan-500/20 font-medium self-start sm:self-auto",children:[(0,s.jsx)(m.Z,{size:18})," Nuevo Pago"]})]}),(0,s.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:y.map(t=>{var a;let r=t.icon,i=function(e,t){let a=e.filter(e=>e.type===t).sort((e,t)=>new Date(t.date).getTime()-new Date(e.date).getTime());if(0===a.length)return 0;let s=a.slice(0,3),r=0,i=0,n=[.5,.3,.2];return s.forEach((e,t)=>{let a=n[t];i+=e.amount*a,r+=a}),i/r}(e,t.id),l=function(e,t){let a=e.filter(e=>e.type===t).sort((e,t)=>new Date(t.date).getTime()-new Date(e.date).getTime());if(a.length<2)return 0;let s=a[0].amount,r=a.slice(1,4);if(0===r.length)return 0;let i=r.reduce((e,t)=>e+t.amount,0)/r.length;return(s-i)/i*100}(e,t.id),d=e.filter(e=>e.type===t.id).sort((e,t)=>new Date(t.date).getTime()-new Date(e.date).getTime())[0];return(0,s.jsxs)("div",{className:"bg-slate-900 border border-slate-800 rounded-xl p-5 space-y-4",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsx)("div",{className:(0,n.cn)("p-2 rounded-lg",t.bg),children:(0,s.jsx)(r,{className:(0,n.cn)("w-6 h-6",t.color)})}),0!==l&&(0,s.jsxs)("div",{className:(0,n.cn)("flex items-center gap-1 text-xs font-medium px-2 py-1 rounded-full",l>0?"bg-red-500/10 text-red-400":"bg-emerald-500/10 text-emerald-400"),children:[l>0?(0,s.jsx)(x.Z,{size:12}):(0,s.jsx)(h.Z,{size:12}),Math.abs(l).toFixed(0),"%"]})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-slate-400 text-sm font-medium",children:t.label}),(0,s.jsxs)("div",{className:"flex items-baseline gap-2",children:[(0,s.jsx)("h3",{className:"text-2xl font-bold text-white mt-1",children:(0,n.xG)(i||(null!==(a=null==d?void 0:d.amount)&&void 0!==a?a:0))}),i>0&&(0,s.jsx)("span",{className:"text-xs text-slate-500 font-mono",children:"(est.)"})]}),(0,s.jsx)("p",{className:"text-xs text-slate-500 mt-1",children:d?"\xdaltimo: ".concat((0,n.xG)(d.amount)):"Sin historial"})]})]},t.id)})}),(0,s.jsxs)("div",{className:"bg-slate-900 border border-slate-800 rounded-xl overflow-hidden",children:[(0,s.jsxs)("div",{className:"p-5 border-b border-slate-800 flex items-center gap-2",children:[(0,s.jsx)(g,{size:18,className:"text-slate-400"}),(0,s.jsx)("h3",{className:"text-lg font-semibold text-white",children:"Historial de Pagos"})]}),(0,s.jsx)("div",{className:"divide-y divide-slate-800",children:0===e.length?(0,s.jsx)("div",{className:"p-8 text-center text-slate-500 text-sm",children:"No hay facturas registradas. Comienza agregando una para ver predicciones."}):e.sort((e,t)=>new Date(t.date).getTime()-new Date(e.date).getTime()).map(e=>{let t=y.find(t=>t.id===e.type),a=(null==t?void 0:t.icon)||d;return(0,s.jsxs)("div",{className:"p-4 flex items-center justify-between hover:bg-slate-800/50 transition-colors",children:[(0,s.jsxs)("div",{className:"flex items-center gap-4",children:[(0,s.jsx)("div",{className:(0,n.cn)("p-2 rounded-lg",(null==t?void 0:t.bg)||"bg-slate-800"),children:(0,s.jsx)(a,{className:(0,n.cn)("w-5 h-5",(null==t?void 0:t.color)||"text-slate-400")})}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-white font-medium capitalize",children:(null==t?void 0:t.label)||e.type}),(0,s.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center gap-1 sm:gap-2",children:[(0,s.jsx)("p",{className:"text-xs text-slate-500 capitalize",children:new Date(e.date).toLocaleDateString("es-AR",{dateStyle:"long"})}),e.usage&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"hidden sm:inline text-slate-700",children:"•"}),(0,s.jsxs)("p",{className:"text-xs text-slate-400",children:["Consumo: ",(0,s.jsxs)("span",{className:"text-slate-300 font-medium",children:[e.usage," ",e.unit]})]})]})]})]})]}),(0,s.jsxs)("div",{className:"text-right",children:[(0,s.jsx)("p",{className:"text-white font-mono font-medium",children:(0,n.xG)(e.amount)}),(0,s.jsxs)("div",{className:"flex flex-col items-end",children:[(0,s.jsx)("p",{className:"text-xs text-slate-500 uppercase",children:e.period}),e.usage&&e.amount&&(0,s.jsxs)("p",{className:"text-[10px] text-cyan-500/80 font-mono",children:[(0,n.xG)(e.amount/e.usage)," / ",e.unit]})]})]})]},e.id)})})]}),(0,s.jsx)(p,{isOpen:t,onClose:()=>a(!1)})]})}},4835:function(e,t,a){"use strict";a.d(t,{J:function(){return m}});var s=a(3011),r=a(6885),i=a(4147);let n=e=>({fixedDebts:[],variableDebts:[],addFixedDebt:t=>e(e=>({fixedDebts:[...e.fixedDebts,{...t,id:(0,i.Z)()}]})),updateFixedDebt:(t,a)=>e(e=>({fixedDebts:e.fixedDebts.map(e=>e.id===t?{...e,...a}:e)})),deleteFixedDebt:t=>e(e=>({fixedDebts:e.fixedDebts.filter(e=>e.id!==t)})),toggleFixedDebtPaid:t=>e(e=>({fixedDebts:e.fixedDebts.map(e=>e.id===t?{...e,isPaid:!e.isPaid}:e)})),addVariableDebt:t=>e(e=>({variableDebts:[...e.variableDebts,{...t,id:(0,i.Z)()}]})),updateVariableDebt:(t,a)=>e(e=>({variableDebts:e.variableDebts.map(e=>e.id===t?{...e,...a}:e)})),deleteVariableDebt:t=>e(e=>({variableDebts:e.variableDebts.filter(e=>e.id!==t)})),toggleVariableDebtPaid:t=>e(e=>({variableDebts:e.variableDebts.map(e=>e.id===t?{...e,isPaid:!e.isPaid}:e)}))}),l=e=>({creditCards:[],cardPayments:[],addCreditCard:t=>e(e=>({creditCards:[...e.creditCards,{...t,id:(0,i.Z)()}]})),updateCreditCard:(t,a)=>e(e=>({creditCards:e.creditCards.map(e=>e.id===t?{...e,...a}:e)})),deleteCreditCard:t=>e(e=>({creditCards:e.creditCards.filter(e=>e.id!==t)})),addCardPayment:t=>e(e=>({cardPayments:[...e.cardPayments,{...t,id:(0,i.Z)()}]})),deleteCardPayment:t=>e(e=>({cardPayments:e.cardPayments.filter(e=>e.id!==t)}))}),d=new Date,c=e=>({monthlyBudgets:[],currentMonth:d.getMonth()+1,currentYear:d.getFullYear(),setMonthlyBudget:t=>e(e=>{let a=e.monthlyBudgets.findIndex(e=>e.month===t.month&&e.year===t.year);if(a>=0){let s=[...e.monthlyBudgets];return s[a]=t,{monthlyBudgets:s}}return{monthlyBudgets:[...e.monthlyBudgets,t]}}),updateMonthlyBudget:(t,a,s)=>e(e=>({monthlyBudgets:e.monthlyBudgets.map(e=>e.month===t&&e.year===a?{...e,...s}:e)}))}),o=e=>({alerts:[],addAlert:t=>e(e=>({alerts:[...e.alerts,{...t,id:(0,i.Z)(),date:new Date().toISOString()}]})),markAlertAsRead:t=>e(e=>({alerts:e.alerts.map(e=>e.id===t?{...e,isRead:!0}:e)})),deleteAlert:t=>e(e=>({alerts:e.alerts.filter(e=>e.id!==t)})),clearAllAlerts:()=>e(()=>({alerts:[]}))}),u=e=>({serviceBills:[],addServiceBill:t=>e(e=>({serviceBills:[...e.serviceBills,{...t,id:(0,i.Z)(),isPaid:!1}]})),deleteServiceBill:t=>e(e=>({serviceBills:e.serviceBills.filter(e=>e.id!==t)})),toggleServiceBillPaid:t=>e(e=>({serviceBills:e.serviceBills.map(e=>e.id===t?{...e,isPaid:!e.isPaid}:e)}))}),m=(0,s.U)()((0,r.tJ)(function(){for(var e=arguments.length,t=Array(e),a=0;a<e;a++)t[a]=arguments[a];return{...n(...t),...l(...t),...c(...t),...o(...t),...u(...t)}},{name:"finanzas-storage"}))},4508:function(e,t,a){"use strict";a.d(t,{Ic:function(){return x},JG:function(){return c},P8:function(){return d},PW:function(){return g},Q0:function(){return m},ZY:function(){return o},cn:function(){return i},iS:function(){return l},tk:function(){return h},w7:function(){return f},xG:function(){return n},zF:function(){return u}});var s=a(1994),r=a(3335);function i(){for(var e=arguments.length,t=Array(e),a=0;a<e;a++)t[a]=arguments[a];return(0,r.m6)((0,s.W)(t))}function n(e){return new Intl.NumberFormat("es-AR",{style:"currency",currency:"ARS",minimumFractionDigits:2,maximumFractionDigits:2}).format(e)}function l(e){let t="string"==typeof e?new Date(e):e;return new Intl.DateTimeFormat("es-AR",{day:"2-digit",month:"2-digit",year:"numeric"}).format(t)}function d(e){let t="string"==typeof e?new Date(e):e,a=new Date,s=new Date(t.getFullYear(),t.getMonth(),t.getDate()),r=new Date(a.getFullYear(),a.getMonth(),a.getDate());return Math.ceil((s.getTime()-r.getTime())/864e5)}function c(e){let t=new Date,a=t.getFullYear(),s=t.getMonth(),r=t.getDate(),i=a,n=s;r>e&&(n+=1)>11&&(n=0,i+=1);let l=new Date(i,n+1,0).getDate();return new Date(i,n,Math.min(e,l))}function o(e){if(e<1||e>12)throw Error("El mes debe estar entre 1 y 12");return["enero","febrero","marzo","abril","mayo","junio","julio","agosto","septiembre","octubre","noviembre","diciembre"][e-1]}function u(e){return e.filter(e=>!e.isPaid).reduce((e,t)=>e+t.amount,0)}function m(e){return e.filter(e=>!e.isPaid).reduce((e,t)=>e+t.amount,0)}function x(e,t){return(t?e.filter(e=>e.cardId===t):e).reduce((e,t)=>e+t.amount,0)}function h(e){return c(e)}function g(e){return c(e)}function f(e,t){return t<=0?0:Math.min(Math.max(e/t*100,0),100)}},9397:function(e,t,a){"use strict";a.d(t,{Z:function(){return s}});let s=(0,a(8755).Z)("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]])},3085:function(e,t,a){"use strict";a.d(t,{Z:function(){return s}});let s=(0,a(8755).Z)("trending-down",[["path",{d:"M16 17h6v-6",key:"t6n2it"}],["path",{d:"m22 17-8.5-8.5-5 5L2 7",key:"x473p"}]])},525:function(e,t,a){"use strict";a.d(t,{Z:function(){return s}});let s=(0,a(8755).Z)("trending-up",[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]])}},function(e){e.O(0,[697,71,971,117,744],function(){return e(e.s=4427)}),_N_E=e.O()}]); |