diff --git a/backend/internal/auth/handler.go b/backend/internal/auth/handler.go index 6c505c7..a3f2770 100644 --- a/backend/internal/auth/handler.go +++ b/backend/internal/auth/handler.go @@ -317,6 +317,10 @@ func (h *Handler) Me(c *gin.Context) { if user.EmpresaNome.Valid { empresaNome = user.EmpresaNome.String } + var empresaID string + if user.EmpresaID.Valid { + empresaID = uuid.UUID(user.EmpresaID.Bytes).String() + } resp := loginResponse{ User: userResponse{ @@ -327,6 +331,7 @@ func (h *Handler) Me(c *gin.Context) { Name: user.Nome, Phone: user.Whatsapp, CompanyName: empresaNome, + CompanyID: empresaID, }, } // Note: We are not returning AccessToken/ExpiresAt here as they are already set/active. diff --git a/frontend/components/EventForm.tsx b/frontend/components/EventForm.tsx index 53974af..d8c9a5c 100644 --- a/frontend/components/EventForm.tsx +++ b/frontend/components/EventForm.tsx @@ -163,6 +163,40 @@ export const EventForm: React.FC = ({ const [selectedCourseName, setSelectedCourseName] = useState(""); const [selectedInstitutionName, setSelectedInstitutionName] = useState(""); + // Populate form with initialData + useEffect(() => { + if (initialData) { + // 1. Populate standard form fields + setFormData(prev => ({ + ...prev, + ...initialData, + startTime: initialData.time || "00:00", + locationName: (initialData as any).local_evento || (initialData as any).address?.mapLink?.includes('http') ? "" : (initialData as any).address?.mapLink || "", // Try to recover location name or clear if it's a link + fotId: initialData.fotId || "", + })); + + // 2. Populate derived dropdowns if data exists + if (initialData.curso) { + setSelectedCourseName(initialData.curso); + } + if (initialData.instituicao) { + setSelectedInstitutionName(initialData.instituicao); + } + + // 3. Populate address if available + if (initialData.address) { + setFormData(prev => ({ + ...prev, + address: { + ...prev.address, + ...initialData.address, + mapLink: initialData.address.mapLink || "" + } + })); + } + } + }, [initialData]); + // Unique Courses const uniqueCourses = Array.from(new Set(availableFots.map(f => f.curso_nome))).sort();