README.md
md6 kBIn React_Labs_Chapters_08_09.zip
React Lab 03 - Workshop Registration Control Room
Overview
This project implements a Workshop Registration Control Room focusing on Chapter 08 (Conditional Rendering) and Chapter 09 (Forms & Validation). Students can filter workshops, select sessions, and register with a fully controlled form.
Setup Instructions
-
Install Dependencies
npm install -
Run Development Server
npm run dev -
Build for Production
npm run build
Features Implemented
Part 1 - Data Flow & Selection State (Chapter 08)
State Variables:
workshops- Array of workshop objects initialized withINITIAL_WORKSHOPSfilters- Object with{ showOnlyOpen, mode, focus }selectedWorkshopId- ID of the currently selected workshoplastRegistration- Most recent registration submission
Derived Values:
filteredWorkshops- Workshops filtered based on active filtersopenCount- Count of workshops with available seatsisFull- Boolean indicating if selected workshop is fullalmostFull- Boolean for workshops with ≤3 seats remainingnoResults- Boolean when no workshops match filters
Auto-Fallback Logic:
Uses useEffect to automatically select the first available workshop when the currently selected one is filtered out.
Part 2 - Filter Panel & Workshop Cards (Chapter 08)
FilterPanel Component:
- Controlled checkbox for "Show only open seats"
- Segmented buttons for delivery mode (all/in-person/remote)
- Select dropdown for focus area (all/events/forms/assessment)
- Dynamic filter caption showing active filters
- All controls fully controlled via props
WorkshopCard Component:
- Conditional class names for selected/full states
- Dynamic seat status badges (Open/Filling fast/Waitlist only)
- Mode and focus badges
- Different icons for in-person (📍) vs remote (🌐) sessions
- Displays tags, instructor, session time, and duration
- Click handler to select workshop
Part 3 - Registration Form (Chapter 09)
Form State:
{
fullName: '',
email: '',
experience: 'beginner',
attendanceType: 'in-person' or 'remote',
needsEquipment: false,
dietary: 'none',
notes: '',
equipmentDetails: ''
}Validation:
- Name must be at least 3 characters
- Email must contain '@' symbol
- Inline error messages displayed below inputs
Conditional Fields:
- Attendance type radio - in-person disabled when workshop is remote-only
- Equipment details textarea - only shown when
needsEquipmentis checked - Dietary helper note - shown when dietary restriction is selected
Form Submission:
- Validates all fields before submission
- Calls
onSubmitwith form data + workshopId - Resets form after successful submission
Part 4 - Confirmation Panel & Seat Updates
Seat Management:
- Increments
seats.takenwhen seats are available - Sets
waitlist: trueflag when workshop is full - Updates workshop state immutably
SummaryPanel Component:
- Renders nothing when
registrationis null - Displays attendee information
- Shows workshop details and session time
- Status badge (Confirmed/Waitlist) with appropriate styling
- Conditionally shows equipment and dietary notes
- Clear button to reset and allow new registration
- Timestamp of submission
Components
App.jsx
Main application component managing:
- Global state (workshops, filters, selection, registration)
- Filter logic and derived values
- Event handlers for filter changes and selection
- Registration submission with seat updates
- Layout and component composition
FilterPanel.jsx
Filter controls component:
- Checkbox for open seats filter
- Mode selection buttons (all/in-person/remote)
- Focus area dropdown
- Helper text for active filters
WorkshopCard.jsx
Workshop display card:
- Workshop information display
- Conditional styling based on selection and availability
- Seat status badges
- Tags and metadata
- Selection button
RegistrationForm.jsx
Registration form with validation:
- Controlled inputs for all fields
- Real-time validation
- Conditional field rendering
- Form submission handling
- Reset after submission
SummaryPanel.jsx
Registration confirmation display:
- Attendee information summary
- Workshop details
- Status indicator (confirmed/waitlist)
- Optional notes (equipment/dietary)
- Clear functionality
Conditional Rendering Patterns Used
- Ternary operators - For seat status badges and status text
- Logical && operator - For conditional pills and helper text
- Early return - SummaryPanel returns null when no registration
- Conditional classes - Dynamic className composition
- Array.filter() - Workshop filtering logic
- Map with conditional content - Workshop grid and tags
- Disabled attributes - Form controls based on workshop mode
Form Validation Patterns
- Controlled inputs - All form fields managed via state
- Inline validation - Real-time error checking on change
- Submit validation - Complete validation before submission
- Error state management - Separate errors object
- Conditional field rendering - Based on form values
Key Features
✅ Dynamic filtering with multiple criteria ✅ Automatic workshop selection fallback ✅ Conditional rendering throughout UI ✅ Fully controlled form inputs ✅ Real-time validation with error messages ✅ Seat count updates on registration ✅ Waitlist handling for full workshops ✅ Registration confirmation panel ✅ Responsive design with CSS grid ✅ Arabic time format preservation (ق.ظ./ب.ظ.)
Technologies Used
- React 18
- Vite
- CSS Custom Properties
- ES6+ JavaScript
Testing Recommendations
- Test all filter combinations
- Try registering for open workshops
- Try registering for full workshops (waitlist)
- Test form validation (invalid email, short name)
- Test conditional fields (equipment, dietary)
- Verify seat count increments correctly
- Test workshop selection fallback when filtering