This commit is contained in:
@@ -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({
|
||||
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 (
|
||||
<div className="bg-white min-h-screen">
|
||||
|
||||
@@ -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({
|
||||
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 (
|
||||
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-12">
|
||||
|
||||
@@ -1,12 +1,7 @@
|
||||
import { prisma } from './prisma';
|
||||
|
||||
export async function getSiteSettings() {
|
||||
try {
|
||||
const settings = await prisma.siteSetting.findUnique({
|
||||
where: { id: 'singleton' }
|
||||
});
|
||||
|
||||
// Default fallback values if not initialized
|
||||
// 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.",
|
||||
@@ -20,21 +15,18 @@ export async function getSiteSettings() {
|
||||
footerText: "© 2025 Afropreunariat. Tous droits réservés."
|
||||
};
|
||||
|
||||
try {
|
||||
const settings = await prisma.siteSetting.findUnique({
|
||||
where: { id: 'singleton' }
|
||||
});
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user