synchronisation du contenu avec la DB et amélioration du CMS

- Migration du blog et des interviews des données mockées vers PostgreSQL (Prisma).
- Refonte des pages publiques en Server Components pour de meilleures performances/SEO.
- Intégration d'un éditeur de texte riche (React Quill) avec titres H1-H6 et séparateurs.
- Correction des erreurs de validation Prisma liées aux paramètres asynchrones (Next.js 15+).
- Correction des problèmes d'affichage des modales de suspension via React Portals.
- Installation de @tailwindcss/typography et correction du débordement de texte (break-words).
- Implémentation des actions de modération (suspension/révocation) pour les utilisateurs et boutiques.
This commit is contained in:
2026-04-12 18:59:20 +02:00
parent b73939d381
commit 887030ee47
84 changed files with 5577 additions and 15128 deletions

View File

@@ -1,22 +1,24 @@
"use client";
import React, { useEffect } from 'react';
import React from 'react';
import Link from 'next/link';
import { useParams } from 'next/navigation';
import { notFound } from 'next/navigation';
import { ArrowLeft, Share2, Play, Calendar, User, Building2 } from 'lucide-react';
import { MOCK_INTERVIEWS } from '../../../lib/mockData';
import { InterviewType } from '../../../types';
import { prisma } from '../../../lib/prisma';
import { InterviewType } from '@prisma/client';
const InterviewDetailPage = () => {
const { id } = useParams();
const interview = MOCK_INTERVIEWS.find(i => i.id === id);
interface Props {
params: Promise<{ id: string }>;
}
useEffect(() => {
window.scrollTo(0, 0);
}, [id]);
export default async function InterviewDetailPage({ params }: Props) {
const { id } = await params;
const interview = await prisma.interview.findUnique({
where: { id }
});
if (!interview) return null;
if (!interview) {
notFound();
}
// Helper to get YouTube embed URL
const getEmbedUrl = (url: string) => {
@@ -56,7 +58,7 @@ const InterviewDetailPage = () => {
</div>
<div className="flex items-center">
<Calendar className="w-4 h-4 mr-2 text-brand-500" />
{interview.date}
{new Date(interview.date).toLocaleDateString('fr-FR', { day: 'numeric', month: 'long', year: 'numeric' })}
</div>
</div>
</div>
@@ -73,7 +75,7 @@ const InterviewDetailPage = () => {
className="w-full h-full"
></iframe>
) : (
<div className="w-full h-full flex items-center justify-center bg-gray-900">
<div className="w-full h-full flex items-center justify-center bg-gray-900 min-h-[300px]">
<p className="text-white">Vidéo non disponible</p>
</div>
)}
@@ -86,11 +88,9 @@ const InterviewDetailPage = () => {
)}
{/* Description / Article Content */}
<div className="prose prose-lg prose-orange max-w-none mx-auto text-gray-600">
<div className="prose prose-lg prose-orange max-w-none mx-auto text-gray-600 break-words overflow-hidden">
{!isVideo && interview.content ? (
interview.content.split('\n').map((paragraph, idx) => (
<p key={idx}>{paragraph}</p>
))
<div dangerouslySetInnerHTML={{ __html: interview.content }} />
) : (
<p className="text-xl font-serif italic text-gray-500 border-l-4 border-brand-500 pl-6 py-2">
{interview.excerpt}
@@ -108,6 +108,5 @@ const InterviewDetailPage = () => {
</div>
</div>
);
};
}
export default InterviewDetailPage;

View File

@@ -1,18 +1,27 @@
"use client";
import React, { useState } from 'react';
import React from 'react';
import Link from 'next/link';
import { Play, FileText, Clock, Mic } from 'lucide-react';
import { MOCK_INTERVIEWS } from '../../lib/mockData';
import { InterviewType } from '../../types';
import { prisma } from '../../lib/prisma';
import { InterviewType } from '@prisma/client';
const AfroLifePage = () => {
const [filter, setFilter] = useState<'ALL' | 'VIDEO' | 'ARTICLE'>('ALL');
export const revalidate = 3600;
const filteredInterviews = MOCK_INTERVIEWS.filter(interview => {
if (filter === 'ALL') return true;
return interview.type === filter;
interface Props {
searchParams: Promise<{ type?: string }>;
}
export default async function AfroLifePage({ searchParams }: Props) {
const params = await searchParams;
const filter = params.type as InterviewType | 'ALL' || 'ALL';
const where: any = {};
if (filter !== 'ALL') {
where.type = filter;
}
const interviews = await prisma.interview.findMany({
where,
orderBy: { createdAt: 'desc' }
});
return (
@@ -34,77 +43,81 @@ const AfroLifePage = () => {
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-12">
{/* Filters */}
<div className="flex justify-center mb-12 space-x-4">
<button
onClick={() => setFilter('ALL')}
<Link
href="/afrolife?type=ALL"
className={`px-6 py-2 rounded-full text-sm font-medium transition-all ${filter === 'ALL' ? 'bg-brand-600 text-white shadow-md' : 'bg-gray-100 text-gray-600 hover:bg-gray-200'}`}
>
Tout voir
</button>
<button
onClick={() => setFilter('VIDEO')}
</Link>
<Link
href="/afrolife?type=VIDEO"
className={`flex items-center px-6 py-2 rounded-full text-sm font-medium transition-all ${filter === 'VIDEO' ? 'bg-brand-600 text-white shadow-md' : 'bg-gray-100 text-gray-600 hover:bg-gray-200'}`}
>
<Play className="w-4 h-4 mr-2" /> Vidéos
</button>
<button
onClick={() => setFilter('ARTICLE')}
</Link>
<Link
href="/afrolife?type=ARTICLE"
className={`flex items-center px-6 py-2 rounded-full text-sm font-medium transition-all ${filter === 'ARTICLE' ? 'bg-brand-600 text-white shadow-md' : 'bg-gray-100 text-gray-600 hover:bg-gray-200'}`}
>
<FileText className="w-4 h-4 mr-2" /> Articles
</button>
</Link>
</div>
{/* Grid */}
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8">
{filteredInterviews.map(interview => (
<Link href={`/afrolife/${interview.id}`} key={interview.id} className="group block h-full">
<div className="relative h-64 rounded-xl overflow-hidden shadow-sm group-hover:shadow-xl transition-all duration-300">
<img
src={interview.thumbnailUrl}
alt={interview.title}
className="w-full h-full object-cover group-hover:scale-105 transition-transform duration-700"
/>
<div className="absolute inset-0 bg-black/20 group-hover:bg-black/10 transition-colors"></div>
{/* Type Badge */}
<div className="absolute top-4 left-4">
<span className={`inline-flex items-center px-3 py-1 rounded-full text-xs font-bold uppercase tracking-wide text-white backdrop-blur-md ${interview.type === InterviewType.VIDEO ? 'bg-red-600/90' : 'bg-blue-600/90'}`}>
{interview.type === InterviewType.VIDEO ? <Play className="w-3 h-3 mr-1 fill-current" /> : <Mic className="w-3 h-3 mr-1" />}
{interview.type === InterviewType.VIDEO ? 'Vidéo' : 'Interview'}
</span>
</div>
{/* Play Icon Overlay for Videos */}
{interview.type === InterviewType.VIDEO && (
<div className="absolute inset-0 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity duration-300">
<div className="w-16 h-16 bg-white/30 backdrop-blur-sm rounded-full flex items-center justify-center border border-white/50">
<Play className="w-8 h-8 text-white fill-current ml-1" />
</div>
</div>
)}
</div>
<div className="pt-6 px-2">
<div className="flex items-center text-xs text-gray-500 mb-3 space-x-3">
<span className="font-semibold text-brand-600 uppercase">{interview.guestName}</span>
<span className="w-1 h-1 bg-gray-300 rounded-full"></span>
<span>{interview.companyName}</span>
<span className="w-1 h-1 bg-gray-300 rounded-full"></span>
<span className="flex items-center"><Clock className="w-3 h-3 mr-1"/> {interview.duration}</span>
</div>
<h3 className="text-xl font-serif font-bold text-gray-900 mb-2 group-hover:text-brand-600 transition-colors leading-tight">
{interview.title}
</h3>
<p className="text-gray-600 text-sm line-clamp-2">
{interview.excerpt}
</p>
</div>
</Link>
))}
</div>
{interviews.length === 0 ? (
<div className="text-center py-20 bg-gray-50 rounded-2xl border-2 border-dashed border-gray-200">
<p className="text-gray-500">Aucune interview trouvée dans cette catégorie.</p>
</div>
) : (
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8">
{interviews.map(interview => (
<Link href={`/afrolife/${interview.id}`} key={interview.id} className="group block h-full">
<div className="relative h-64 rounded-xl overflow-hidden shadow-sm group-hover:shadow-xl transition-all duration-300">
<img
src={interview.thumbnailUrl}
alt={interview.title}
className="w-full h-full object-cover group-hover:scale-105 transition-transform duration-700"
/>
<div className="absolute inset-0 bg-black/20 group-hover:bg-black/10 transition-colors"></div>
{/* Type Badge */}
<div className="absolute top-4 left-4">
<span className={`inline-flex items-center px-3 py-1 rounded-full text-xs font-bold uppercase tracking-wide text-white backdrop-blur-md ${interview.type === InterviewType.VIDEO ? 'bg-red-600/90' : 'bg-blue-600/90'}`}>
{interview.type === InterviewType.VIDEO ? <Play className="w-3 h-3 mr-1 fill-current" /> : <Mic className="w-3 h-3 mr-1" />}
{interview.type === InterviewType.VIDEO ? 'Vidéo' : 'Interview'}
</span>
</div>
{/* Play Icon Overlay for Videos */}
{interview.type === InterviewType.VIDEO && (
<div className="absolute inset-0 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity duration-300">
<div className="w-16 h-16 bg-white/30 backdrop-blur-sm rounded-full flex items-center justify-center border border-white/50">
<Play className="w-8 h-8 text-white fill-current ml-1" />
</div>
</div>
)}
</div>
<div className="pt-6 px-2">
<div className="flex items-center text-xs text-gray-500 mb-3 space-x-3">
<span className="font-semibold text-brand-600 uppercase">{interview.guestName}</span>
<span className="w-1 h-1 bg-gray-300 rounded-full"></span>
<span>{interview.companyName}</span>
<span className="w-1 h-1 bg-gray-300 rounded-full"></span>
<span className="flex items-center"><Clock className="w-3 h-3 mr-1"/> {interview.duration || 'N/A'}</span>
</div>
<h3 className="text-xl font-serif font-bold text-gray-900 mb-2 group-hover:text-brand-600 transition-colors leading-tight line-clamp-2">
{interview.title}
</h3>
<p className="text-gray-600 text-sm line-clamp-2">
{interview.excerpt}
</p>
</div>
</Link>
))}
</div>
)}
</div>
</div>
);
};
export default AfroLifePage;
}