fixes, theming, branding

This commit is contained in:
mikicvi
2025-09-26 22:16:34 +01:00
parent 22c462c61c
commit 220f999f19
24 changed files with 787 additions and 260 deletions
+6 -4
View File
@@ -4,7 +4,7 @@ import { announcements } from '@/lib/db/schema';
import { eq } from 'drizzle-orm';
import { getSession } from '@/lib/session';
export async function PUT(request: NextRequest, { params }: { params: { id: string } }) {
export async function PUT(request: NextRequest, context: { params: Promise<{ id: string }> }) {
try {
const session = await getSession();
if (!session || session.role !== 'admin') {
@@ -12,7 +12,8 @@ export async function PUT(request: NextRequest, { params }: { params: { id: stri
}
const { title, content, priority, expiresAt, isActive } = await request.json();
const announcementId = params.id;
const { id } = await context.params;
const announcementId = id;
if (!title || !content) {
return NextResponse.json({ error: 'Title and content are required' }, { status: 400 });
@@ -49,14 +50,15 @@ export async function PUT(request: NextRequest, { params }: { params: { id: stri
}
}
export async function DELETE(request: NextRequest, { params }: { params: { id: string } }) {
export async function DELETE(request: NextRequest, context: { params: Promise<{ id: string }> }) {
try {
const session = await getSession();
if (!session || session.role !== 'admin') {
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
}
const announcementId = params.id;
const { id } = await context.params;
const announcementId = id;
// Check if announcement exists
const existing = await db.select().from(announcements).where(eq(announcements.id, announcementId)).limit(1);
+6 -4
View File
@@ -4,7 +4,7 @@ import { courts } from '@/lib/db/schema';
import { eq } from 'drizzle-orm';
import { getSession } from '@/lib/session';
export async function PUT(request: NextRequest, { params }: { params: { id: string } }) {
export async function PUT(request: NextRequest, context: { params: Promise<{ id: string }> }) {
try {
const session = await getSession();
if (!session || session.role !== 'admin') {
@@ -12,7 +12,8 @@ export async function PUT(request: NextRequest, { params }: { params: { id: stri
}
const { name, isActive } = await request.json();
const courtId = params.id;
const { id } = await context.params;
const courtId = id;
if (!name) {
return NextResponse.json({ error: 'Court name is required' }, { status: 400 });
@@ -46,14 +47,15 @@ export async function PUT(request: NextRequest, { params }: { params: { id: stri
}
}
export async function DELETE(request: NextRequest, { params }: { params: { id: string } }) {
export async function DELETE(request: NextRequest, context: { params: Promise<{ id: string }> }) {
try {
const session = await getSession();
if (!session || session.role !== 'admin') {
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
}
const courtId = params.id;
const { id } = await context.params;
const courtId = id;
// Check if court exists
const existing = await db.select().from(courts).where(eq(courts.id, courtId)).limit(1);
+4
View File
@@ -3,6 +3,7 @@ import { db } from '@/lib/db';
import { settings } from '@/lib/db/schema';
import { eq } from 'drizzle-orm';
import { getSession } from '@/lib/session';
import { invalidateAppConfigCache } from '@/lib/app-config';
export async function GET(request: NextRequest) {
try {
@@ -70,6 +71,9 @@ export async function PUT(request: NextRequest) {
await Promise.all(updatePromises);
// Invalidate app config cache since settings changed
invalidateAppConfigCache();
return NextResponse.json({ message: 'Settings updated successfully' });
} catch (error) {
console.error('Error updating settings:', error);
+6 -4
View File
@@ -5,7 +5,7 @@ import { eq } from 'drizzle-orm';
import { getSession } from '@/lib/session';
import bcrypt from 'bcryptjs';
export async function PUT(request: NextRequest, { params }: { params: { id: string } }) {
export async function PUT(request: NextRequest, context: { params: Promise<{ id: string }> }) {
try {
const session = await getSession();
if (!session || session.role !== 'admin') {
@@ -13,7 +13,8 @@ export async function PUT(request: NextRequest, { params }: { params: { id: stri
}
const { name, surname, email, role, password } = await request.json();
const userId = params.id;
const { id } = await context.params;
const userId = id;
if (!name || !surname || !email) {
return NextResponse.json({ error: 'Missing required fields' }, { status: 400 });
@@ -58,14 +59,15 @@ export async function PUT(request: NextRequest, { params }: { params: { id: stri
}
}
export async function DELETE(request: NextRequest, { params }: { params: { id: string } }) {
export async function DELETE(request: NextRequest, context: { params: Promise<{ id: string }> }) {
try {
const session = await getSession();
if (!session || session.role !== 'admin') {
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
}
const userId = params.id;
const { id } = await context.params;
const userId = id;
// Prevent admin from deleting themselves
if (session.userId === userId) {
+6 -4
View File
@@ -5,7 +5,7 @@ import { bookings, settings } from '@/lib/db/schema';
import { eq, and } from 'drizzle-orm';
import { logActivity, ACTIONS, ENTITY_TYPES } from '@/lib/activity-logger';
export async function PATCH(request: NextRequest, { params }: { params: { id: string } }) {
export async function PATCH(request: NextRequest, context: { params: Promise<{ id: string }> }) {
try {
const session = await getSession();
if (!session) {
@@ -13,7 +13,8 @@ export async function PATCH(request: NextRequest, { params }: { params: { id: st
}
const { notes } = await request.json();
const bookingId = params.id;
const { id } = await context.params;
const bookingId = id;
// Check if booking exists and belongs to user
const existingBooking = await db
@@ -98,14 +99,15 @@ export async function PATCH(request: NextRequest, { params }: { params: { id: st
}
}
export async function DELETE(request: NextRequest, { params }: { params: { id: string } }) {
export async function DELETE(request: NextRequest, context: { params: Promise<{ id: string }> }) {
try {
const session = await getSession();
if (!session) {
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
}
const bookingId = params.id;
const { id } = await context.params;
const bookingId = id;
// Check if booking exists and belongs to user
const existingBooking = await db
+6 -2
View File
@@ -1,7 +1,7 @@
import { NextRequest, NextResponse } from 'next/server';
import { db } from '@/lib/db';
import { bookings, courts, timeSlots, settings, metrics } from '@/lib/db/schema';
import { eq, and } from 'drizzle-orm';
import { eq, and, gte, asc } from 'drizzle-orm';
import { getSession } from '@/lib/session';
import { logActivity, ACTIONS, ENTITY_TYPES } from '@/lib/activity-logger';
@@ -12,6 +12,9 @@ export async function GET(request: NextRequest) {
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
}
// Get today's date to filter out past bookings
const today = new Date().toISOString().split('T')[0];
const userBookings = await db
.select({
id: bookings.id,
@@ -29,7 +32,8 @@ export async function GET(request: NextRequest) {
})
.from(bookings)
.innerJoin(courts, eq(bookings.courtId, courts.id))
.where(eq(bookings.userId, session.userId));
.where(and(eq(bookings.userId, session.userId), eq(bookings.status, 'active'), gte(bookings.date, today)))
.orderBy(asc(bookings.date), asc(bookings.startTime));
return NextResponse.json({ bookings: userBookings });
} catch (error) {
+12
View File
@@ -0,0 +1,12 @@
import { NextResponse } from 'next/server';
import { getAppConfig } from '@/lib/app-config';
export async function GET() {
try {
const config = await getAppConfig();
return NextResponse.json(config);
} catch (error) {
console.error('Error fetching app config:', error);
return NextResponse.json({ error: 'Internal server error' }, { status: 500 });
}
}
+6 -2
View File
@@ -6,8 +6,10 @@ 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';
import { getAppConfig } from '@/lib/app-config';
export default async function DashboardPage() {
const config = await getAppConfig();
const session = await getSession();
if (!session) {
@@ -38,7 +40,7 @@ export default async function DashboardPage() {
};
return (
<div className='min-h-screen bg-gradient-to-br from-blue-50 to-indigo-100 dark:from-gray-900 dark:to-gray-800'>
<div className='min-h-screen bg-background'>
<DashboardHeader user={userWithSession} />
<main className='container mx-auto px-4 py-8'>
@@ -51,7 +53,9 @@ export default async function DashboardPage() {
{user.name && user.surname ? `${user.name} ${user.surname}` : user.email.split('@')[0]}!
🏓
</h1>
<p className='text-muted-foreground'>Book your table tennis court and enjoy your game</p>
<p className='text-muted-foreground'>
Book your {config.sportName.toLowerCase()} court and enjoy your game
</p>
</div>
<EnhancedBookingCalendar />
+90 -55
View File
@@ -4,65 +4,99 @@
@layer base {
:root {
--background: 0 0% 100%;
--foreground: 222.2 84% 4.9%;
--card: 0 0% 100%;
--card-foreground: 222.2 84% 4.9%;
--popover: 0 0% 100%;
--popover-foreground: 222.2 84% 4.9%;
--primary: 222.2 47.4% 11.2%;
--primary-foreground: 210 40% 98%;
--secondary: 210 40% 96%;
--secondary-foreground: 222.2 84% 4.9%;
--muted: 210 40% 96%;
--muted-foreground: 215.4 16.3% 46.9%;
--accent: 210 40% 96%;
--accent-foreground: 222.2 84% 4.9%;
--destructive: 0 84.2% 60.2%;
--destructive-foreground: 210 40% 98%;
--border: 214.3 31.8% 91.4%;
--input: 214.3 31.8% 91.4%;
--ring: 222.2 84% 4.9%;
--background: 0 0% 98.8235%;
--foreground: 0 0% 9.0196%;
--card: 0 0% 98.8235%;
--card-foreground: 0 0% 9.0196%;
--popover: 0 0% 98.8235%;
--popover-foreground: 0 0% 32.1569%;
--primary: 151.3274 66.8639% 66.8627%;
--primary-foreground: 153.3333 13.0435% 13.5294%;
--secondary: 0 0% 99.2157%;
--secondary-foreground: 0 0% 9.0196%;
--muted: 0 0% 92.9412%;
--muted-foreground: 0 0% 12.549%;
--accent: 0 0% 92.9412%;
--accent-foreground: 0 0% 12.549%;
--destructive: 9.8901 81.982% 43.5294%;
--destructive-foreground: 0 100% 99.4118%;
--border: 0 0% 87.451%;
--input: 0 0% 96.4706%;
--ring: 151.3274 66.8639% 66.8627%;
--chart-1: 151.3274 66.8639% 66.8627%;
--chart-2: 217.2193 91.2195% 59.8039%;
--chart-3: 258.3117 89.5349% 66.2745%;
--chart-4: 37.6923 92.126% 50.1961%;
--chart-5: 160.1183 84.0796% 39.4118%;
--sidebar: 0 0% 98.8235%;
--sidebar-foreground: 0 0% 43.9216%;
--sidebar-primary: 151.3274 66.8639% 66.8627%;
--sidebar-primary-foreground: 153.3333 13.0435% 13.5294%;
--sidebar-accent: 0 0% 92.9412%;
--sidebar-accent-foreground: 0 0% 12.549%;
--sidebar-border: 0 0% 87.451%;
--sidebar-ring: 151.3274 66.8639% 66.8627%;
--font-sans: Outfit, sans-serif;
--font-serif: ui-serif, Georgia, Cambria, 'Times New Roman', Times, serif;
--font-mono: monospace;
--radius: 0.5rem;
--shadow-2xs: 0px 1px 3px 0px hsl(0 0% 0% / 0.09);
--shadow-xs: 0px 1px 3px 0px hsl(0 0% 0% / 0.09);
--shadow-sm: 0px 1px 3px 0px hsl(0 0% 0% / 0.17), 0px 1px 2px -1px hsl(0 0% 0% / 0.17);
--shadow: 0px 1px 3px 0px hsl(0 0% 0% / 0.17), 0px 1px 2px -1px hsl(0 0% 0% / 0.17);
--shadow-md: 0px 1px 3px 0px hsl(0 0% 0% / 0.17), 0px 2px 4px -1px hsl(0 0% 0% / 0.17);
--shadow-lg: 0px 1px 3px 0px hsl(0 0% 0% / 0.17), 0px 4px 6px -1px hsl(0 0% 0% / 0.17);
--shadow-xl: 0px 1px 3px 0px hsl(0 0% 0% / 0.17), 0px 8px 10px -1px hsl(0 0% 0% / 0.17);
--shadow-2xl: 0px 1px 3px 0px hsl(0 0% 0% / 0.43);
--tracking-normal: 0.025em;
--spacing: 0.25rem;
}
.dark {
--background: 222.2 84% 4.9%;
--foreground: 210 40% 98%;
--card: 222.2 84% 4.9%;
--card-foreground: 210 40% 98%;
--popover: 222.2 84% 4.9%;
--popover-foreground: 210 40% 98%;
--primary: 210 40% 98%;
--primary-foreground: 222.2 47.4% 11.2%;
--secondary: 217.2 32.6% 17.5%;
--secondary-foreground: 210 40% 98%;
--muted: 217.2 32.6% 17.5%;
--muted-foreground: 215 20.2% 65.1%;
--accent: 217.2 32.6% 17.5%;
--accent-foreground: 210 40% 98%;
--destructive: 0 62.8% 30.6%;
--destructive-foreground: 210 40% 98%;
--border: 217.2 32.6% 17.5%;
--input: 217.2 32.6% 17.5%;
--ring: 212.7 26.8% 83.9%;
--background: 0 0% 7.0588%;
--foreground: 214.2857 31.8182% 91.3725%;
--card: 0 0% 9.0196%;
--card-foreground: 214.2857 31.8182% 91.3725%;
--popover: 0 0% 14.1176%;
--popover-foreground: 0 0% 66.2745%;
--primary: 154.898 100% 19.2157%;
--primary-foreground: 152.7273 19.2982% 88.8235%;
--secondary: 0 0% 14.1176%;
--secondary-foreground: 0 0% 98.0392%;
--muted: 0 0% 12.1569%;
--muted-foreground: 0 0% 63.5294%;
--accent: 0 0% 19.2157%;
--accent-foreground: 0 0% 98.0392%;
--destructive: 6.6667 60% 20.5882%;
--destructive-foreground: 12 12.1951% 91.9608%;
--border: 0 0% 16.0784%;
--input: 0 0% 14.1176%;
--ring: 141.8919 69.1589% 58.0392%;
--chart-1: 141.8919 69.1589% 58.0392%;
--chart-2: 213.1169 93.9024% 67.8431%;
--chart-3: 255.1351 91.7355% 76.2745%;
--chart-4: 43.2558 96.4126% 56.2745%;
--chart-5: 172.4551 66.0079% 50.3922%;
--sidebar: 0 0% 7.0588%;
--sidebar-foreground: 0 0% 53.7255%;
--sidebar-primary: 154.898 100% 19.2157%;
--sidebar-primary-foreground: 152.7273 19.2982% 88.8235%;
--sidebar-accent: 0 0% 19.2157%;
--sidebar-accent-foreground: 0 0% 98.0392%;
--sidebar-border: 0 0% 16.0784%;
--sidebar-ring: 141.8919 69.1589% 58.0392%;
--font-sans: Outfit, sans-serif;
--font-serif: ui-serif, Georgia, Cambria, 'Times New Roman', Times, serif;
--font-mono: monospace;
--radius: 0.5rem;
--shadow-2xs: 0px 1px 3px 0px hsl(0 0% 0% / 0.09);
--shadow-xs: 0px 1px 3px 0px hsl(0 0% 0% / 0.09);
--shadow-sm: 0px 1px 3px 0px hsl(0 0% 0% / 0.17), 0px 1px 2px -1px hsl(0 0% 0% / 0.17);
--shadow: 0px 1px 3px 0px hsl(0 0% 0% / 0.17), 0px 1px 2px -1px hsl(0 0% 0% / 0.17);
--shadow-md: 0px 1px 3px 0px hsl(0 0% 0% / 0.17), 0px 2px 4px -1px hsl(0 0% 0% / 0.17);
--shadow-lg: 0px 1px 3px 0px hsl(0 0% 0% / 0.17), 0px 4px 6px -1px hsl(0 0% 0% / 0.17);
--shadow-xl: 0px 1px 3px 0px hsl(0 0% 0% / 0.17), 0px 8px 10px -1px hsl(0 0% 0% / 0.17);
--shadow-2xl: 0px 1px 3px 0px hsl(0 0% 0% / 0.43);
}
}
@@ -72,5 +106,6 @@
}
body {
@apply bg-background text-foreground;
letter-spacing: var(--tracking-normal);
}
}
+9 -4
View File
@@ -3,13 +3,18 @@ import type { Metadata } from 'next';
import { Inter } from 'next/font/google';
import { ThemeProvider } from '@/components/theme-provider';
import { Toaster } from '@/components/ui/toaster';
import { getAppConfig } from '@/lib/app-config';
const inter = Inter({ subsets: ['latin'] });
export const metadata: Metadata = {
title: 'Table Tennis Booking System',
description: 'Book your table tennis court slots with ease',
};
export async function generateMetadata(): Promise<Metadata> {
const config = await getAppConfig();
return {
title: config.appTitle,
description: config.appDescription,
};
}
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
+6 -3
View File
@@ -1,13 +1,16 @@
import Link from 'next/link';
import { LoginForm } from '@/components/auth/LoginForm';
import { getAppConfig } from '@/lib/app-config';
export default async function LoginPage() {
const config = await getAppConfig();
export default function LoginPage() {
return (
<div className='min-h-screen bg-gradient-to-br from-blue-50 to-indigo-100 dark:from-gray-900 dark:to-gray-800 flex items-center justify-center px-4'>
<div className='w-full max-w-md space-y-6'>
<div className='text-center'>
<h1 className='text-3xl font-bold text-foreground mb-2'>🏓 TT Booking</h1>
<p className='text-muted-foreground'>Professional table tennis court booking system</p>
<h1 className='text-3xl font-bold text-foreground mb-2'>🏓 {config.clubName}</h1>
<p className='text-muted-foreground'>{config.appDescription}</p>
</div>
<LoginForm />
+6 -3
View File
@@ -1,13 +1,16 @@
import Link from 'next/link';
import { RegisterForm } from '@/components/auth/RegisterForm';
import { getAppConfig } from '@/lib/app-config';
export default async function RegisterPage() {
const config = await getAppConfig();
export default function RegisterPage() {
return (
<div className='min-h-screen bg-gradient-to-br from-blue-50 to-indigo-100 dark:from-gray-900 dark:to-gray-800 flex items-center justify-center px-4'>
<div className='w-full max-w-md space-y-6'>
<div className='text-center'>
<h1 className='text-3xl font-bold text-foreground mb-2'>🏓 TT Booking</h1>
<p className='text-muted-foreground'>Join our table tennis community</p>
<h1 className='text-3xl font-bold text-foreground mb-2'>🏓 {config.clubName}</h1>
<p className='text-muted-foreground'>Join our {config.sportName.toLowerCase()} community</p>
</div>
<RegisterForm />