Correction de redirection

This commit is contained in:
Alexis SANOGO
2026-07-23 14:08:04 +02:00
parent 4f0593bc38
commit 2f7b2d2b64
3 changed files with 66 additions and 41 deletions

View File

@@ -1,6 +1,20 @@
import { Link } from 'react-router-dom'
import { Link, useLocation } from 'react-router-dom'
import { useAuth } from '../context/AuthContext'
export default function Footer() {
const { pathname } = useLocation()
const { user } = useAuth()
const isLoggedIn = !!user
function FooterLink({ to, children, className=''}) {
return pathname === to ? (
<span className={className}>{children}</span>
) : (
<Link to={to} className={className}>
{children}
</Link>
)
}
return (
<footer className="bg-green-900 text-white">
@@ -11,13 +25,11 @@ export default function Footer() {
{/* Logo */}
<div>
<Link to="/accueil">
<FooterLink to='/accueil'>
<h3 className="text-xl font-bold mb-3">
Thé Tip Top
</h3>
</Link>
</FooterLink>
<p className="text-green-100 text-sm leading-relaxed">
Participez au jeu-concours Thé Tip Top et tentez de gagner
@@ -39,43 +51,44 @@ export default function Footer() {
<ul className="space-y-3 text-green-100">
<li>
<Link
<FooterLink
to="/accueil"
className="hover:text-white transition"
>
Accueil
</Link>
</FooterLink>
</li>
<li>
<Link
<FooterLink
to="/regles-jeu"
className="hover:text-white transition"
>
Règles du jeu
</Link>
</FooterLink>
</li>
<li>
<Link
<FooterLink
to="/saisir-code-unique"
className="hover:text-white transition"
>
Tester mon code
</Link>
</FooterLink>
</li>
{ !isLoggedIn && (
<li>
<Link
<FooterLink
to="/inscription"
className="hover:text-white transition"
>
Créer un compte
</Link>
</FooterLink>
</li>
)}
</ul>
@@ -95,41 +108,41 @@ export default function Footer() {
<ul className="space-y-3 text-green-100">
<li>
<Link
<FooterLink
to="/mentions-legales"
className="hover:text-white transition"
>
Mentions légales
</Link>
</FooterLink>
</li>
<li>
<Link
<FooterLink
to="/confidentialite"
className="hover:text-white transition"
>
Politique de confidentialité
</Link>
</FooterLink>
</li>
<li>
<Link
<FooterLink
to="/contact"
className="hover:text-white transition"
>
Contact
</Link>
</FooterLink>
</li>
<li>
<Link
<FooterLink
to="/sitemap"
className="hover:text-white transition"
>
Plan du site
</Link>
</FooterLink>
</li>
</ul>

View File

@@ -9,6 +9,7 @@ export default function Header() {
const navigate = useNavigate()
const { user, logout } = useAuth()
const isLoggedIn = !!user
const logoContent = <img src={logo} alt="Logo de Thé Tip Top" className="h-10 sm:h-12 w-auto" />
const handleLogout = () => {
logout()
@@ -28,10 +29,15 @@ export default function Header() {
return (
<header className="bg-white shadow-sm relative z-50">
<div className="max-w-7xl mx-auto px-4 sm:px-6 py-4 flex items-center justify-between">
<Link to={isLoggedIn ? '/mes-gains' : '/accueil'} className="flex items-center flex-shrink-0">
<img src={logo} alt="Thé Tip Top" className="h-10 sm:h-12 w-auto" />
{pathname === '/accueil' ? (
<span className="flex items-center flex-shrink-0">
{logoContent}
</span>
) : (
<Link to ={'/accueil'} className='flex items-center flex-shrink-0'>
{logoContent}
</Link>
)}
{/* Nav desktop */}
<nav className="hidden md:flex items-center gap-6">
@@ -49,7 +55,7 @@ export default function Header() {
{isLoggedIn ? (
<div className="flex items-center gap-3">
<Link to="/mes-gains" className="flex items-center gap-2 text-sm text-gray-700 hover:text-green-700 font-medium transition-colors">
<Link to="/profile" className="flex items-center gap-2 text-sm text-gray-700 hover:text-green-700 font-medium transition-colors">
<div className="w-8 h-8 rounded-full bg-[#006B6B] flex items-center justify-center text-white text-xs font-bold">
{initials}
</div>

View File

@@ -1,6 +1,10 @@
import { Link } from 'react-router-dom'
import { useAuth } from '../context/AuthContext'
export default function ReglesJeu() {
const { user } = useAuth()
const isLoggedIn = !!user
return (
<div className="bg-green-50 min-h-screen">
@@ -79,12 +83,14 @@ export default function ReglesJeu() {
Inscrivez-vous, entrez votre code de ticket et retirez votre lot en magasin ou en ligne.
</p>
<div className="flex flex-col sm:flex-row justify-center gap-3 sm:gap-4">
{!isLoggedIn && (
<Link
to="/inscription"
className="bg-white text-green-700 px-6 sm:px-8 py-3 rounded-xl font-semibold hover:bg-green-50 text-sm sm:text-base"
>
Inscrivez-vous
</Link>
)}
<Link
to="/saisir-code-unique"
className="border border-white px-6 sm:px-8 py-3 rounded-xl font-semibold hover:bg-green-800 text-sm sm:text-base"