correction V2 prisma

This commit is contained in:
2026-05-11 17:45:05 +02:00
parent 139d6991f5
commit cfc5f1ac02
4 changed files with 12 additions and 61 deletions

View File

@@ -1,31 +0,0 @@
"use client";
import { useEffect } from "react";
export default function Error({
error,
reset,
}: {
error: Error & { digest?: string };
reset: () => void;
}) {
useEffect(() => {
// Log the error to an error reporting service
console.error(error);
}, [error]);
return (
<div className="flex flex-col items-center justify-center min-h-[400px] p-6 text-center">
<h2 className="text-2xl font-bold mb-4">Un problème est survenu !</h2>
<p className="text-slate-600 mb-6 max-w-md">
Nous sommes désolés, mais une erreur inattendue s'est produite lors du chargement de cette page.
</p>
<button
className="px-6 py-2 bg-indigo-600 text-white rounded-lg hover:bg-indigo-700 transition-colors"
onClick={() => reset()}
>
Réessayer
</button>
</div>
);
}

View File

@@ -1,25 +0,0 @@
"use client";
export default function GlobalError({
error,
reset,
}: {
error: Error & { digest?: string };
reset: () => void;
}) {
return (
<html lang="fr">
<body>
<div style={{ padding: '2rem', textAlign: 'center', fontFamily: 'sans-serif' }}>
<h2>Une erreur critique est survenue !</h2>
<button
onClick={() => reset()}
style={{ padding: '0.5rem 1rem', marginTop: '1rem', cursor: 'pointer' }}
>
Réessayer
</button>
</div>
</body>
</html>
);
}

View File

@@ -1,4 +1,5 @@
import type { Metadata } from "next";
export const dynamic = 'force-dynamic';
import "./globals.css";

View File

@@ -1,18 +1,24 @@
import { PrismaClient } from '@prisma/client'
import { PrismaPg } from '@prisma/adapter-pg'
// Updated: 2026-05-10T17:21 (Forced reload for OneShotPlan model)
import pg from 'pg'
const connectionString = process.env.DATABASE_URL!
const globalForPrisma = globalThis as unknown as { prisma_v4: PrismaClient }
function makePrisma() {
const pool = new pg.Pool({ connectionString })
const connectionString = process.env.DATABASE_URL
if (!connectionString && process.env.NODE_ENV === 'production') {
// If we're in production build and DATABASE_URL is missing,
// we return a proxy or a dummy to avoid crashing the build worker
// if it just evaluates the module.
console.warn("DATABASE_URL is missing. Prisma Client might fail if called.");
}
const pool = new pg.Pool({ connectionString: connectionString || "" })
const adapter = new PrismaPg(pool)
return new PrismaClient({ adapter })
}
const globalForPrisma = globalThis as unknown as { prisma_v4: PrismaClient }
export const prisma = globalForPrisma.prisma_v4 || makePrisma()
if (process.env.NODE_ENV !== 'production') globalForPrisma.prisma_v4 = prisma