games_app/prediqo_web/src/features/landing/LandingPage.tsx
2026-11-06 11:33:42 +02:00

240 lines
8.9 KiB
TypeScript

/**
* Public Tloto web landing — desktop-first nocturnal prediction exchange.
* One job per section; auth CTAs only in header + hero (no repeats).
*/
import { useEffect, useMemo } from 'react';
import { Link as RouterLink } from 'react-router-dom';
import { useTranslation } from 'react-i18next';
import { useGames, useHeroAdvertisements } from '../home/hooks/useCatalog';
import { LandingHeader } from './components/LandingHeader';
import { LandingHero } from './components/LandingHero';
import { LandingGamePeek } from './components/LandingGamePeek';
import { LandingFeedStrip } from './components/LandingFeedStrip';
import { useActivityFeed, useWithdrawalFeed } from './hooks/useMarketingFeeds';
import { PLATFORM_WORDMARK } from '../../shared/brand/platformName';
import './landing.css';
function scrollToId(id: string) {
document.getElementById(id)?.scrollIntoView({ behavior: 'smooth', block: 'start' });
}
/**
* Reveals elements tagged `.tl-reveal` as they enter the viewport.
* Soft-fails (reveals everything) when IntersectionObserver is unavailable or
* the user prefers reduced motion.
*/
function useScrollReveal() {
useEffect(() => {
const nodes = Array.from(document.querySelectorAll<HTMLElement>('.tl-reveal'));
const reduce = window.matchMedia?.('(prefers-reduced-motion: reduce)').matches;
if (reduce || typeof IntersectionObserver === 'undefined') {
nodes.forEach((n) => n.classList.add('tl-in'));
return;
}
const observer = new IntersectionObserver(
(entries) => {
entries.forEach((entry) => {
if (entry.isIntersecting) {
entry.target.classList.add('tl-in');
observer.unobserve(entry.target);
}
});
},
{ threshold: 0.14, rootMargin: '0px 0px -8% 0px' }
);
nodes.forEach((n) => observer.observe(n));
return () => observer.disconnect();
}, []);
}
/** Guest marketing home for the Tloto web app. */
export function LandingPage() {
const { t } = useTranslation();
const gamesQ = useGames();
const heroQ = useHeroAdvertisements();
const activityQ = useActivityFeed();
const withdrawalsQ = useWithdrawalFeed();
useScrollReveal();
const navItems = useMemo(
() => [
{ id: 'offers', label: t('landing.nav.offers') },
{ id: 'games', label: t('landing.nav.games') },
{ id: 'live', label: t('landing.nav.live') },
{ id: 'why', label: t('landing.nav.why') },
],
[t]
);
const whyItems = [
{ title: t('landing.why.predictTitle'), body: t('landing.why.predictBody') },
{ title: t('landing.why.walletTitle'), body: t('landing.why.walletBody') },
{ title: t('landing.why.referralTitle'), body: t('landing.why.referralBody') },
];
const activityRows = (activityQ.data?.items ?? []).map((item) => ({
id: item.id,
left: item.publicId,
right:
item.statusLabel === 'Playing'
? t('landing.feeds.statusPlaying')
: item.statusLabel === 'Completed'
? t('landing.feeds.statusCompleted')
: item.statusLabel,
}));
const withdrawalRows = (withdrawalsQ.data?.items ?? []).map((item) => ({
id: item.id,
left: item.publicId,
right: `${item.amountLabel} USDT`,
}));
const activePlayers = activityQ.data?.activePlayersCount;
const heroAd = (heroQ.data ?? [])[0] ?? null;
const offerMedia = heroAd?.imageUrl
? `linear-gradient(100deg, rgba(5,8,14,0.72), rgba(5,8,14,0.28) 55%, rgba(5,8,14,0.62)), center/cover no-repeat url(${heroAd.imageUrl})`
: heroAd?.backgroundGradient || undefined;
return (
<div className="tloto-landing">
<LandingHeader navItems={navItems} onNavigateSection={scrollToId} />
<LandingHero />
{/* Offers — one promotional band (campaign CTA only, not generic auth) */}
<section id="offers" className="tl-offers tl-reveal" style={{ scrollMarginTop: 96 }}>
{offerMedia && <div className="tl-offers__media" aria-hidden style={{ background: offerMedia }} />}
<div className="tl-offers__scrim" aria-hidden />
<div className="tl-container tl-offers__inner">
<p className="tl-eyebrow tl-eyebrow--gold">{t('landing.offers.kicker')}</p>
{heroQ.isLoading && <p className="tl-muted">{t('common.loading')}</p>}
{!heroQ.isLoading && !heroAd && (
<>
<h2 className="tl-display tl-offers__title">{t('landing.offers.title')}</h2>
<p className="tl-offers__sub">{t('landing.offers.empty')}</p>
</>
)}
{heroAd && (
<>
<h2 className="tl-display tl-offers__title">{heroAd.title}</h2>
{heroAd.subtitle && <p className="tl-offers__sub">{heroAd.subtitle}</p>}
{heroAd.ctaLabel && (
<RouterLink
to={heroAd.linkUrl?.startsWith('/') ? heroAd.linkUrl : '/register'}
className="tl-btn"
style={{
justifySelf: 'start',
marginTop: '0.75rem',
color: '#04110c',
background: heroAd.accentColor || '#10B981',
}}
>
{heroAd.ctaLabel}
</RouterLink>
)}
</>
)}
</div>
</section>
<LandingGamePeek games={gamesQ.data ?? []} loading={gamesQ.isLoading} />
{/* Live — dual ticker boards */}
<section id="live" className="tl-section tl-divider-top tl-reveal">
<div className="tl-container">
<div className="tl-live-head">
<div>
<p className="tl-eyebrow">{t('landing.live.kicker')}</p>
<h2 className="tl-display tl-h2">{t('landing.live.title')}</h2>
<p className="tl-muted" style={{ marginTop: '0.75rem', maxWidth: '32rem' }}>
{t('landing.live.subtitle')}
</p>
</div>
{typeof activePlayers === 'number' && activePlayers > 0 && (
<span className="tl-live-pill">
<span className="tl-dot" />
{t('landing.live.subtitleWithCount', { count: activePlayers })}
</span>
)}
</div>
<div className="tl-live-grid">
<LandingFeedStrip
title={t('landing.feeds.activityTitle')}
subtitle={t('landing.feeds.activitySubtitle')}
rows={activityRows}
loading={activityQ.isLoading}
emptyLabel={t('landing.feeds.activityEmpty')}
accent="#34D399"
/>
<LandingFeedStrip
title={t('landing.feeds.withdrawalsTitle')}
subtitle={t('landing.feeds.withdrawalsSubtitle')}
rows={withdrawalRows}
loading={withdrawalsQ.isLoading}
emptyLabel={t('landing.feeds.withdrawalsEmpty')}
accent="#D4AF37"
/>
</div>
</div>
</section>
{/* Why — three numbered columns */}
<section id="why" className="tl-section tl-divider-top tl-reveal">
<div className="tl-container">
<div className="tl-why-head">
<p className="tl-eyebrow">{t('landing.why.kicker')}</p>
<h2 className="tl-display tl-h2">{t('landing.why.title')}</h2>
<p className="tl-muted" style={{ marginTop: '1rem' }}>
{t('landing.why.subtitle')}
</p>
</div>
<div className="tl-why-grid">
{whyItems.map((item, i) => (
<div key={item.title} className="tl-why-col">
<p className="tl-display tl-why-num">{String(i + 1).padStart(2, '0')}</p>
<h3 className="tl-display tl-why-title">{item.title}</h3>
<p className="tl-why-body">{item.body}</p>
</div>
))}
</div>
</div>
</section>
{/* FAQ only — no second signup CTA */}
<section className="tl-closing tl-reveal">
<div className="tl-container">
<p className="tl-eyebrow" style={{ justifyContent: 'center' }}>
{t('landing.faqCta.kicker')}
</p>
<h2 className="tl-display tl-closing__title">{t('landing.faqCta.title')}</h2>
<p className="tl-closing__sub">{t('landing.faqCta.subtitle')}</p>
<div className="tl-closing__ctas">
<RouterLink to="/faq" className="tl-btn tl-btn--ghost">
{t('landing.faqCta.openFaq')}
</RouterLink>
</div>
</div>
</section>
<footer className="tl-footer">
<div className="tl-container tl-footer__inner">
<span className="tl-display" style={{ fontWeight: 800, fontSize: '1.15rem' }}>
{PLATFORM_WORDMARK}
</span>
<div className="tl-footer__links">
<RouterLink to="/faq" className="tl-footer__link">
{t('landing.nav.faq')}
</RouterLink>
</div>
<span className="tl-footer__rights">{t('landing.footer.rights')}</span>
</div>
</footer>
</div>
);
}