After improving the design for the web part1

This commit is contained in:
Your Name 2026-11-06 16:59:31 +02:00
parent b4038667fd
commit 108ddd9076
12 changed files with 609 additions and 56 deletions

View File

@ -24,19 +24,57 @@ function once(key: string, load: () => Promise<unknown>): Promise<unknown> {
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<T>(_key: string, loader: () => Promise<T>): Promise<T> {
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<T>(() => undefined);
}
sessionStorage.removeItem(CHUNK_RELOAD_KEY);
} catch {
/* ignore storage / reload issues */
}
}
throw err;
}
}
function lazyNamed<T extends AnyModule, K extends keyof T>(
key: string,
loader: () => Promise<T>,
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<Record<string, never>> };

View File

@ -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: <RouteErrorPage />,
children: [
{
path: '/login',
element: <LoginPage />,
@ -424,4 +428,6 @@ export const router = createBrowserRouter([
},
],
},
],
},
]);

View File

@ -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 (
<Box sx={{ minHeight: '100vh', display: 'grid', placeItems: 'center', px: 2, position: 'relative' }}>
<Box sx={{ position: 'absolute', top: 16, right: 16 }}>
<Box
sx={{
position: 'absolute',
top: 16,
left: 16,
right: 16,
display: 'flex',
alignItems: 'center',
justifyContent: 'space-between',
gap: 1,
zIndex: 1,
}}
>
<Link
component={RouterLink}
to="/"
underline="hover"
sx={{
display: 'inline-flex',
alignItems: 'center',
gap: 0.75,
fontWeight: 700,
fontSize: '0.9rem',
}}
>
<ArrowBackRoundedIcon fontSize="small" />
{t('auth.backToPublicHome')}
</Link>
<LanguageSwitcher />
</Box>
<Card sx={{ width: '100%', maxWidth: 520 }}>
<Card sx={{ width: '100%', maxWidth: 520, mt: { xs: 5, sm: 0 } }}>
<CardContent>
<Typography variant="h4" sx={{ fontWeight: 900 }}>
{t('auth.resetPassword')}

View File

@ -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 (
<Box sx={{ minHeight: '100vh', display: 'grid', placeItems: 'center', px: 2, position: 'relative' }}>
<Box sx={{ position: 'absolute', top: 16, right: 16 }}>
<Box
sx={{
position: 'absolute',
top: 16,
left: 16,
right: 16,
display: 'flex',
alignItems: 'center',
justifyContent: 'space-between',
gap: 1,
zIndex: 1,
}}
>
<Link
component={RouterLink}
to="/"
underline="hover"
sx={{
display: 'inline-flex',
alignItems: 'center',
gap: 0.75,
fontWeight: 700,
fontSize: '0.9rem',
}}
>
<ArrowBackRoundedIcon fontSize="small" />
{t('auth.backToPublicHome')}
</Link>
<LanguageSwitcher />
</Box>
<Card sx={{ width: '100%', maxWidth: 520 }}>
<Card sx={{ width: '100%', maxWidth: 520, mt: { xs: 5, sm: 0 } }}>
<CardContent>
<PrediqoLogo size={48} />
<Box
component={RouterLink}
to="/"
aria-label={t('auth.backToPublicHome')}
sx={{ textDecoration: 'none', color: 'inherit', display: 'inline-flex' }}
>
<PrediqoLogo size={48} />
</Box>
<Typography sx={{ opacity: 0.75, mt: 1.25 }}>{t('auth.brandSubtitle')}</Typography>
<Stack spacing={2} sx={{ mt: 3 }}>

View File

@ -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 (
<Box sx={{ minHeight: '100vh', display: 'grid', placeItems: 'center', px: 2, py: 4, position: 'relative' }}>
<Box sx={{ position: 'absolute', top: 16, right: 16 }}>
<Box
sx={{
position: 'absolute',
top: 16,
left: 16,
right: 16,
display: 'flex',
alignItems: 'center',
justifyContent: 'space-between',
gap: 1,
zIndex: 1,
}}
>
<Link
component={RouterLink}
to="/"
underline="hover"
sx={{
display: 'inline-flex',
alignItems: 'center',
gap: 0.75,
fontWeight: 700,
fontSize: '0.9rem',
}}
>
<ArrowBackRoundedIcon fontSize="small" />
{t('auth.backToPublicHome')}
</Link>
<LanguageSwitcher />
</Box>
<Card sx={{ width: '100%', maxWidth: 560 }}>
<Card sx={{ width: '100%', maxWidth: 560, mt: { xs: 5, sm: 0 } }}>
<CardContent>
<PrediqoLogo size={40} />
<Box
component={RouterLink}
to="/"
aria-label={t('auth.backToPublicHome')}
sx={{ textDecoration: 'none', color: 'inherit', display: 'inline-flex' }}
>
<PrediqoLogo size={40} />
</Box>
<Typography variant="h5" sx={{ fontWeight: 900, mt: 1.5 }}>
{t('auth.createAccount')}
</Typography>

View File

@ -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) {
)}
<Stack spacing={0.75} sx={{ mb: 2.5 }}>
<Stack direction="row" spacing={1} sx={{ alignItems: 'center' }}>
<HelpOutlineRoundedIcon color="primary" />
<Typography variant="h4" sx={{ fontWeight: 900, fontSize: { xs: '1.65rem', sm: '2.125rem' } }}>
{t('faq.title')}
</Typography>
</Stack>
<Typography sx={{ opacity: 0.7 }}>{t('faq.subtitle')}</Typography>
<Typography
className="tl-display"
variant="h4"
sx={{ fontWeight: 900, fontSize: { xs: '1.65rem', sm: '2.2rem' }, letterSpacing: '-0.02em' }}
>
{t('faq.title')}
</Typography>
<Typography sx={{ opacity: 0.72, lineHeight: 1.55 }}>{t('faq.subtitle')}</Typography>
</Stack>
<TextField

View File

@ -1,20 +1,47 @@
import { Box, Container } from '@mui/material';
/**
* Public FAQ — same nocturnal visual language as the landing page,
* with a clear path back home and auth CTAs.
*/
import { Link as RouterLink } from 'react-router-dom';
import { useTranslation } from 'react-i18next';
import { LanguageSwitcher } from '../../shared/i18n/LanguageSwitcher';
import { PLATFORM_WORDMARK } from '../../shared/brand/platformName';
import { FaqPage } from './FaqPage';
import '../landing/landing.css';
/** Standalone public FAQ route (accessible without login). */
export function FaqPublicPage() {
const { t } = useTranslation();
return (
<Box
sx={{
minHeight: '100vh',
py: { xs: 2, md: 4 },
px: { xs: 2, sm: 3 },
background: 'linear-gradient(180deg, rgba(18,23,36,1) 0%, rgba(12,16,28,1) 100%)',
}}
>
<Container maxWidth="md">
<FaqPage showPublicHeader />
</Container>
</Box>
<div className="tloto-landing tl-faq-public">
<header className="tl-faq-public__header">
<div className="tl-faq-public__bar">
<RouterLink to="/" className="tl-faq-public__brand">
<img src="/brand/prediqo-mark.png" alt="" width={28} height={28} />
<span className="tl-display">{PLATFORM_WORDMARK}</span>
</RouterLink>
<div className="tl-faq-public__actions">
<LanguageSwitcher />
<RouterLink to="/login" className="tl-btn tl-btn--sm tl-btn--ghost">
{t('faq.publicHeader.login')}
</RouterLink>
<RouterLink to="/register" className="tl-btn tl-btn--sm tl-btn--primary">
{t('faq.publicHeader.register')}
</RouterLink>
</div>
</div>
</header>
<main className="tl-container tl-faq-public__main">
<p className="tl-eyebrow">{t('faq.publicKicker')}</p>
<FaqPage />
<div className="tl-faq-public__footer">
<RouterLink to="/" className="tl-faq-public__home-link">
← {t('auth.backToPublicHome')}
</RouterLink>
</div>
</main>
</div>
);
}

View File

@ -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 (
<section id="games" className="tl-section tl-reveal">
<section id="games" className="tl-section tl-section--tight tl-reveal">
<div className="tl-container">
<div className="tl-games-head">
<div>
@ -35,12 +50,8 @@ export function LandingGamePeek({ games, loading }: LandingGamePeekProps) {
{[0, 1].map((i) => (
<div
key={i}
style={{
minHeight: 320,
borderRadius: 28,
background: 'rgba(255,255,255,0.04)',
border: '1px solid rgba(255,255,255,0.06)',
}}
className="tl-game tl-game--skeleton"
aria-hidden
/>
))}
</div>
@ -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 (
<RouterLink
key={game.id}
to="/login"
className={`tl-game${reverse ? ' tl-game--reverse' : ''}`}
className={`tl-game${reverse ? ' tl-game--reverse' : ''}${
hasThumb ? '' : ' tl-game--no-thumb'
}`}
style={{
background: `linear-gradient(135deg, ${accent}1f 0%, rgba(10,14,22,0.94) 50%)`,
['--tl-game-accent' as string]: accent,
}}
>
<div className="tl-game__media" style={{ background: mediaBg }} />
<div className="tl-game__media" style={{ background: mediaBg }}>
{!hasThumb && (
<div className="tl-game__placeholder" aria-hidden>
{PLACEHOLDER_CANDLES.map((c, i) => (
<span
key={i}
className={`tl-game__ph-candle${c.up ? ' is-up' : ' is-down'}`}
style={{ height: `${c.h}%` }}
/>
))}
</div>
)}
</div>
<div className="tl-game__body">
<span className="tl-eyebrow" style={{ color: accent, ...accentEyebrow }}>
{game.category}

View File

@ -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) {

View File

@ -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: {

View File

@ -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: {

View File

@ -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 (
<Box
sx={{
minHeight: '100vh',
display: 'grid',
placeItems: 'center',
px: 2,
py: 4,
background:
'radial-gradient(90vw 50vh at 80% -10%, rgba(16,185,129,0.14), transparent 55%), linear-gradient(180deg, #0b0f1a 0%, #070a12 100%)',
color: '#eef3fb',
}}
>
<Stack spacing={2.5} sx={{ maxWidth: 440, width: '100%', textAlign: 'center', alignItems: 'center' }}>
<Box
component={RouterLink}
to="/"
sx={{ textDecoration: 'none', color: 'inherit', display: 'inline-flex' }}
>
<PrediqoLogo size={40} />
</Box>
<Typography sx={{ fontWeight: 900, fontSize: { xs: '1.5rem', sm: '1.85rem' }, lineHeight: 1.2 }}>
{title}
</Typography>
<Typography sx={{ opacity: 0.72, lineHeight: 1.55 }}>{body}</Typography>
<Stack direction={{ xs: 'column', sm: 'row' }} spacing={1.25} sx={{ width: '100%', pt: 0.5 }}>
<Button
fullWidth
variant="contained"
startIcon={<RefreshRoundedIcon />}
onClick={() => window.location.reload()}
sx={{
fontWeight: 800,
bgcolor: '#10b981',
color: '#04110c',
'&:hover': { bgcolor: '#34d399' },
}}
>
{t('errors.route.reload')}
</Button>
<Button
fullWidth
variant="outlined"
component={RouterLink}
to="/"
startIcon={<HomeRoundedIcon />}
sx={{
fontWeight: 800,
borderColor: 'rgba(255,255,255,0.22)',
color: '#eef3fb',
}}
>
{t('errors.route.home')}
</Button>
</Stack>
</Stack>
</Box>
);
}