diff --git a/app/afrolife/page.tsx b/app/afrolife/page.tsx index 84a5d20..39cb3ec 100644 --- a/app/afrolife/page.tsx +++ b/app/afrolife/page.tsx @@ -3,6 +3,7 @@ import Link from 'next/link'; import { Play, FileText, Clock, Mic } from 'lucide-react'; import { prisma } from '../../lib/prisma'; import { InterviewType } from '@prisma/client'; +import { MOCK_INTERVIEWS } from '../../lib/mockData'; export const revalidate = 3600; @@ -19,10 +20,20 @@ export default async function AfroLifePage({ searchParams }: Props) { where.type = filter; } - const interviews = await prisma.interview.findMany({ - where, - orderBy: { createdAt: 'desc' } - }); + let interviews: any[] = []; + + try { + interviews = await prisma.interview.findMany({ + where, + orderBy: { createdAt: 'desc' } + }); + } catch (error) { + console.error("Database connection failed on Afro Life page, using mock data."); + interviews = MOCK_INTERVIEWS.filter(i => filter === 'ALL' || i.type === filter).map(i => ({ + ...i, + createdAt: new Date(i.date), + })); + } return (
diff --git a/app/blog/page.tsx b/app/blog/page.tsx index b9dc09e..89ba6aa 100644 --- a/app/blog/page.tsx +++ b/app/blog/page.tsx @@ -2,13 +2,24 @@ import React from 'react'; import Link from 'next/link'; import { ArrowRight } from 'lucide-react'; import { prisma } from '../../lib/prisma'; +import { MOCK_BLOG_POSTS } from '../../lib/mockData'; export const revalidate = 3600; // Revalidate every hour export default async function BlogPage() { - const posts = await prisma.blogPost.findMany({ - orderBy: { createdAt: 'desc' } - }); + let posts: any[] = []; + + try { + posts = await prisma.blogPost.findMany({ + orderBy: { createdAt: 'desc' } + }); + } catch (error) { + console.error("Database connection failed on blog page, using mock data."); + posts = MOCK_BLOG_POSTS.map(p => ({ + ...p, + createdAt: new Date(p.date), // Map mock date to createdAt to satisfy frontend + })); + } return (
diff --git a/lib/settings.ts b/lib/settings.ts index f851c52..5caffcb 100644 --- a/lib/settings.ts +++ b/lib/settings.ts @@ -1,40 +1,32 @@ import { prisma } from './prisma'; export async function getSiteSettings() { + // Default fallback values used during build or if DB is down + const defaultSettings = { + siteName: "Afropreunariat", + siteSlogan: "La plateforme de référence pour l'entrepreneuriat africain. Visibilité, connexion et croissance pour les TPE/PME.", + contactEmail: "support@afropreunariat.com", + contactPhone: "+225 00 00 00 00 00", + address: "Abidjan, Côte d'Ivoire / Paris, France", + facebookUrl: "#", + twitterUrl: "#", + instagramUrl: "#", + linkedinUrl: "#", + footerText: "© 2025 Afropreunariat. Tous droits réservés." + }; + try { const settings = await prisma.siteSetting.findUnique({ where: { id: 'singleton' } }); - // Default fallback values if not initialized - const defaultSettings = { - siteName: "Afropreunariat", - siteSlogan: "La plateforme de référence pour l'entrepreneuriat africain. Visibilité, connexion et croissance pour les TPE/PME.", - contactEmail: "support@afropreunariat.com", - contactPhone: "+225 00 00 00 00 00", - address: "Abidjan, Côte d'Ivoire / Paris, France", - facebookUrl: "#", - twitterUrl: "#", - instagramUrl: "#", - linkedinUrl: "#", - footerText: "© 2025 Afropreunariat. Tous droits réservés." - }; - if (!settings) return defaultSettings; return settings; } catch (error) { - console.error("Failed to fetch site settings:", error); - return { - siteName: "Afropreunariat", - siteSlogan: "La plateforme de référence pour l'entrepreneuriat africain.", - contactEmail: "support@afropreunariat.com", - contactPhone: "", - address: "", - facebookUrl: "#", - twitterUrl: "#", - instagramUrl: "#", - linkedinUrl: "#", - footerText: "© 2025 Afropreunariat. Tous droits réservés." - }; + // Silently log only if not in build phase to keep CI logs clean + if (process.env.NEXT_PHASE !== 'phase-production-build') { + console.error("Database connection failed, using default site settings."); + } + return defaultSettings; } }