diff --git a/src/components/education/EducationTraining.tsx b/src/components/education/EducationTraining.tsx index 9aeec1e..d173809 100644 --- a/src/components/education/EducationTraining.tsx +++ b/src/components/education/EducationTraining.tsx @@ -398,7 +398,7 @@ const EducationTraining: React.FC = () => { Contact Admissions this.getFullImageUrl(img)).filter(img => img !== '') || [] + }; + } + // File upload method async uploadImage(file: File): Promise<{url: string, filename: string}> { try { @@ -54,14 +77,21 @@ class EventAPI { const response = await fetch(`${this.baseUrl}/api/files/upload`, { method: 'POST', - body: formData, // Don't set Content-Type header for FormData + body: formData, }); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } - return await response.json(); + const result = await response.json(); + + // Ensure the URL is absolute + if (result.url) { + result.url = this.getFullImageUrl(result.url); + } + + return result; } catch (error) { console.error('Error uploading image:', error); throw error; @@ -86,13 +116,16 @@ class EventAPI { headers: { 'Content-Type': 'application/json', }, + cache: 'no-store', // Ensure fresh data }); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } - return await response.json(); + const events = await response.json(); + // Process all events to fix image URLs + return events.map((event: Event) => this.processEvent(event)); } catch (error) { console.error('Error fetching events:', error); throw error; @@ -106,13 +139,16 @@ class EventAPI { headers: { 'Content-Type': 'application/json', }, + cache: 'no-store', }); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } - return await response.json(); + const event = await response.json(); + // Process event to fix image URLs + return this.processEvent(event); } catch (error) { console.error('Error fetching event:', error); throw error;