diff --git a/src/components/Layouts/Header.tsx b/src/components/Layouts/Header.tsx index 713f406..9206de6 100644 --- a/src/components/Layouts/Header.tsx +++ b/src/components/Layouts/Header.tsx @@ -3,13 +3,14 @@ import React, { useState } from "react"; import Link from "next/link"; import Image from "next/image"; -import { usePathname } from "next/navigation"; +import { usePathname, useRouter } from "next/navigation"; const Header = () => { const [isMenuOpen, setIsMenuOpen] = useState(false); const [isServicesOpen, setIsServicesOpen] = useState(false); const [isMobileServicesOpen, setIsMobileServicesOpen] = useState(false); const pathname = usePathname(); + const router = useRouter(); const closeAllMenus = () => { setIsMenuOpen(false); @@ -17,7 +18,27 @@ const Header = () => { setIsMobileServicesOpen(false); }; - + const scrollToSection = (sectionId: string) => { + closeAllMenus(); + + // If not on services page, navigate to it first + if (pathname !== '/services') { + router.push('/services'); + // Wait for navigation to complete, then scroll + setTimeout(() => { + const element = document.getElementById(sectionId); + if (element) { + element.scrollIntoView({ behavior: 'smooth', block: 'start' }); + } + }, 100); + } else { + // Already on services page, just scroll + const element = document.getElementById(sectionId); + if (element) { + element.scrollIntoView({ behavior: 'smooth', block: 'start' }); + } + } + }; const menuItems = [ { href: "/", label: "Home" }, @@ -99,6 +120,7 @@ const Header = () => { ? "text-white bg-red-600" : "text-white hover:bg-red-600" } flex items-center justify-center gap-1`} + onClick={closeAllMenus} > {item.label} { {/* Services Dropdown */} {isServicesOpen && (
- scrollToSection('trauma-care')} + className="w-full text-left block px-4 py-3 text-sm font-medium text-blue-900 hover:bg-gray-100 hover:text-red-600 transition-colors border-b border-gray-100" + > + Trauma Care Services + +
)} @@ -213,13 +240,20 @@ const Header = () => { {isMobileServicesOpen && ( )} diff --git a/src/components/about/StatisticsTiles.tsx b/src/components/about/StatisticsTiles.tsx index 839a79a..11aaaca 100644 --- a/src/components/about/StatisticsTiles.tsx +++ b/src/components/about/StatisticsTiles.tsx @@ -6,6 +6,7 @@ interface ServiceTile { id: number; title: string; description: string; + category: 'TRAUMA_CARE' | 'ACUTE_CARE_SURGERY'; isActive: boolean; displayOrder: number; createdDate: string; @@ -13,7 +14,8 @@ interface ServiceTile { } const StatisticsTiles = () => { - const [tiles, setTiles] = useState([]); + const [traumaCareTiles, setTraumaCareTiles] = useState([]); + const [acuteCareTiles, setAcuteCareTiles] = useState([]); const [loading, setLoading] = useState(true); const [error, setError] = useState(false); @@ -25,20 +27,20 @@ const StatisticsTiles = () => { if (response.ok) { const data: ServiceTile[] = await response.json(); - // Filter active tiles and sort by display order - const activeTiles = data - .filter(tile => tile.isActive) + + // Separate tiles by category + const traumaTiles = data + .filter(tile => tile.isActive && tile.category === 'TRAUMA_CARE') .sort((a, b) => a.displayOrder - b.displayOrder); - if (activeTiles.length > 0) { - setTiles(activeTiles); - setError(false); - } else { - // No active tiles - setError(true); - } + const acuteTiles = data + .filter(tile => tile.isActive && tile.category === 'ACUTE_CARE_SURGERY') + .sort((a, b) => a.displayOrder - b.displayOrder); + + setTraumaCareTiles(traumaTiles); + setAcuteCareTiles(acuteTiles); + setError(false); } else { - // API error setError(true); } } catch (err) { @@ -54,7 +56,6 @@ const StatisticsTiles = () => { // Function to parse description and convert to bullet points (comma-separated) const parseDescription = (description: string) => { - // Split by commas and filter out empty strings const points = description .split(',') .map(point => point.trim()) @@ -66,19 +67,19 @@ const StatisticsTiles = () => { return (
-

- Our Trauma Care Services -

- {loading ? ( // Loading state
- ) : error || tiles.length === 0 ? ( + ) : error ? ( + // Error state +
+

+ Unable to load services. Please check back later. +

+
+ ) : traumaCareTiles.length === 0 && acuteCareTiles.length === 0 ? ( // No services available

@@ -86,34 +87,87 @@ const StatisticsTiles = () => {

) : ( - // Display services one after another -
- {tiles.map((tile, index) => ( -
-

+ {/* Trauma Care Section */} + {traumaCareTiles.length > 0 && ( +
+

- {tile.title} -

-
    - {parseDescription(tile.description).map((point, idx) => ( -
  • - - {point} -
  • + Our Trauma Care Services +

+ +
+ {traumaCareTiles.map((tile) => ( +
+

+ {tile.title} +

+
    + {parseDescription(tile.description).map((point, idx) => ( +
  • + + {point} +
  • + ))} +
+
))} - +
- ))} -
+ )} + + {/* Acute Care Surgery Section */} + {acuteCareTiles.length > 0 && ( +
+

+ Acute Care Surgery Services +

+ +
+ {acuteCareTiles.map((tile) => ( +
+

+ {tile.title} +

+
    + {parseDescription(tile.description).map((point, idx) => ( +
  • + + {point} +
  • + ))} +
+
+ ))} +
+
+ )} + )}
diff --git a/src/components/education/EducationTraining.tsx b/src/components/education/EducationTraining.tsx index 28a7eba..8673682 100644 --- a/src/components/education/EducationTraining.tsx +++ b/src/components/education/EducationTraining.tsx @@ -19,12 +19,14 @@ import { upcomingEventsService, UpcomingEvent } from '../../services/upcomingEve const AcademicResearch: React.FC = () => { const [mounted, setMounted] = useState(false); const [courses, setCourses] = useState([]); + const [pastCourses, setPastCourses] = useState([]); const [upcomingEvents, setUpcomingEvents] = useState([]); const [loading, setLoading] = useState(true); const [error, setError] = useState(null); const [selectedCategory, setSelectedCategory] = useState('All'); const [searchQuery, setSearchQuery] = useState(''); const [activeTab, setActiveTab] = useState<'education' | 'research'>('education'); + const [courseTab, setCourseTab] = useState<'active' | 'past'>('active'); const categories = ['All', 'Certification', 'Training', 'Workshop', 'Fellowship']; @@ -98,12 +100,14 @@ const AcademicResearch: React.FC = () => { setLoading(true); setError(null); - const [fetchedCourses, fetchedEvents] = await Promise.all([ + const [fetchedActiveCourses, fetchedPastCourses, fetchedEvents] = await Promise.all([ educationService.getActiveCourses(), + educationService.getPastCourses(), upcomingEventsService.getActiveUpcomingEvents() ]); - setCourses(fetchedCourses); + setCourses(fetchedActiveCourses); + setPastCourses(fetchedPastCourses); setUpcomingEvents(fetchedEvents); } catch (err) { setError('Failed to load courses and events. Please try again later.'); @@ -117,7 +121,7 @@ const AcademicResearch: React.FC = () => { return null; } - const filteredCourses = courses.filter(course => { + const filteredCourses = (courseTab === 'active' ? courses : pastCourses).filter(course => { const matchesCategory = selectedCategory === 'All' || course.category === selectedCategory; const matchesSearch = !searchQuery.trim() || course.title.toLowerCase().includes(searchQuery.toLowerCase()) || @@ -226,15 +230,15 @@ const AcademicResearch: React.FC = () => { {/* Education & Training Tab Content */} {activeTab === 'education' && ( <> - {/* Upcoming Training Section */} + {/* Upcoming Training Section - NO FALLBACK */}

Upcoming Training Programs

-
- {upcomingEvents.length > 0 ? ( - upcomingEvents.map((event) => ( + {upcomingEvents.length > 0 ? ( +
+ {upcomingEvents.map((event) => (
{ {event.description}

- )) - ) : ( - <> -
-
-
-

- Simulation-based Team Drills -

-
- - Q3 2025 -
-
-
-

- Hands-on simulation training designed to improve team coordination and emergency response in high-pressure trauma situations. -

-
- -
-
-
-

- Online Webinar Series -

-
- - Monthly Sessions -
-
-
-

- Monthly online sessions covering trauma ethics, young doctor support, and professional development in emergency medicine. -

-
- -
-
-
-

- Community Education -

-
- - Ongoing -
-
-
-

- Road safety fairs and school education sessions to promote trauma prevention and basic first aid awareness in the community. -

-
- - )} -
+ ))} +
+ ) : ( +
+

No upcoming training programs at the moment.

+
+ )}
@@ -320,6 +275,43 @@ const AcademicResearch: React.FC = () => {

Available Courses

+ + {/* Course Tabs - Active/Past */} +
+ + +
+
{/* Category Filter */}
@@ -368,7 +360,7 @@ const AcademicResearch: React.FC = () => {

{filteredCourses.length === 0 ? 'No courses found matching your criteria.' - : `Showing ${filteredCourses.length} of ${courses.length} course${courses.length !== 1 ? 's' : ''}` + : `Showing ${filteredCourses.length} of ${courseTab === 'active' ? courses.length : pastCourses.length} course${(courseTab === 'active' ? courses.length : pastCourses.length) !== 1 ? 's' : ''}` }

@@ -384,7 +376,9 @@ const AcademicResearch: React.FC = () => {

{searchQuery.trim() || selectedCategory !== 'All' ? 'No courses match your search criteria.' - : 'No courses available at the moment.' + : courseTab === 'active' + ? 'No active courses available at the moment.' + : 'No past courses available.' }

{(searchQuery.trim() || selectedCategory !== 'All') && ( @@ -407,8 +401,8 @@ 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 */} -
+ {/* Image - FIXED */} +
{course.title} {
- {/* Image Section */} -
+ {/* Image Section - FIXED */} +
-
+
{eventData.title}
{galleryImages.map((image, index) => ( -
+
{`Gallery {
{/* Event Details Section */} -
+
{/* Header Section */}
@@ -373,7 +373,7 @@ const EventDetail = () => {

{eventData.title}

- {/* Learn More Button - THIS IS THE NEW ADDITION */} + {/* Learn More Button */} {eventData.learnMoreLink && eventData.learnMoreLink.trim() !== '' && (