condition d'affichage reservé à l'admin

This commit is contained in:
Alexis SANOGO
2026-07-23 15:06:14 +02:00
parent 2f7b2d2b64
commit 1c68b2bc0d

View File

@@ -1,4 +1,5 @@
import { Link } from 'react-router-dom' import { Link } from 'react-router-dom'
import { useAuth} from '../context/AuthContext'
const sections = [ const sections = [
{ {
@@ -41,6 +42,11 @@ const sections = [
] ]
export default function Sitemap() { export default function Sitemap() {
const { user } = useAuth()
const isAdmin = user?.role === 'admin'
const visibleSections = sections.filter(
(section) => section.title !== 'Espaces professionnels' || isAdmin
)
return ( return (
<main className="bg-green-50 min-h-screen px-4 sm:px-6 py-10 sm:py-16"> <main className="bg-green-50 min-h-screen px-4 sm:px-6 py-10 sm:py-16">
<div className="max-w-4xl mx-auto"> <div className="max-w-4xl mx-auto">
@@ -55,7 +61,7 @@ export default function Sitemap() {
</div> </div>
<div className="grid sm:grid-cols-2 gap-6"> <div className="grid sm:grid-cols-2 gap-6">
{sections.map((section) => ( {visibleSections.map((section) => (
<div key={section.title} className="bg-white rounded-2xl shadow p-5 sm:p-6"> <div key={section.title} className="bg-white rounded-2xl shadow p-5 sm:p-6">
<h2 className="text-base sm:text-lg font-bold text-green-700 mb-4 pb-2 border-b border-gray-100"> <h2 className="text-base sm:text-lg font-bold text-green-700 mb-4 pb-2 border-b border-gray-100">
{section.title} {section.title}