54 lines
1.5 KiB
TypeScript
54 lines
1.5 KiB
TypeScript
import { getServerSession } from 'next-auth';
|
|
import { authOptions } from '@/lib/auth';
|
|
import { prisma } from '@/lib/prisma';
|
|
import DashboardContent from '@/components/DashboardContent';
|
|
import DashboardSidebar from '@/components/DashboardSidebar';
|
|
|
|
export default async function DashboardPage() {
|
|
const session = await getServerSession(authOptions);
|
|
|
|
const stats = {
|
|
totalBookings: await prisma.booking.count(),
|
|
reservedBookings: await prisma.booking.count({
|
|
where: { status: 'RESERVED' },
|
|
}),
|
|
confirmedBookings: await prisma.booking.count({
|
|
where: { status: 'CONFIRMED' },
|
|
}),
|
|
completedBookings: await prisma.booking.count({
|
|
where: { status: 'COMPLETED' },
|
|
}),
|
|
totalLocations: await prisma.location.count(),
|
|
totalPhotoboxes: await prisma.photobox.count({
|
|
where: { active: true },
|
|
}),
|
|
totalDrivers: await prisma.user.count({
|
|
where: { role: 'DRIVER', active: true },
|
|
}),
|
|
};
|
|
|
|
const recentBookings = await prisma.booking.findMany({
|
|
take: 5,
|
|
orderBy: { createdAt: 'desc' },
|
|
include: {
|
|
location: true,
|
|
photobox: true,
|
|
},
|
|
});
|
|
|
|
return (
|
|
<div className="min-h-screen bg-gradient-to-br from-gray-900 via-gray-800 to-gray-900">
|
|
<div className="flex">
|
|
<DashboardSidebar user={session?.user} />
|
|
<main className="flex-1 p-8">
|
|
<DashboardContent
|
|
user={session?.user}
|
|
stats={stats}
|
|
recentBookings={recentBookings}
|
|
/>
|
|
</main>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|