From 07fc9a8fe379dd5a5bc91103628f69aec190e585 Mon Sep 17 00:00:00 2001 From: Marlene-Angel <139193696+Marlene-Angel@users.noreply.github.com> Date: Sat, 24 Jan 2026 20:02:21 -0800 Subject: [PATCH] feat: add onboarding screen and redirect new users after login --- apps/web/app/(auth)/login/page.tsx | 6 +- apps/web/app/onboarding/page.tsx | 5 + .../onboarding/OnboardingScreen.tsx | 170 ++++++++++++++++++ 3 files changed, 180 insertions(+), 1 deletion(-) create mode 100644 apps/web/app/onboarding/page.tsx create mode 100644 apps/web/components/onboarding/OnboardingScreen.tsx diff --git a/apps/web/app/(auth)/login/page.tsx b/apps/web/app/(auth)/login/page.tsx index dc2eebb..0e0e424 100644 --- a/apps/web/app/(auth)/login/page.tsx +++ b/apps/web/app/(auth)/login/page.tsx @@ -30,7 +30,11 @@ export default function LoginPage() { const response = await login({ email, password }); setTokens(response.accessToken, response.refreshToken); setUser(response.user); - router.push('/dashboard'); + + const STORAGE_KEY = 'horux360:onboarding_seen_v1'; + const seen = typeof window !== 'undefined' && localStorage.getItem(STORAGE_KEY) === '1'; + + router.push(seen ? '/dashboard' : '/onboarding'); } catch (err: any) { setError(err.response?.data?.message || 'Error al iniciar sesión'); } finally { diff --git a/apps/web/app/onboarding/page.tsx b/apps/web/app/onboarding/page.tsx new file mode 100644 index 0000000..b939b21 --- /dev/null +++ b/apps/web/app/onboarding/page.tsx @@ -0,0 +1,5 @@ +import OnboardingScreen from "../../components/onboarding/OnboardingScreen"; + +export default function Page() { + return ; +} diff --git a/apps/web/components/onboarding/OnboardingScreen.tsx b/apps/web/components/onboarding/OnboardingScreen.tsx new file mode 100644 index 0000000..2d5eecf --- /dev/null +++ b/apps/web/components/onboarding/OnboardingScreen.tsx @@ -0,0 +1,170 @@ +'use client'; + +import { useEffect, useMemo, useState } from 'react'; +import { useRouter } from 'next/navigation'; + +/** + * Onboarding persistence key. + * If you later want this to come from env/config, move it to apps/web/config/onboarding.ts + */ +const STORAGE_KEY = 'horux360:onboarding_seen_v1'; + +export default function OnboardingScreen() { + const router = useRouter(); + const [isNewUser, setIsNewUser] = useState(true); + const [loading, setLoading] = useState(false); + + const safePush = (path: string) => { + // Avoid multiple navigations if user clicks quickly. + if (loading) return; + setLoading(true); + router.push(path); + }; + + useEffect(() => { + const seen = typeof window !== 'undefined' && localStorage.getItem(STORAGE_KEY) === '1'; + + // If the user has already seen onboarding, go to dashboard automatically. + if (seen) { + setIsNewUser(false); + setLoading(true); + const t = setTimeout(() => router.push('/dashboard'), 900); + return () => clearTimeout(t); + } + }, [router]); + + const handleContinue = () => { + if (typeof window !== 'undefined') localStorage.setItem(STORAGE_KEY, '1'); + setLoading(true); + setTimeout(() => router.push('/dashboard'), 700); + }; + + const handleReset = () => { + if (typeof window !== 'undefined') localStorage.removeItem(STORAGE_KEY); + location.reload(); + }; + + const headerStatus = useMemo(() => (isNewUser ? 'Onboarding' : 'Redirección'), [isNewUser]); + + return ( +
+ {/* Grid tech claro */} +
+ + {/* Glow global azul (sutil) */} +
+ +
+
+
+ {/* Header */} +
+
+
+
+
+
+

Horux360

+

Pantalla de inicio

+
+
+ + {headerStatus} +
+ + {/* Body */} +
+ {isNewUser ? ( +
+ {/* Left */} +
+

+ Bienvenido a Horux360 +

+

+ Revisa este breve video para conocer el flujo. Después podrás continuar. +

+ +
+ + + +
+ +
+ Usuario nuevo: muestra video • Usuario recurrente: redirección automática +
+
+ + {/* Right (video) - elegante sin glow */} +
+
+
+
+
+
+ +
+ + + Video introductorio + + v1 +
+
+
+
+
+ ) : ( +
+
+
+
+

+ Redirigiendo al dashboard… +

+

Usuario recurrente detectado.

+ +
+
+
+ + +
+ )} +
+
+ +

+ Demo UI sin backend • Persistencia local: localStorage +

+
+
+
+ ); +}