Files
tt-booking/docs/DAY_SPECIFIC_FEATURES.md
T

120 lines
4.1 KiB
Markdown

# Day-Specific Booking Times & User Display Features
## Overview
This update introduces two major features to the table tennis booking system:
### 1. Day-Specific Booking Times
The system now supports different booking hours for different days of the week. Administrators can configure custom time slots for each day (Sunday through Saturday).
#### Example Configuration:
- **Sunday**: 12:00 - 17:00 (Weekend afternoon sessions)
- **Monday**: 19:00 - 23:00 (Evening sessions only)
- **Tuesday**: 19:00 - 23:00 (Evening sessions only)
- **Wednesday**: 18:00 - 22:00 (Shorter evening sessions)
- **Thursday**: 19:00 - 23:00 (Evening sessions only)
- **Friday**: 18:00 - 22:00 (Shorter evening sessions)
- **Saturday**: 10:00 - 18:00 (Full day weekend sessions)
### 2. User Name Display
The booking calendar now shows who has booked each court slot, displaying the full name of the person who made the booking.
## Implementation Details
### Database Schema
The system uses the existing `timeSlots` table in the database schema:
```sql
CREATE TABLE time_slots (
id TEXT PRIMARY KEY,
dayOfWeek INTEGER NOT NULL, -- 0 = Sunday, 1 = Monday, etc.
startTime TEXT NOT NULL, -- Format: "HH:MM"
endTime TEXT NOT NULL, -- Format: "HH:MM"
isActive BOOLEAN DEFAULT TRUE,
createdAt INTEGER NOT NULL,
updatedAt INTEGER NOT NULL
);
```
### API Endpoints
#### Public Endpoints (for authenticated users):
- `GET /api/time-slots` - Retrieve active time slots for all days
- `GET /api/bookings/all?date=YYYY-MM-DD` - Get all bookings with user and court information
#### Admin Endpoints:
- `GET /api/admin/time-slots` - Retrieve all time slots (including inactive)
- `POST /api/admin/time-slots` - Create new time slot
- `PUT /api/admin/time-slots/[id]` - Update existing time slot
- `DELETE /api/admin/time-slots/[id]` - Delete time slot
### Admin Management
Administrators can manage time slots through the admin dashboard under the "Settings" tab. The interface allows:
- **Create Time Slots**: Set day of week, start time, end time, and active status
- **Edit Time Slots**: Modify existing time slot configurations
- **Delete Time Slots**: Remove time slot configurations
- **Activate/Deactivate**: Toggle time slots on/off without deletion
### User Experience
#### Enhanced Booking Calendar:
- Automatically adapts to show only available time slots for the selected day
- Displays who has booked each unavailable slot
- Maintains mobile-responsive design
- Provides fallback to global settings if no day-specific slots are configured
#### Booking Display:
- Available slots: Green background with "Book" button
- Booked slots: Red background showing "Booked by [Full Name]"
- Clear visual distinction between available and booked slots
## Usage Instructions
### For Administrators:
1. **Navigate to Admin Dashboard** → Settings tab
2. **Time Slot Management section** allows you to:
- Add new time slots for specific days
- Edit existing time slot configurations
- View all time slots organized by day of the week
- Activate/deactivate time slots as needed
### For Users:
1. **Select a date** in the enhanced booking calendar
2. **View available time slots** automatically filtered for that day
3. **See who has booked unavailable slots** to know who might be playing
4. **Book available slots** with partner information as before
## Technical Benefits
- **Flexible Scheduling**: Different operational hours for different days
- **User Transparency**: Know who's playing when for coordination
- **Administrative Control**: Easy management of time slots
- **Backward Compatibility**: Maintains fallback to global settings
- **Mobile Optimized**: Responsive design across all devices
## Migration
The system includes database seeding scripts that populate initial time slots based on the example configuration above. Existing bookings and functionality remain unchanged.
## Future Enhancements
Potential future improvements could include:
- Seasonal time slot variations
- Holiday-specific scheduling
- Automatic time slot generation tools
- Bulk time slot operations
- Time slot templates for quick setup