maj url photo + page 404 + gestion programmation d'article
This commit is contained in:
@@ -19,10 +19,17 @@ export default async function AfroLifePage({ searchParams }: Props) {
|
||||
const filter = allowedFilters.includes(rawFilter) ? rawFilter : 'ALL';
|
||||
|
||||
let items: any[] = [];
|
||||
const now = new Date();
|
||||
|
||||
try {
|
||||
if (filter === 'EVENT') {
|
||||
const events = await prisma.event.findMany({
|
||||
where: {
|
||||
status: 'PUBLISHED',
|
||||
publishedAt: {
|
||||
lte: now
|
||||
}
|
||||
},
|
||||
orderBy: { date: 'desc' }
|
||||
});
|
||||
items = events.map(e => ({
|
||||
@@ -34,7 +41,12 @@ export default async function AfroLifePage({ searchParams }: Props) {
|
||||
duration: new Date(e.date).toLocaleDateString('fr-FR')
|
||||
}));
|
||||
} else {
|
||||
const where: any = {};
|
||||
const where: any = {
|
||||
status: 'PUBLISHED',
|
||||
publishedAt: {
|
||||
lte: now
|
||||
}
|
||||
};
|
||||
if (filter !== 'ALL') {
|
||||
where.type = filter as InterviewType;
|
||||
}
|
||||
@@ -47,6 +59,12 @@ export default async function AfroLifePage({ searchParams }: Props) {
|
||||
// If 'ALL', we might want to also fetch events and mix them
|
||||
if (filter === 'ALL') {
|
||||
const events = await prisma.event.findMany({
|
||||
where: {
|
||||
status: 'PUBLISHED',
|
||||
publishedAt: {
|
||||
lte: now
|
||||
}
|
||||
},
|
||||
orderBy: { date: 'desc' },
|
||||
take: 10
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user