Files
finanzas/dist/_next/static/chunks/app/login/page-6be400e8521677b4.js

1 line
5.2 KiB
JavaScript

(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[626],{225:function(e,t,r){Promise.resolve().then(r.bind(r,6374))},6374:function(e,t,r){"use strict";r.r(t),r.d(t,{default:function(){return c}});var n=r(7437),a=r(2265),s=r(9376),i=r(6337),l=r(1817),o=r(4743);function c(){let[e,t]=(0,a.useState)("initial"),[r,c]=(0,a.useState)(""),[d,u]=(0,a.useState)(!1),[h,f]=(0,a.useState)(""),m=(0,s.useRouter)(),x=async()=>{u(!0),f("");try{let e=await fetch("/api/auth/send",{method:"POST"}),r=await e.json();if(!e.ok)throw Error(r.error||"Failed to send code");t("verify")}catch(e){f(e.message)}finally{u(!1)}},g=async()=>{u(!0),f("");try{let e=await fetch("/api/auth/verify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:r})}),t=await e.json();if(!e.ok)throw Error(t.error||"Invalid code");m.push("/"),m.refresh()}catch(e){f(e.message)}finally{u(!1)}};return(0,n.jsx)("div",{className:"flex min-h-screen items-center justify-center bg-gray-900 text-white p-4",children:(0,n.jsxs)("div",{className:"w-full max-w-md bg-gray-800 rounded-lg shadow-xl p-8 border border-gray-700",children:[(0,n.jsxs)("div",{className:"flex flex-col items-center mb-8",children:[(0,n.jsx)("div",{className:"bg-blue-600 p-3 rounded-full mb-4",children:(0,n.jsx)(i.Z,{className:"w-8 h-8 text-white"})}),(0,n.jsx)("h1",{className:"text-2xl font-bold",children:"Secure Access"}),(0,n.jsx)("p",{className:"text-gray-400 mt-2 text-center",children:"Finanzas Personales"})]}),h&&(0,n.jsx)("div",{className:"bg-red-900/50 border border-red-500 text-red-200 p-3 rounded mb-4 text-sm",children:h}),"initial"===e?(0,n.jsxs)("div",{className:"space-y-4",children:[(0,n.jsx)("p",{className:"text-gray-300 text-center text-sm",children:"Click below to receive a login code via Telegram."}),(0,n.jsxs)("button",{onClick:x,disabled:d,className:"w-full bg-blue-600 hover:bg-blue-500 text-white font-semibold py-3 px-4 rounded-lg transition flex items-center justify-center gap-2 disabled:opacity-50",children:[d?(0,n.jsx)(l.Z,{className:"animate-spin"}):(0,n.jsx)(o.Z,{size:20}),"Send Code to Telegram"]})]}):(0,n.jsxs)("div",{className:"space-y-4",children:[(0,n.jsx)("p",{className:"text-gray-300 text-center text-sm",children:"Enter the 6-digit code sent to your Telegram."}),(0,n.jsx)("input",{type:"text",value:r,onChange:e=>c(e.target.value),placeholder:"123456",className:"w-full bg-gray-700 border border-gray-600 rounded-lg px-4 py-3 text-center text-2xl tracking-widest focus:outline-none focus:ring-2 focus:ring-blue-500",maxLength:6}),(0,n.jsx)("button",{onClick:g,disabled:d||r.length<4,className:"w-full bg-green-600 hover:bg-green-500 text-white font-semibold py-3 px-4 rounded-lg transition flex items-center justify-center gap-2 disabled:opacity-50",children:d?(0,n.jsx)(l.Z,{className:"animate-spin"}):"Verify & Login"}),(0,n.jsx)("button",{onClick:()=>t("initial"),className:"w-full text-gray-400 hover:text-white text-sm",children:"Cancel"})]})]})})}},8755:function(e,t,r){"use strict";r.d(t,{Z:function(){return u}});var n=r(2265);let a=function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return t.filter((e,t,r)=>!!e&&""!==e.trim()&&r.indexOf(e)===t).join(" ").trim()},s=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),i=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,r)=>r?r.toUpperCase():t.toLowerCase()),l=e=>{let t=i(e);return t.charAt(0).toUpperCase()+t.slice(1)};var o={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let c=e=>{for(let t in e)if(t.startsWith("aria-")||"role"===t||"title"===t)return!0;return!1},d=(0,n.forwardRef)((e,t)=>{let{color:r="currentColor",size:s=24,strokeWidth:i=2,absoluteStrokeWidth:l,className:d="",children:u,iconNode:h,...f}=e;return(0,n.createElement)("svg",{ref:t,...o,width:s,height:s,stroke:r,strokeWidth:l?24*Number(i)/Number(s):i,className:a("lucide",d),...!u&&!c(f)&&{"aria-hidden":"true"},...f},[...h.map(e=>{let[t,r]=e;return(0,n.createElement)(t,r)}),...Array.isArray(u)?u:[u]])}),u=(e,t)=>{let r=(0,n.forwardRef)((r,i)=>{let{className:o,...c}=r;return(0,n.createElement)(d,{ref:i,iconNode:t,className:a("lucide-".concat(s(l(e))),"lucide-".concat(e),o),...c})});return r.displayName=l(e),r}},1817:function(e,t,r){"use strict";r.d(t,{Z:function(){return n}});let n=(0,r(8755).Z)("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]])},6337:function(e,t,r){"use strict";r.d(t,{Z:function(){return n}});let n=(0,r(8755).Z)("lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]])},4743:function(e,t,r){"use strict";r.d(t,{Z:function(){return n}});let n=(0,r(8755).Z)("send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]])},9376:function(e,t,r){"use strict";var n=r(5475);r.o(n,"usePathname")&&r.d(t,{usePathname:function(){return n.usePathname}}),r.o(n,"useRouter")&&r.d(t,{useRouter:function(){return n.useRouter}})}},function(e){e.O(0,[971,117,744],function(){return e(e.s=225)}),_N_E=e.O()}]);