From 108ddd90764e19cdbe48fabe12dae8f6fb5ffddc Mon Sep 17 00:00:00 2001 From: Your Name Date: Fri, 6 Nov 2026 16:59:31 +0200 Subject: [PATCH] After improving the design for the web part1 --- prediqo_web/src/app/router/routePrefetch.ts | 42 ++- prediqo_web/src/app/router/router.tsx | 6 + .../src/features/auth/ForgotPasswordPage.tsx | 32 ++- prediqo_web/src/features/auth/LoginPage.tsx | 41 ++- .../src/features/auth/RegisterPage.tsx | 41 ++- prediqo_web/src/features/faq/FaqPage.tsx | 16 +- .../src/features/faq/FaqPublicPage.tsx | 53 +++- .../landing/components/LandingGamePeek.tsx | 49 +++- prediqo_web/src/features/landing/landing.css | 253 +++++++++++++++++- prediqo_web/src/shared/i18n/locales/en.ts | 12 + prediqo_web/src/shared/i18n/locales/fr.ts | 12 + .../src/shared/routing/RouteErrorPage.tsx | 108 ++++++++ 12 files changed, 609 insertions(+), 56 deletions(-) create mode 100644 prediqo_web/src/shared/routing/RouteErrorPage.tsx diff --git a/prediqo_web/src/app/router/routePrefetch.ts b/prediqo_web/src/app/router/routePrefetch.ts index f87eccfb..33e1ff61 100644 --- a/prediqo_web/src/app/router/routePrefetch.ts +++ b/prediqo_web/src/app/router/routePrefetch.ts @@ -24,19 +24,57 @@ function once(key: string, load: () => Promise): Promise { return pending; } +const CHUNK_RELOAD_KEY = 'tl_chunk_reload_once'; + +function isChunkLoadFailure(err: unknown): boolean { + const msg = err instanceof Error ? err.message : String(err ?? ''); + return /Failed to fetch dynamically imported module|Loading chunk [\d]+ failed|ChunkLoadError|Importing a module script failed/i.test( + msg + ); +} + +async function loadWithChunkRecovery(_key: string, loader: () => Promise): Promise { + try { + const mod = await loader(); + try { + sessionStorage.removeItem(CHUNK_RELOAD_KEY); + } catch { + /* ignore */ + } + return mod; + } catch (err) { + if (isChunkLoadFailure(err)) { + try { + if (!sessionStorage.getItem(CHUNK_RELOAD_KEY)) { + sessionStorage.setItem(CHUNK_RELOAD_KEY, '1'); + window.location.reload(); + // Stay pending until the page unloads. + return await new Promise(() => undefined); + } + sessionStorage.removeItem(CHUNK_RELOAD_KEY); + } catch { + /* ignore storage / reload issues */ + } + } + throw err; + } +} + function lazyNamed( key: string, loader: () => Promise, exportName: K ): LazyPage { + const safeLoader = () => loadWithChunkRecovery(key, loader); + const preload = () => once(key, async () => { - const mod = await loader(); + const mod = await safeLoader(); return mod[exportName]; }); const Comp = lazy(async () => { - const mod = await loader(); + const mod = await safeLoader(); // Keep cache warm for subsequent prefetchRoute calls. void once(key, async () => mod[exportName]); return { default: mod[exportName] as ComponentType> }; diff --git a/prediqo_web/src/app/router/router.tsx b/prediqo_web/src/app/router/router.tsx index fa01473a..8b946872 100644 --- a/prediqo_web/src/app/router/router.tsx +++ b/prediqo_web/src/app/router/router.tsx @@ -9,6 +9,7 @@ import { AppShell } from '../../shared/layout/AppShell'; import { RequireAuth } from '../../shared/auth/RequireAuth'; import { LoginPage } from '../../features/auth/LoginPage'; import { SetupPage } from '../../features/auth/SetupPage'; +import { RouteErrorPage } from '../../shared/routing/RouteErrorPage'; import { RegisterPage, VerifyEmailPage, @@ -67,6 +68,9 @@ function L({ children }: { children: ReactNode }) { /** Browser router instance with login, dashboard, options, and admin route trees. */ export const router = createBrowserRouter([ + { + errorElement: , + children: [ { path: '/login', element: , @@ -424,4 +428,6 @@ export const router = createBrowserRouter([ }, ], }, + ], + }, ]); diff --git a/prediqo_web/src/features/auth/ForgotPasswordPage.tsx b/prediqo_web/src/features/auth/ForgotPasswordPage.tsx index e472c160..de38cbde 100644 --- a/prediqo_web/src/features/auth/ForgotPasswordPage.tsx +++ b/prediqo_web/src/features/auth/ForgotPasswordPage.tsx @@ -2,6 +2,7 @@ * Request a password reset link by email. */ import { Alert, Box, Button, Card, CardContent, Link, Stack, TextField, Typography } from '@mui/material'; +import ArrowBackRoundedIcon from '@mui/icons-material/ArrowBackRounded'; import { useState } from 'react'; import { Link as RouterLink } from 'react-router-dom'; import { useTranslation } from 'react-i18next'; @@ -43,10 +44,37 @@ export function ForgotPasswordPage() { return ( - + + + + {t('auth.backToPublicHome')} + - + {t('auth.resetPassword')} diff --git a/prediqo_web/src/features/auth/LoginPage.tsx b/prediqo_web/src/features/auth/LoginPage.tsx index c3214b3b..185f68e4 100644 --- a/prediqo_web/src/features/auth/LoginPage.tsx +++ b/prediqo_web/src/features/auth/LoginPage.tsx @@ -16,6 +16,7 @@ import { TextField, Typography, } from '@mui/material'; +import ArrowBackRoundedIcon from '@mui/icons-material/ArrowBackRounded'; import VisibilityOffRoundedIcon from '@mui/icons-material/VisibilityOffRounded'; import VisibilityRoundedIcon from '@mui/icons-material/VisibilityRounded'; import { useState, useCallback } from 'react'; @@ -220,12 +221,46 @@ export function LoginPage() { return ( - + + + + {t('auth.backToPublicHome')} + - + - + + + {t('auth.brandSubtitle')} diff --git a/prediqo_web/src/features/auth/RegisterPage.tsx b/prediqo_web/src/features/auth/RegisterPage.tsx index 6eb3949f..4347c709 100644 --- a/prediqo_web/src/features/auth/RegisterPage.tsx +++ b/prediqo_web/src/features/auth/RegisterPage.tsx @@ -14,6 +14,7 @@ import { TextField, Typography, } from '@mui/material'; +import ArrowBackRoundedIcon from '@mui/icons-material/ArrowBackRounded'; import VisibilityOffRoundedIcon from '@mui/icons-material/VisibilityOffRounded'; import VisibilityRoundedIcon from '@mui/icons-material/VisibilityRounded'; import { useEffect, useState } from 'react'; @@ -179,12 +180,46 @@ export function RegisterPage() { return ( - + + + + {t('auth.backToPublicHome')} + - + - + + + {t('auth.createAccount')} diff --git a/prediqo_web/src/features/faq/FaqPage.tsx b/prediqo_web/src/features/faq/FaqPage.tsx index 7966054b..cf91bb32 100644 --- a/prediqo_web/src/features/faq/FaqPage.tsx +++ b/prediqo_web/src/features/faq/FaqPage.tsx @@ -16,7 +16,6 @@ import ExpandMoreRoundedIcon from '@mui/icons-material/ExpandMoreRounded'; import SearchRoundedIcon from '@mui/icons-material/SearchRounded'; import ThumbUpAltOutlinedIcon from '@mui/icons-material/ThumbUpAltOutlined'; import ThumbDownAltOutlinedIcon from '@mui/icons-material/ThumbDownAltOutlined'; -import HelpOutlineRoundedIcon from '@mui/icons-material/HelpOutlineRounded'; import TrendingUpRoundedIcon from '@mui/icons-material/TrendingUpRounded'; import { PrediqoLogo } from '../../shared/brand/PrediqoLogo'; import { useQuery, useMutation } from '@tanstack/react-query'; @@ -193,13 +192,14 @@ export function FaqPage({ showPublicHeader = false }: FaqPageProps) { )} - - - - {t('faq.title')} - - - {t('faq.subtitle')} + + {t('faq.title')} + + {t('faq.subtitle')} - - - - +
+
+
+ + + {PLATFORM_WORDMARK} + +
+ + + {t('faq.publicHeader.login')} + + + {t('faq.publicHeader.register')} + +
+
+
+ +
+

{t('faq.publicKicker')}

+ +
+ + ← {t('auth.backToPublicHome')} + +
+
+
); } diff --git a/prediqo_web/src/features/landing/components/LandingGamePeek.tsx b/prediqo_web/src/features/landing/components/LandingGamePeek.tsx index 001ad405..1406b2d5 100644 --- a/prediqo_web/src/features/landing/components/LandingGamePeek.tsx +++ b/prediqo_web/src/features/landing/components/LandingGamePeek.tsx @@ -12,13 +12,28 @@ type LandingGamePeekProps = { loading?: boolean; }; +/** Deterministic mini-candle silhouette for games without a thumbnail. */ +const PLACEHOLDER_CANDLES: Array<{ h: number; up: boolean }> = [ + { h: 42, up: true }, + { h: 58, up: false }, + { h: 36, up: true }, + { h: 70, up: true }, + { h: 48, up: false }, + { h: 78, up: true }, + { h: 54, up: false }, + { h: 88, up: true }, + { h: 62, up: true }, + { h: 44, up: false }, + { h: 74, up: true }, +]; + export function LandingGamePeek({ games, loading }: LandingGamePeekProps) { const { t } = useTranslation(); const featured = games.filter((g) => g.isFeatured).slice(0, 2); const list = featured.length > 0 ? featured : games.slice(0, 2); return ( -
+
@@ -35,12 +50,8 @@ export function LandingGamePeek({ games, loading }: LandingGamePeekProps) { {[0, 1].map((i) => (
))}
@@ -53,19 +64,35 @@ export function LandingGamePeek({ games, loading }: LandingGamePeekProps) { {list.map((game, index) => { const accent = game.accentColor || '#10B981'; const reverse = index % 2 === 1; - const mediaBg = game.thumbnailUrl + const hasThumb = Boolean(game.thumbnailUrl); + const mediaBg = hasThumb ? `linear-gradient(135deg, ${accent}2e, transparent 60%), center/cover no-repeat url(${game.thumbnailUrl})` - : `radial-gradient(circle at 32% 30%, ${accent}66, transparent 58%), linear-gradient(145deg, #121a2a, #0a0e16)`; + : `radial-gradient(circle at 30% 35%, ${accent}55, transparent 55%), linear-gradient(145deg, #121a2a, #0a0e16)`; return ( -
+
+ {!hasThumb && ( +
+ {PLACEHOLDER_CANDLES.map((c, i) => ( + + ))} +
+ )} +
{game.category} diff --git a/prediqo_web/src/features/landing/landing.css b/prediqo_web/src/features/landing/landing.css index afca290d..e363491a 100644 --- a/prediqo_web/src/features/landing/landing.css +++ b/prediqo_web/src/features/landing/landing.css @@ -388,7 +388,7 @@ .tl-offers { position: relative; overflow: hidden; - min-height: clamp(320px, 46vh, 460px); + min-height: clamp(220px, 34vh, 360px); display: flex; align-items: center; border-top: 1px solid var(--tl-line); @@ -441,9 +441,9 @@ .tl-games-head { display: grid; - gap: 1.25rem; + gap: 0.85rem; align-items: end; - margin-bottom: clamp(2rem, 4vw, 3rem); + margin-bottom: clamp(1.25rem, 3vw, 2rem); min-width: 0; } @@ -465,7 +465,7 @@ .tl-game { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr); - min-height: clamp(300px, 38vw, 420px); + min-height: clamp(260px, 32vw, 380px); border-radius: 28px; overflow: hidden; border: 1px solid var(--tl-line); @@ -474,6 +474,13 @@ transition: transform 0.22s ease, border-color 0.22s ease, box-shadow 0.22s ease; } +.tl-game--skeleton { + min-height: 220px; + background: rgba(255, 255, 255, 0.04); + border: 1px solid rgba(255, 255, 255, 0.06); + pointer-events: none; +} + .tl-game:hover { transform: translateY(-4px); border-color: rgba(255, 255, 255, 0.2); @@ -487,24 +494,74 @@ .tl-game__media { direction: ltr; position: relative; - min-height: 240px; + min-height: 180px; background-size: cover; background-position: center; } +.tl-game--no-thumb .tl-game__media { + min-height: 160px; +} + .tl-game__media::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 40%, rgba(7, 10, 18, 0.55) 100%); + pointer-events: none; +} + +.tl-game__placeholder { + position: absolute; + inset: 18% 10% 14%; + z-index: 1; + display: flex; + align-items: flex-end; + justify-content: center; + gap: 7px; +} + +.tl-game__ph-candle { + flex: 0 0 auto; + width: 9px; + border-radius: 2px; + position: relative; +} + +.tl-game__ph-candle::before { + content: ''; + position: absolute; + left: 50%; + top: -18%; + width: 2px; + height: 136%; + transform: translateX(-50%); + background: currentColor; + opacity: 0.35; +} + +.tl-game__ph-candle.is-up { + color: var(--tl-game-accent, var(--tl-emerald)); + background: linear-gradient( + 180deg, + color-mix(in srgb, var(--tl-game-accent, #34d399) 92%, white), + color-mix(in srgb, var(--tl-game-accent, #10b981) 35%, transparent) + ); + box-shadow: 0 0 14px color-mix(in srgb, var(--tl-game-accent, #10b981) 40%, transparent); +} + +.tl-game__ph-candle.is-down { + color: #d4af37; + background: linear-gradient(180deg, rgba(212, 175, 55, 0.9), rgba(212, 175, 55, 0.28)); + box-shadow: 0 0 12px rgba(212, 175, 55, 0.25); } .tl-game__body { direction: ltr; display: grid; align-content: center; - gap: 0.85rem; - padding: clamp(1.75rem, 3vw, 3rem); + gap: 0.7rem; + padding: clamp(1.25rem, 2.4vw, 2.4rem); } .tl-game__title { @@ -881,13 +938,118 @@ transform: none; } +/* ========================================================================== + PUBLIC FAQ — reuses landing atmosphere + ========================================================================== */ + +.tl-faq-public { + min-height: 100vh; +} + +.tl-faq-public__header { + position: sticky; + top: 0; + z-index: 20; + padding: 0.85rem clamp(0.75rem, 3vw, 1.5rem); + backdrop-filter: blur(16px); + -webkit-backdrop-filter: blur(16px); + background: rgba(7, 10, 16, 0.72); + border-bottom: 1px solid var(--tl-line); +} + +.tl-faq-public__bar { + max-width: var(--tl-max); + margin: 0 auto; + display: flex; + align-items: center; + justify-content: space-between; + gap: 0.75rem; + min-width: 0; +} + +.tl-faq-public__brand { + display: inline-flex; + align-items: center; + gap: 10px; + text-decoration: none; + color: inherit; + flex-shrink: 0; + font-weight: 800; + font-size: 1.05rem; +} + +.tl-faq-public__brand img { + border-radius: 8px; +} + +.tl-faq-public__actions { + display: flex; + align-items: center; + gap: 0.45rem; + flex-shrink: 0; + min-width: 0; +} + +.tl-faq-public__main { + padding-block: clamp(1.75rem, 4vw, 3rem) clamp(3rem, 6vw, 4.5rem); + max-width: 920px; +} + +.tl-faq-public__footer { + margin-top: 2rem; + padding-top: 1.25rem; + border-top: 1px solid var(--tl-line); +} + +.tl-faq-public__home-link { + text-decoration: none; + color: rgba(238, 243, 251, 0.78); + font-weight: 700; + font-size: 0.92rem; +} + +.tl-faq-public__home-link:hover { + color: var(--tl-text); +} + +.tl-faq-public .MuiAccordion-root { + background: rgba(255, 255, 255, 0.03) !important; + border: 1px solid var(--tl-line); + box-shadow: none !important; + color: inherit; +} + +.tl-faq-public .MuiAccordionSummary-root, +.tl-faq-public .MuiAccordionDetails-root { + color: inherit; +} + +.tl-faq-public .MuiChip-root { + border-color: rgba(255, 255, 255, 0.16); +} + +.tl-faq-public .MuiTextField-root .MuiOutlinedInput-root { + background: rgba(255, 255, 255, 0.03); +} + +@media (max-width: 560px) { + .tl-faq-public__actions .tl-btn--ghost { + display: none; + } + + .tl-faq-public__actions .tl-btn--primary { + padding-inline: 0.85rem; + font-size: 0.78rem; + } +} + /* ========================================================================== RESPONSIVE ========================================================================== */ @media (max-width: 1024px) { .tl-game { - min-height: clamp(260px, 44vw, 360px); + min-height: clamp(220px, 38vw, 320px); } } @@ -896,9 +1058,35 @@ --tl-gutter: clamp(1rem, 4vw, 1.5rem); } + .tl-section { + padding-block: clamp(2.25rem, 6vw, 3.25rem); + } + + .tl-section--tight { + padding-block: clamp(1.75rem, 5vw, 2.75rem); + } + .tl-hero { min-height: auto; - padding-block: clamp(5.5rem, 10vh, 7rem) clamp(2.5rem, 6vh, 4rem); + padding-block: clamp(5.25rem, 9vh, 6.5rem) clamp(2rem, 5vh, 3.25rem); + } + + .tl-offers { + min-height: 0; + } + + .tl-offers__inner { + padding-block: clamp(1.75rem, 5vw, 2.75rem); + gap: 0.75rem; + } + + .tl-live-head, + .tl-why-head { + margin-bottom: 1.25rem; + } + + .tl-closing { + padding-block: clamp(2.25rem, 6vw, 3.5rem); } .tl-hero-visual { @@ -989,6 +1177,33 @@ .tl-game { grid-template-columns: 1fr; direction: ltr !important; + min-height: 0; + } + + .tl-game__media { + min-height: 132px; + } + + .tl-game--no-thumb .tl-game__media { + min-height: 112px; + } + + .tl-game__placeholder { + inset: 16% 8% 12%; + gap: 5px; + } + + .tl-game__ph-candle { + width: 7px; + } + + .tl-game__body { + padding: 1.15rem 1.2rem 1.35rem; + gap: 0.55rem; + } + + .tl-game__title { + font-size: clamp(1.35rem, 6vw, 1.75rem); } .tl-why-grid { @@ -996,7 +1211,7 @@ } .tl-why-col { - padding: 1.75rem 0; + padding: 1.25rem 0; border-left: 0; border-top: 1px solid var(--tl-line); } @@ -1005,16 +1220,22 @@ border-top: 0; } + .tl-why-num { + font-size: 2.1rem; + margin-bottom: 0.55rem; + } + .tl-why-head { max-width: none; + margin-bottom: 1.25rem; + } + + .tl-feed { + padding: 1.1rem 1.15rem; } } @media (max-width: 480px) { - .tl-section { - padding-block: clamp(2.5rem, 8vw, 3.5rem); - } - .tl-wordmark { font-size: clamp(2.6rem, 14vw, 3.6rem); } @@ -1031,6 +1252,10 @@ .tl-closing__ctas .tl-btn { width: 100%; } + + .tl-games-list { + gap: 0.9rem; + } } @media (min-width: 1025px) { diff --git a/prediqo_web/src/shared/i18n/locales/en.ts b/prediqo_web/src/shared/i18n/locales/en.ts index 5b09a01b..8464bd02 100644 --- a/prediqo_web/src/shared/i18n/locales/en.ts +++ b/prediqo_web/src/shared/i18n/locales/en.ts @@ -150,6 +150,7 @@ export const en = { }, auth: { brandSubtitle: 'Prediction games platform — sign in to manage or play.', + backToPublicHome: 'Back to home', signIn: 'Sign in', signingIn: 'Signing in…', signUp: 'Sign up', @@ -1003,9 +1004,20 @@ export const en = { percentOf: '{{percent}}% of {{amount}}', }, }, + errors: { + route: { + title: 'Something went wrong', + body: 'This page could not be loaded. Please refresh, or return to the home page.', + notFoundTitle: 'Page not found', + notFoundBody: 'This link does not exist or is no longer available.', + reload: 'Refresh page', + home: 'Back to home', + }, + }, faq: { title: 'Frequently asked questions', subtitle: 'Find quick answers to the most common questions.', + publicKicker: 'Help center', searchPlaceholder: 'Search for a question…', allCategories: 'All', categories: { diff --git a/prediqo_web/src/shared/i18n/locales/fr.ts b/prediqo_web/src/shared/i18n/locales/fr.ts index 3afaf5e4..86ff8fb6 100644 --- a/prediqo_web/src/shared/i18n/locales/fr.ts +++ b/prediqo_web/src/shared/i18n/locales/fr.ts @@ -151,6 +151,7 @@ export const fr = { auth: { brandSubtitle: 'Plateforme de jeux de prédiction — connectez-vous pour gérer ou jouer.', + backToPublicHome: 'Retour à l’accueil', signIn: 'Connexion', signingIn: 'Connexion…', signUp: 'Inscription', @@ -1017,9 +1018,20 @@ export const fr = { percentOf: '{{percent}} % de {{amount}}', }, }, + errors: { + route: { + title: 'Une erreur est survenue', + body: 'Cette page n’a pas pu être chargée. Actualisez, ou revenez à l’accueil.', + notFoundTitle: 'Page introuvable', + notFoundBody: 'Ce lien n’existe pas ou n’est plus disponible.', + reload: 'Actualiser la page', + home: 'Retour à l’accueil', + }, + }, faq: { title: 'Foire aux questions', subtitle: 'Trouvez rapidement des réponses aux questions les plus fréquentes.', + publicKicker: 'Centre d’aide', searchPlaceholder: 'Rechercher une question…', allCategories: 'Toutes', categories: { diff --git a/prediqo_web/src/shared/routing/RouteErrorPage.tsx b/prediqo_web/src/shared/routing/RouteErrorPage.tsx new file mode 100644 index 00000000..94bcd2b8 --- /dev/null +++ b/prediqo_web/src/shared/routing/RouteErrorPage.tsx @@ -0,0 +1,108 @@ +/** + * User-facing route error screen — never shows stack traces or chunk URLs. + * Handles stale deploy chunk misses via a one-shot reload. + */ +import { Box, Button, Stack, Typography } from '@mui/material'; +import HomeRoundedIcon from '@mui/icons-material/HomeRounded'; +import RefreshRoundedIcon from '@mui/icons-material/RefreshRounded'; +import { isRouteErrorResponse, Link as RouterLink, useRouteError } from 'react-router-dom'; +import { useTranslation } from 'react-i18next'; +import { PrediqoLogo } from '../brand/PrediqoLogo'; + +const CHUNK_RELOAD_KEY = 'tl_chunk_reload_once'; + +function isChunkLoadFailure(error: unknown): boolean { + const msg = + error instanceof Error + ? error.message + : typeof error === 'string' + ? error + : ''; + return /Failed to fetch dynamically imported module|Loading chunk [\d]+ failed|ChunkLoadError|Importing a module script failed/i.test( + msg + ); +} + +/** Friendly fallback when a route throws or a lazy chunk fails to load. */ +export function RouteErrorPage() { + const { t } = useTranslation(); + const error = useRouteError(); + + if (typeof window !== 'undefined' && isChunkLoadFailure(error)) { + try { + if (!sessionStorage.getItem(CHUNK_RELOAD_KEY)) { + sessionStorage.setItem(CHUNK_RELOAD_KEY, '1'); + window.location.reload(); + } else { + sessionStorage.removeItem(CHUNK_RELOAD_KEY); + } + } catch { + /* ignore storage errors */ + } + } + + const status = isRouteErrorResponse(error) ? error.status : null; + const title = + status === 404 ? t('errors.route.notFoundTitle') : t('errors.route.title'); + const body = + status === 404 ? t('errors.route.notFoundBody') : t('errors.route.body'); + + return ( + + + + + + + {title} + + {body} + + + + + + + ); +}