import React, { useState, useEffect, useMemo } from 'react'; import { Event, Announcement, SpecialEvent } from '../types'; import { motion, AnimatePresence } from 'motion/react'; import SpecialEventsBanner from './SpecialEventsBanner'; import AccreditationsSection from './AccreditationsSection'; interface HomeDashboardProps { events: Event[]; announcements: Announcement[]; onNavigateToEvents: () => void; specialEvents: SpecialEvent[]; } const HomeDashboard: React.FC = ({ events = [], announcements = [], onNavigateToEvents, specialEvents = [] }) => { const [now, setNow] = useState(new Date()); useEffect(() => { const timer = setInterval(() => setNow(new Date()), 30000); return () => clearInterval(timer); }, []); const filteredAnnouncements = useMemo(() => { return (announcements || []).filter(ann => { if (!ann.expiresAt) return true; const expiry = new Date(ann.expiresAt); return expiry > now; }); }, [announcements, now]); // Generate stable random values for rotation and color based on announcement ID const getNoteStyle = (id: string) => { // Simple hash function for stability const hash = id.split('').reduce((acc, char) => acc + char.charCodeAt(0), 0); const rotations = [-2, -1, 1, 2, 3, -3]; const colors = [ 'bg-[#fdfd96]', // Classic Yellow 'bg-[#ff7eb9]', // Hot Pink 'bg-[#7afcff]', // Light Blue 'bg-[#feff9c]', // Light Yellow 'bg-[#fff740]' // Darker Yellow ]; return { rotation: rotations[hash % rotations.length], color: colors[hash % colors.length] }; }; return (
Events

Let's get started

Explore Events
{/* Notice Board Section */}
{/* Cork texture pattern */}

Campus Notice Board

Real-time updates from the administration

{filteredAnnouncements.length > 0 ? ( filteredAnnouncements.slice(0, 6).map((ann) => { const style = getNoteStyle(ann.id); return ( {/* Pin */}
{ann.type || 'NOTICE'}

{ann.title}

{ann.message}

{new Date(ann.timestamp).toLocaleDateString(undefined, { weekday: 'short', month: 'short', day: 'numeric' })} {new Date(ann.timestamp).toLocaleTimeString([], {hour: '2-digit', minute:'2-digit'})}
{ann.expiresAt && Exp: {new Date(ann.expiresAt).toLocaleTimeString([], {hour: '2-digit', minute:'2-digit'})}}
); }) ) : (

The board is empty right now.

Check back later for updates

)}
); }; export default HomeDashboard;