QUICK_START.md
md6 kBIn solution.zip
Quick Start Guide
🚀 Getting Started
1. Install Dependencies
npm install2. Start Development Server
npm run dev3. Open the Templates
Navigate to the TEMPLATES folder and open COMPONENT_TEMPLATES.md
4. Create Component Files
Create these files in src/components/:
EventCard.jsxFilterPanel.jsxEditEventForm.jsxStatsDashboard.jsx
5. Copy Template Code
Copy the code from COMPONENT_TEMPLATES.md into each corresponding file.
6. Implement the Logic
Follow the TODO comments in each file to:
- Add state management
- Implement event handlers
- Add conditional rendering
- Implement validation
📁 Project Structure
react-part/
├── TEMPLATES/
│ └── COMPONENT_TEMPLATES.md ← START HERE!
├── src/
│ ├── components/ ← Create your components here
│ │ ├── EventCard.jsx
│ │ ├── FilterPanel.jsx
│ │ ├── EditEventForm.jsx
│ │ └── StatsDashboard.jsx
│ ├── App.jsx ← Main component
│ ├── index.css ← Pre-written styles (DO NOT MODIFY)
│ └── main.jsx
├── package.json
└── README.md
🎯 Key Concepts to Focus On
1. State Management
- Use
useStatefor all state - Initialize state properly
- Update state correctly
2. Derived State
- Calculate filtered data during render
- DO NOT use
useEffectfor filtering - Statistics should be calculated, not stored
3. Controlled Components
- All form inputs must be controlled
- Value comes from state
- Changes update state via event handlers
4. Conditional Rendering
- Use ternary operators for simple conditions
- Use
&&for showing/hiding elements - Render different content based on state
5. Form Validation
- Track which fields are "touched"
- Show errors only after field is touched
- Disable submit when errors exist
⚠️ Common Mistakes to Avoid
-
❌ Don't use
useEffectfor filtering// WRONG useEffect(() => { setFilteredEvents(events.filter(...)); }, [events, filters]); // CORRECT const filteredEvents = events.filter(...); -
❌ Don't store derived data in state
// WRONG const [totalCapacity, setTotalCapacity] = useState(0); // CORRECT const totalCapacity = events.reduce((sum, e) => sum + e.capacity, 0); -
❌ Don't forget to make inputs controlled
// WRONG <input type="text" /> // CORRECT <input type="text" value={formData.title} onChange={(e) => handleChange('title', e.target.value)} /> -
❌ Don't show errors before field is touched
// WRONG {errors.title && <span>{errors.title}</span>} // CORRECT {touched.title && errors.title && <span>{errors.title}</span>}
🎨 Using the Pre-written CSS
All CSS is already written in src/index.css. Just use these classes:
Layout
container- Main container with max-widthcard- White card with shadowgrid grid-2- 2-column responsive grid
Buttons
btn btn-primary- Blue primary buttonbtn btn-secondary- Gray secondary buttonbtn btn-sm- Small button
Badges
badge badge-workshop- Workshop badgebadge badge-talk- Talk badgebadge badge-available- Green statusbadge badge-almost-full- Yellow statusbadge badge-sold-out- Red status
Forms
form-group- Form field wrapperform-label- Field labelform-input- Text inputform-select- Dropdown selectform-checkbox- Checkbox with labelform-radio- Radio button with labelform-error- Error message
Alerts
alert alert-warning- Warning messagealert alert-success- Success messagealert alert-info- Info message
Event Cards
event-card- Card wrapperevent-card.selected- Selected stateevent-card-title- Event titleevent-card-speaker- Speaker name
🧪 Testing Your Work
Test Filtering (Q1)
- Enter search text - cards should filter
- Select "Workshop" - only workshops show
- Check "Hide full events" - full events disappear
- Combine filters - all filters should work together
Test Filter Panel (Q2)
- Change filters - summary text should update
- Reset button should appear when filters are active
- Click reset - all filters should clear
Test Edit Form (Q3)
- Click "Edit" on a card - form should open
- Change title to 3 characters - error should show
- Change type to "workshop" - laptop checkbox appears
- Set capacity below registered count - error shows
- Click cancel with changes - confirmation dialog appears
Test Statistics (Q4)
- Apply filters - stats should update
- Check occupancy calculation is correct
- When occupancy > 90% - warning appears
📊 Sample Data Reference
Your app should start with 6 events:
- 2 sold out (capacity = registered)
- 2 almost full (1-5 seats left)
- 2 available (more seats)
- Mix of workshops and talks
🆘 Need Help?
If components aren't rendering:
- Check browser console for errors
- Make sure you imported the component in App.jsx
- Verify the component is exported with
export default
If styles aren't working:
- Check that class names match exactly (case-sensitive)
- Verify
index.cssis imported inmain.jsx - Clear browser cache and refresh
If state isn't updating:
- Check that you're using
setXfunctions fromuseState - Make sure inputs are controlled (
value={...}) - Verify event handlers are calling the right functions
⏱️ Time Management
- Q1: 35 min - State setup, filtering, event cards
- Q2: 15 min - Filter panel
- Q3: 25 min - Edit form with validation
- Q4: 10 min - Statistics dashboard
- Buffer: 5 min - Testing and fixes