From 8f2a45a477e58dac5f12ff9b03f45f0aa2258f48 Mon Sep 17 00:00:00 2001 From: mukeshs Date: Fri, 21 Nov 2025 09:46:33 +0530 Subject: [PATCH] past image resolved --- .../education/EducationTraining.tsx | 20 +++-- src/components/events/EventDetail.tsx | 68 +++++++-------- .../events/MedicalEventsComponent.tsx | 84 ++++++++++--------- src/components/home/EventSection.tsx | 58 +++++++++---- 4 files changed, 132 insertions(+), 98 deletions(-) diff --git a/src/components/education/EducationTraining.tsx b/src/components/education/EducationTraining.tsx index 8673682..5035a43 100644 --- a/src/components/education/EducationTraining.tsx +++ b/src/components/education/EducationTraining.tsx @@ -1,6 +1,5 @@ 'use client'; import { useState, useEffect } from 'react'; -import Image from 'next/image'; import Link from 'next/link'; import { ChevronRight, @@ -401,14 +400,19 @@ const AcademicResearch: React.FC = () => { href={`/education-training/course-detail?id=${course.id}`} className="group bg-white rounded-lg overflow-hidden border border-gray-300 hover:shadow-xl transition-all duration-300 flex flex-col h-full cursor-pointer" > - {/* Image - FIXED */} + {/* Image - no fallback */}
- {course.title} + {course.image && course.image.trim() !== '' ? ( + {course.title} + ) : ( +
+ No image available +
+ )}
{/* Content */} diff --git a/src/components/events/EventDetail.tsx b/src/components/events/EventDetail.tsx index 40e9388..ff84151 100644 --- a/src/components/events/EventDetail.tsx +++ b/src/components/events/EventDetail.tsx @@ -165,30 +165,18 @@ const EventDetail = () => { }; }; - const getSafeImageUrl = (imageUrl: string | undefined, fallback: string) => { - return imageUrl && imageUrl.trim() !== '' ? imageUrl : fallback; + // Get safe image URL - no fallback + const getSafeImageUrl = (imageUrl: string | undefined): string => { + return imageUrl && imageUrl.trim() !== '' ? imageUrl : ''; }; - const getGalleryImages = (galleryImages: string[] | undefined) => { - const fallbackImages = [ - 'https://images.unsplash.com/photo-1576091160550-2173dba999ef?w=400&h=200&fit=crop', - 'https://images.unsplash.com/photo-1582750433449-648ed127bb54?w=400&h=200&fit=crop' - ]; - + const getGalleryImages = (galleryImages: string[] | undefined): string[] => { if (!galleryImages || galleryImages.length === 0) { - return fallbackImages; + return []; } - const validImages = galleryImages.filter(img => img && img.trim() !== ''); - if (validImages.length === 0) { - return fallbackImages; - } - - while (validImages.length < 2) { - validImages.push(fallbackImages[validImages.length % fallbackImages.length]); - } - - return validImages.slice(0, 2); + // Only return valid images, no fallbacks + return galleryImages.filter(img => img && img.trim() !== ''); }; const getFormattedDescription = (event: Event) => { @@ -298,7 +286,7 @@ const EventDetail = () => { const venue = getPrimaryVenue(eventData); const description = getFormattedDescription(eventData); const galleryImages = getGalleryImages(eventData.galleryImages); - const mainImage = getSafeImageUrl(eventData.mainImage, 'https://images.unsplash.com/photo-1559757148-5c350d0d3c56?w=800&h=400&fit=crop'); + const mainImage = getSafeImageUrl(eventData.mainImage); return (
@@ -335,28 +323,36 @@ const EventDetail = () => {
- {/* Image Section - FIXED */} + {/* Image Section - No fallbacks */}
- {eventData.title} -
-
- {galleryImages.map((image, index) => ( -
- {`Gallery + {mainImage ? ( + {eventData.title} + ) : ( +
+ No image available
- ))} + )}
+ {galleryImages.length > 0 && ( +
+ {galleryImages.map((image, index) => ( +
+ {`Gallery +
+ ))} +
+ )}
diff --git a/src/components/events/MedicalEventsComponent.tsx b/src/components/events/MedicalEventsComponent.tsx index 249bbd3..9f942e5 100644 --- a/src/components/events/MedicalEventsComponent.tsx +++ b/src/components/events/MedicalEventsComponent.tsx @@ -129,38 +129,28 @@ const MedicalEventsComponent = () => { } }; - // Get safe image URL with fallback - const getSafeImageUrl = (imageUrl: string | undefined, fallback: string) => { - return imageUrl && imageUrl.trim() !== '' ? imageUrl : fallback; + // Get safe image URL - no fallback, return empty string if no image + const getSafeImageUrl = (imageUrl: string | undefined): string => { + if (!imageUrl || imageUrl.trim() === '') { + return ''; + } + return imageUrl; }; - // Get gallery images with fallbacks - only for events, not training programs - const getGalleryImages = (item: DisplayItem) => { - const fallbackImages = [ - 'https://images.unsplash.com/photo-1551601651-2a8555f1a136?w=200&h=100&fit=crop', - 'https://images.unsplash.com/photo-1582750433449-648ed127bb54?w=200&h=100&fit=crop', - 'https://images.unsplash.com/photo-1638202993928-7267aad84c31?w=200&h=100&fit=crop', - 'https://images.unsplash.com/photo-1551601651-2a8555f1a136?w=200&h=100&fit=crop' - ]; - + // Get gallery images - no fallbacks, only return valid images + const getGalleryImages = (item: DisplayItem): string[] => { if (item.type === 'training') { - // Training programs don't have gallery images return []; } const galleryImages = item.galleryImages; if (!galleryImages || galleryImages.length === 0) { - return fallbackImages; + return []; } - // Fill missing images with fallbacks - const validImages = galleryImages.filter(img => img && img.trim() !== ''); - while (validImages.length < 4 && validImages.length < fallbackImages.length) { - validImages.push(fallbackImages[validImages.length]); - } - - return validImages.slice(0, 4); + // Only return valid images, no fallbacks + return galleryImages.filter(img => img && img.trim() !== ''); }; if (loading) { @@ -264,11 +254,17 @@ const MedicalEventsComponent = () => { onClick={() => navigateToDetail(nextItem)} >
- {nextItem.title} + {getSafeImageUrl(nextItem.mainImage) ? ( + {nextItem.title} + ) : ( +
+ No image available +
+ )} {/* Type Badge */}
{
{/* Main image - FIXED HEIGHT */}
- {item.title} + {getSafeImageUrl(item.mainImage) ? ( + {item.title} + ) : ( +
+ No image +
+ )} {/* Type Badge */}
{
- {/* Gallery grid - only for events - FIXED HEIGHT */} - {showGallery && ( + {/* Gallery grid - only for events, only if images exist */} + {showGallery && galleryImages.length > 0 && (
{galleryImages.map((img, index) => (
@@ -491,11 +493,17 @@ const MedicalEventsComponent = () => { onClick={() => router.push(`/event-detail/${event.id}`)} >
- {event.title} + {getSafeImageUrl(event.mainImage) ? ( + {event.title} + ) : ( +
+ No image +
+ )}
diff --git a/src/components/home/EventSection.tsx b/src/components/home/EventSection.tsx index 66a34c3..cc4508c 100644 --- a/src/components/home/EventSection.tsx +++ b/src/components/home/EventSection.tsx @@ -60,6 +60,14 @@ const EventsSection = () => { } }; + // Get safe image URL - no fallback + const getSafeImageUrl = (item: EventOrCourse): string => { + if (!item.mainImage || item.mainImage.trim() === '') { + return ''; + } + return item.mainImage; + }; + // Navigation functions const navigateToDetail = (item: EventOrCourse) => { if (item.type === 'event') { @@ -144,11 +152,17 @@ const EventsSection = () => { } ${index === 3 ? 'md:col-span-2 lg:col-span-1' : ''}`} onClick={() => navigateToDetail(item)} > - {getTitle(item)} + {getSafeImageUrl(item) ? ( + {getTitle(item)} + ) : ( +
+ No image +
+ )} {/* Gradient overlay for better text readability */}
@@ -199,11 +213,17 @@ const EventsSection = () => { onClick={() => navigateToDetail(featuredItem)} >
- {getTitle(featuredItem)} + {getSafeImageUrl(featuredItem) ? ( + {getTitle(featuredItem)} + ) : ( +
+ No image available +
+ )} {/* Item type badge */}
{ className="bg-white border border-gray-100 rounded-lg overflow-hidden cursor-pointer hover:shadow-lg transition-shadow flex-shrink-0" onClick={() => router.push(`/event-detail/${event.id}`)} > - {/* FIXED: Added explicit height */} + {/* FIXED: Added explicit height - no fallback */}
- {event.title} + {event.mainImage && event.mainImage.trim() !== '' ? ( + {event.title} + ) : ( +
+ No image +
+ )}