additional features, refinement and more control over the app from admin side, better bookings UX
This commit is contained in:
+30
-2
@@ -1,5 +1,8 @@
|
||||
import { redirect } from 'next/navigation';
|
||||
import { getSession } from '@/lib/session';
|
||||
import { db } from '@/lib/db';
|
||||
import { users } from '@/lib/db/schema';
|
||||
import { eq } from 'drizzle-orm';
|
||||
import { DashboardHeader } from '@/components/dashboard/dashboard-header';
|
||||
import { EnhancedBookingCalendar } from '@/components/booking/enhanced-booking-calendar';
|
||||
import { UserBookingManagement } from '@/components/booking/user-booking-management';
|
||||
@@ -11,9 +14,32 @@ export default async function DashboardPage() {
|
||||
redirect('/login');
|
||||
}
|
||||
|
||||
// Get full user information
|
||||
const [user] = await db
|
||||
.select({
|
||||
id: users.id,
|
||||
email: users.email,
|
||||
name: users.name,
|
||||
surname: users.surname,
|
||||
role: users.role,
|
||||
})
|
||||
.from(users)
|
||||
.where(eq(users.id, session.userId))
|
||||
.limit(1);
|
||||
|
||||
if (!user) {
|
||||
redirect('/login');
|
||||
}
|
||||
|
||||
const userWithSession = {
|
||||
...session,
|
||||
name: user.name,
|
||||
surname: user.surname,
|
||||
};
|
||||
|
||||
return (
|
||||
<div className='min-h-screen bg-gradient-to-br from-blue-50 to-indigo-100'>
|
||||
<DashboardHeader user={session} />
|
||||
<DashboardHeader user={userWithSession} />
|
||||
|
||||
<main className='container mx-auto px-4 py-8'>
|
||||
<div className='grid gap-8 lg:grid-cols-3'>
|
||||
@@ -21,7 +47,9 @@ export default async function DashboardPage() {
|
||||
<div className='lg:col-span-2 space-y-6'>
|
||||
<div>
|
||||
<h1 className='text-3xl font-bold text-gray-900 mb-2'>
|
||||
Welcome back, {session.email.split('@')[0]}! 🏓
|
||||
Welcome back,{' '}
|
||||
{user.name && user.surname ? `${user.name} ${user.surname}` : user.email.split('@')[0]}!
|
||||
🏓
|
||||
</h1>
|
||||
<p className='text-gray-600'>Book your table tennis court and enjoy your game</p>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user