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:
46
scripts/migrate-isactive.ts
Normal file
46
scripts/migrate-isactive.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
import { PrismaPg } from '@prisma/adapter-pg';
|
||||
import pg from 'pg';
|
||||
import dotenv from 'dotenv';
|
||||
|
||||
dotenv.config({ path: '.env.local' });
|
||||
dotenv.config();
|
||||
|
||||
const connectionString = process.env.DATABASE_URL!;
|
||||
const pool = new pg.Pool({ connectionString });
|
||||
const adapter = new PrismaPg(pool);
|
||||
const prisma = new PrismaClient({ adapter });
|
||||
|
||||
async function migrate() {
|
||||
console.log('--- Starting isActive Migration ---');
|
||||
|
||||
const businesses = await prisma.business.findMany();
|
||||
console.log(`Found ${businesses.length} businesses to check.`);
|
||||
|
||||
let updatedCount = 0;
|
||||
|
||||
for (const biz of businesses) {
|
||||
const isNameOk = biz.name && biz.name !== "Nouvelle Entreprise";
|
||||
const isDescOk = biz.description && biz.description.length >= 20;
|
||||
const isLocOk = biz.location && biz.location !== "Ma Ville";
|
||||
const isEmailOk = !!biz.contactEmail;
|
||||
const isPhoneOk = !!biz.contactPhone;
|
||||
|
||||
const newIsActive = !!(isNameOk && isDescOk && isLocOk && isEmailOk && isPhoneOk);
|
||||
|
||||
if (biz.isActive !== newIsActive) {
|
||||
await prisma.business.update({
|
||||
where: { id: biz.id },
|
||||
data: { isActive: newIsActive }
|
||||
});
|
||||
console.log(`Updated "${biz.name}" (ID: ${biz.id}): isActive ${biz.isActive} -> ${newIsActive}`);
|
||||
updatedCount++;
|
||||
}
|
||||
}
|
||||
|
||||
console.log(`--- Migration Complete: ${updatedCount} records updated ---`);
|
||||
}
|
||||
|
||||
migrate()
|
||||
.catch(console.error)
|
||||
.finally(() => prisma.$disconnect());
|
||||
59
scripts/migrate-mock-to-db.ts
Normal file
59
scripts/migrate-mock-to-db.ts
Normal file
@@ -0,0 +1,59 @@
|
||||
import 'dotenv/config';
|
||||
import { prisma } from '../lib/prisma';
|
||||
import { MOCK_BLOG_POSTS, MOCK_INTERVIEWS } from '../lib/mockData';
|
||||
|
||||
async function main() {
|
||||
console.log('--- Migration des données Mock vers la DB ---');
|
||||
|
||||
// 1. Migration des BlogPosts
|
||||
console.log('Migration des BlogPosts...');
|
||||
for (const post of MOCK_BLOG_POSTS) {
|
||||
await prisma.blogPost.upsert({
|
||||
where: { id: post.id },
|
||||
update: {},
|
||||
create: {
|
||||
id: post.id,
|
||||
title: post.title,
|
||||
excerpt: post.excerpt,
|
||||
content: post.content,
|
||||
author: post.author,
|
||||
imageUrl: post.imageUrl,
|
||||
date: new Date(post.date)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 2. Migration des Interviews
|
||||
console.log('Migration des Interviews...');
|
||||
for (const interview of MOCK_INTERVIEWS) {
|
||||
await prisma.interview.upsert({
|
||||
where: { id: interview.id },
|
||||
update: {},
|
||||
create: {
|
||||
id: interview.id,
|
||||
title: interview.title,
|
||||
guestName: interview.guestName,
|
||||
companyName: interview.companyName,
|
||||
role: interview.role,
|
||||
type: interview.type,
|
||||
thumbnailUrl: interview.thumbnailUrl,
|
||||
videoUrl: interview.videoUrl,
|
||||
content: interview.content,
|
||||
excerpt: interview.excerpt,
|
||||
duration: interview.duration,
|
||||
date: new Date(interview.date)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
console.log('Migration terminée avec succès !');
|
||||
}
|
||||
|
||||
main()
|
||||
.catch((e) => {
|
||||
console.error(e);
|
||||
process.exit(1);
|
||||
})
|
||||
.finally(async () => {
|
||||
await prisma.$disconnect();
|
||||
});
|
||||
Reference in New Issue
Block a user