diff --git a/frontend/index.html b/frontend/index.html index d02d4e4..5120c51 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -4,7 +4,7 @@ - orcid-system + ORCID2SWORD
diff --git a/frontend/src/components/layout/AppHeader.jsx b/frontend/src/components/layout/AppHeader.jsx index fd10421..029e66c 100644 --- a/frontend/src/components/layout/AppHeader.jsx +++ b/frontend/src/components/layout/AppHeader.jsx @@ -1,18 +1,16 @@ import { Link, useNavigate } from "react-router-dom"; import { toast } from "sonner"; -import { ArrowLeftIcon, LayersIcon, LogoutIcon, UserCheckIcon } from "../ui/Icons"; +import { LogoutIcon, UserCheckIcon } from "../ui/Icons"; import { useAuth } from "../../contexts/AuthContext"; /** * Institutional navy header used across all views. * - * Variants: - * - `landing` → logo + full product name. - * - `dashboard` → back button to `/` + auth indicator + logout (if logged in). - * - `group` → back button to `/` + group label + auth indicator. + * Brand: ORCID2SWORD — "2" in orcid-green, rest in white. + * Authenticated users see their name (or "Mi Perfil") + logout button. */ export function AppHeader({ variant = "landing" }) { - const { isAuthenticated, userOrcidId, logout } = useAuth(); + const { isAuthenticated, userOrcidId, userName, logout } = useAuth(); const navigate = useNavigate(); function handleLogout() { @@ -23,82 +21,42 @@ export function AppHeader({ variant = "landing" }) { navigate("/"); } - if (variant === "dashboard" || variant === "group") { - return ( -
+ const profileLabel = userName ?? "Mi Perfil"; + const profileHref = userOrcidId ? `/dashboard/${userOrcidId}` : "/"; + + return ( +
+
+ {/* Brand — always navigates home */} - - Inicio + ORCID2SWORD +
+ {isAuthenticated && ( -
- {userOrcidId && ( - - - Mi perfil - - )} - +
+ - Sesión activa - + {profileLabel} +
)} - - {variant === "group" ? "Búsqueda grupal · ORCID" : "Sistema ORCID · SWORD"} - -
- ); - } - - return ( -
-
-
- - Sistema de Integración ORCID · SWORD - - {isAuthenticated && ( -
- {userOrcidId && ( - - - Mi perfil - - )} - - - Sesión activa - - -
- )}
); } diff --git a/frontend/src/contexts/AuthContext.jsx b/frontend/src/contexts/AuthContext.jsx index 206cba1..4e4c833 100644 --- a/frontend/src/contexts/AuthContext.jsx +++ b/frontend/src/contexts/AuthContext.jsx @@ -29,6 +29,21 @@ function extractOrcidFromToken(token) { } } +function extractNameFromToken(token) { + if (!token) return null; + try { + const payloadBase64 = token.split(".")[1]; + if (!payloadBase64) return null; + const payloadJson = atob(payloadBase64.replace(/-/g, "+").replace(/_/g, "/")); + const payload = JSON.parse(payloadJson); + if (payload?.name) return payload.name; + const parts = [payload?.given_name, payload?.family_name].filter(Boolean); + return parts.length > 0 ? parts.join(" ") : null; + } catch { + return null; + } +} + /** * Provides JWT-based authentication state throughout the app. * @@ -82,6 +97,7 @@ export function AuthProvider({ children }) { token, isAuthenticated: Boolean(token), userOrcidId: extractOrcidFromToken(token), + userName: extractNameFromToken(token), storeToken, logout, }), diff --git a/frontend/src/pages/LandingPage.jsx b/frontend/src/pages/LandingPage.jsx index cd0a219..6793a2c 100644 --- a/frontend/src/pages/LandingPage.jsx +++ b/frontend/src/pages/LandingPage.jsx @@ -168,163 +168,168 @@ export function LandingPage() {
-
-
-
-
- +
+
+ + {/* ── Hero ── */} +
+
+
-

- Repositorio Institucional +

+ Tu producción científica,{" "} + siempre al día.

-

- Conecta tu perfil ORCID y deposita tus publicaciones - automáticamente en el repositorio institucional vía protocolo - SWORD. +

+ Sincroniza tu perfil ORCID y deposita tus publicaciones + automáticamente vía SWORD.

- {/* Main card */} -
- {isAuthenticated ? ( -
- Sesión activa - - Verás publicaciones nuevas marcadas en el dashboard - -
- ) : ( - <> + {/* ── Two-column grid ── */} +
+ + {/* ── Left: individual search + login ── */} +
+ {isAuthenticated ? ( +
+ Sesión activa + + Verás publicaciones nuevas marcadas en el dashboard + +
+ ) : ( - - )} - -
-
- - {isAuthenticated ? "TU ORCID iD" : "O INTRODUCE TU ORCID iD"} - -
-
- -
- -
-
- - - - -
- -
- {error && ( -

- {error} -

)} -

- {isAuthenticated - ? "Busca un investigador o usa «Cerrar sesión» arriba." - : "Pulsa «Iniciar sesión» para autenticarte, o «Buscar» de forma anónima."} + +

+
+ + {isAuthenticated ? "TU ORCID iD" : "O INTRODUCE TU ORCID iD"} + +
+
+ +
+ +
+
+ + + + +
+ +
+ {error && ( +

+ {error} +

+ )} +

+ {isAuthenticated + ? "Busca un investigador o usa «Cerrar sesión» arriba." + : "Pulsa «Iniciar sesión» para autenticarte, o «Buscar» de forma anónima."} +

+
+
+ + {/* ── Right: group search ── */} +
+
+ +

+ Búsqueda grupal de investigadores +

+
+

+ Pega varios ORCID iDs separados por comas, espacios o saltos de + línea para buscar y comparar varios investigadores a la vez.

+