feature/implementacion de hub en EFC
This commit is contained in:
@@ -1,7 +1,13 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { Link, useLocation } from 'react-router-dom';
|
||||
import { useLocation } from 'react-router-dom';
|
||||
import { colors } from '../theme';
|
||||
|
||||
const hubLoginUrl = () => {
|
||||
const HUB_URL = import.meta.env.VITE_HUB_URL || 'http://localhost:3001';
|
||||
const returnTo = encodeURIComponent(`${window.location.origin}/auth/sso`);
|
||||
return `${HUB_URL}/login?return_to=${returnTo}`;
|
||||
};
|
||||
|
||||
export default function Navbar() {
|
||||
const [isLoggedIn, setIsLoggedIn] = useState(false);
|
||||
const [isMenuOpen, setIsMenuOpen] = useState(false);
|
||||
@@ -18,11 +24,11 @@ export default function Navbar() {
|
||||
return () => window.removeEventListener('authStateChanged', checkAuthStatus);
|
||||
}, []);
|
||||
|
||||
const logout = () => {
|
||||
localStorage.removeItem('access');
|
||||
localStorage.removeItem('refresh');
|
||||
window.dispatchEvent(new CustomEvent('authStateChanged'));
|
||||
window.location.href = '/';
|
||||
const logout = async () => {
|
||||
const { logout: doLogout } = await import('../api/auth');
|
||||
doLogout(); // limpia estado + llama backend en bg
|
||||
const hubUrl = import.meta.env.VITE_HUB_URL || 'http://localhost:3001';
|
||||
window.location.href = `${hubUrl}/login`;
|
||||
};
|
||||
|
||||
const navLinks = [
|
||||
@@ -97,15 +103,15 @@ export default function Navbar() {
|
||||
</button>
|
||||
</div>
|
||||
) : (
|
||||
<Link
|
||||
to="/login"
|
||||
<a
|
||||
href={hubLoginUrl()}
|
||||
className="bg-gradient-to-r from-navy-600 to-navy-700 hover:from-navy-700 hover:to-navy-800 text-white px-4 py-2 rounded-lg text-sm font-medium transition-all duration-200 flex items-center space-x-2 shadow-lg hover:shadow-xl transform hover:scale-105"
|
||||
>
|
||||
<svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M11 16l-4-4m0 0l4-4m-4 4h14m-5 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3h4a3 3 0 013 3v1" />
|
||||
</svg>
|
||||
<span>Ingresar</span>
|
||||
</Link>
|
||||
</a>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user