import { Suspense } from 'react'; import Link from 'next/link'; import { auth } from '@/lib/auth'; import { getSessionsByUserId } from '@/services/sessions'; import { getMotivatorSessionsByUserId } from '@/services/moving-motivators'; import { getYearReviewSessionsByUserId } from '@/services/year-review'; import { getWeeklyCheckInSessionsByUserId } from '@/services/weekly-checkin'; import { getWeatherSessionsByUserId } from '@/services/weather'; import { Card, Button } from '@/components/ui'; import { WorkshopTabs } from './WorkshopTabs'; function WorkshopTabsSkeleton() { return (
{/* Tabs skeleton */}
{[...Array(4)].map((_, i) => (
))}
{/* Cards skeleton */}
{[...Array(6)].map((_, i) => (
))}
); } export default async function SessionsPage() { const session = await auth(); if (!session?.user?.id) { return null; } // Fetch SWOT, Moving Motivators, Year Review, Weekly Check-in, and Weather sessions const [swotSessions, motivatorSessions, yearReviewSessions, weeklyCheckInSessions, weatherSessions] = await Promise.all([ getSessionsByUserId(session.user.id), getMotivatorSessionsByUserId(session.user.id), getYearReviewSessionsByUserId(session.user.id), getWeeklyCheckInSessionsByUserId(session.user.id), getWeatherSessionsByUserId(session.user.id), ]); // Add type to each session for unified display const allSwotSessions = swotSessions.map((s) => ({ ...s, workshopType: 'swot' as const, })); const allMotivatorSessions = motivatorSessions.map((s) => ({ ...s, workshopType: 'motivators' as const, })); const allYearReviewSessions = yearReviewSessions.map((s) => ({ ...s, workshopType: 'year-review' as const, })); const allWeeklyCheckInSessions = weeklyCheckInSessions.map((s) => ({ ...s, workshopType: 'weekly-checkin' as const, })); const allWeatherSessions = weatherSessions.map((s) => ({ ...s, workshopType: 'weather' as const, })); // Combine and sort by updatedAt const allSessions = [ ...allSwotSessions, ...allMotivatorSessions, ...allYearReviewSessions, ...allWeeklyCheckInSessions, ...allWeatherSessions, ].sort((a, b) => new Date(b.updatedAt).getTime() - new Date(a.updatedAt).getTime()); const hasNoSessions = allSessions.length === 0; return (
{/* Header */}

Mes Ateliers

Tous vos ateliers en un seul endroit

{/* Content */} {hasNoSessions ? (
🚀

Commencez votre premier atelier

Créez un atelier SWOT pour analyser les forces et faiblesses, un Moving Motivators pour découvrir les motivations, un Year Review pour faire le bilan de l'année, ou un Weekly Check-in pour le suivi hebdomadaire.

) : ( }> )}
); }