import{u as g,r,aW as m,i as p,j as a,N as x,bc as E,B as o,aa as y,o as c,a6 as A,p as n,aL as F,bd as v}from"./index-e717fda1.js";import{b as C,p as j}from"./env-198ff0f3.js";const b=()=>{const{authFederal:i,unAuthenticateFederal:l,authenticateFederal:d}=g(),[I,h]=r.useState(!1),[u,f]=r.useState(!1),{code:t}=m();return console.log("codigo-> ",t),console.log("authFederal-> ",i),r.useEffect(()=>{console.log("useEffect triggered with code:",t),(async()=>{if(!t){console.error("No code provided in URL parameters");return}try{v.post(`${C}/${j}/rest/federal/access-code/login-with-access-code`,{accessCode:t},{withCredentials:!0}).then(e=>{e.data.success?(d(e.data),console.log("Authentication successful:",e.data)):(l(),f(!0),console.error("Authentication failed:",e.data))}).catch(e=>{console.error("Error fetching data:",e)})}catch(e){console.error("Error fetching data:",e)}})()},[]),r.useEffect(()=>{let s=!1;var e=document.cookie.match(new RegExp("(^| )JSESSIONID=([^;]+)"));e&&(s=!0),s!==!1&&h(!0)},[]),p({typography:{fontFamily:["Poppins","sans-serif"].join(",")}}),i?a(x,{to:"/federal-home"}):a(E,{children:a(o,{sx:{backgroundColor:"#F4F5FA",height:"100dvh"},children:a(y,{maxWidth:"xl",children:a(o,{sx:{},children:c(o,{sx:{paddingTop:"1em"},children:[a(A,{}),c(o,{sx:{display:"flex",justifyContent:"center",marginTop:"2em",alignItems:"center",flexDirection:"column",gap:"1em"},children:[a(n,{textAlign:"center",variant:"h6",children:"Autenticacion automatica Crédito Federal"}),a(n,{textAlign:"center",variant:"h6",children:"Espere un momento... Sera redirigido a la pantalla principal"}),u&&a(F,{severity:"error",children:"Falló la autenticación. Verifique el código o intente más tarde."})]})]})})})})})};export{b as default};
