From 3ebdd2d7df65bf0b01d0fe21907c41f74e8affc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Gierwia=C5=82o?= Date: Fri, 14 Nov 2025 18:35:01 +0100 Subject: [PATCH] feat: pre-populate heats form with existing data when editing - Add existingHeats prop to HeatsBanner component - Load and format existing heats into form fields - Pass myHeats to HeatsBanner in edit modal - Users can now edit their heats instead of starting from scratch --- frontend/src/components/heats/HeatsBanner.jsx | 15 ++++++++++++++- frontend/src/pages/EventChatPage.jsx | 1 + 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/heats/HeatsBanner.jsx b/frontend/src/components/heats/HeatsBanner.jsx index 0ebd56c..e0abe0a 100644 --- a/frontend/src/components/heats/HeatsBanner.jsx +++ b/frontend/src/components/heats/HeatsBanner.jsx @@ -2,7 +2,7 @@ import { useState, useEffect } from 'react'; import { X, Plus, Trash2, Loader2 } from 'lucide-react'; import { divisionsAPI, competitionTypesAPI, heatsAPI } from '../../services/api'; -export default function HeatsBanner({ slug, onSave, onDismiss }) { +export default function HeatsBanner({ slug, onSave, onDismiss, existingHeats = null }) { const [divisions, setDivisions] = useState([]); const [competitionTypes, setCompetitionTypes] = useState([]); const [heats, setHeats] = useState([{ divisionId: '', competitionTypeId: '', heatNumber: '', role: '' }]); @@ -14,6 +14,19 @@ export default function HeatsBanner({ slug, onSave, onDismiss }) { loadOptions(); }, []); + // Load existing heats if provided + useEffect(() => { + if (existingHeats && existingHeats.length > 0) { + const formattedHeats = existingHeats.map(heat => ({ + divisionId: heat.divisionId.toString(), + competitionTypeId: heat.competitionTypeId.toString(), + heatNumber: heat.heatNumber.toString(), + role: heat.role || '', + })); + setHeats(formattedHeats); + } + }, [existingHeats]); + const loadOptions = async () => { try { setLoading(true); diff --git a/frontend/src/pages/EventChatPage.jsx b/frontend/src/pages/EventChatPage.jsx index f871e07..8440d7f 100644 --- a/frontend/src/pages/EventChatPage.jsx +++ b/frontend/src/pages/EventChatPage.jsx @@ -717,6 +717,7 @@ const EventChatPage = () => { slug={slug} onSave={handleHeatsSave} onDismiss={() => setShowHeatsModal(false)} + existingHeats={myHeats} />