diff --git a/app/(home)/components/CountdownTimer.tsx b/app/(home)/components/CountdownTimer.tsx new file mode 100644 index 0000000..613b65a --- /dev/null +++ b/app/(home)/components/CountdownTimer.tsx @@ -0,0 +1,68 @@ +'use client'; + +import { useState, useEffect, useCallback } from 'react'; + +interface CountdownTimerProps { + eventDate: string; +} + +export default function CountdownTimer({ eventDate }: CountdownTimerProps) { + const formatNumber = (num: number) => (num < 10 ? `0${num}` : `${num}`); + + const calculateTimeLeft = useCallback(() => { + const difference = +new Date(eventDate) - +new Date(); + if (difference > 0) { + return { + days: formatNumber(Math.floor(difference / (1000 * 60 * 60 * 24))), + hours: formatNumber(Math.floor((difference / (1000 * 60 * 60)) % 24)), + minutes: formatNumber(Math.floor((difference / 1000 / 60) % 60)), + seconds: formatNumber(Math.floor((difference / 1000) % 60)), + }; + } + return { days: '00', hours: '00', minutes: '00', seconds: '00' }; + }, [eventDate]); // Dependency array ensures the function updates when `eventDate` changes + + const [timeLeft, setTimeLeft] = useState(calculateTimeLeft()); + const [isClient, setIsClient] = useState(false); + + useEffect(() => { + setIsClient(true); + + const timer = setInterval(() => { + setTimeLeft(calculateTimeLeft()); + }, 1000); + + return () => clearInterval(timer); + }, [calculateTimeLeft]); // Dependency array ensures the effect re-runs if `calculateTimeLeft` changes + + if (!isClient) return null; + + return ( +
+

+ COMING SOON +

+

+ PYCON COUNTDOWN +

+
+
+

{`${timeLeft.days}`}

+

DAYS

+
+
+

{`${timeLeft.hours}`}

+

HRS

+
+
+

{`${timeLeft.minutes}`}

+

MIN

+
+
+

{`${timeLeft.seconds}`}

+

SEC

+
+
+
+ ); +} diff --git a/app/(home)/components/EventCard.tsx b/app/(home)/components/EventCard.tsx new file mode 100644 index 0000000..cb7413b --- /dev/null +++ b/app/(home)/components/EventCard.tsx @@ -0,0 +1,62 @@ +import { Button } from '@/components/ui/button'; +import { cn } from '@/lib/utils'; +import CountdownTimer from './CountdownTimer'; +import Link from 'next/link'; + +interface Event { + title: string; + date: string; + location: string; + variant: 'main' | 'regular'; // "main" for the featured event, "regular" for other events + link: string; +} + +export default function EventCard({ event }: { event: Event }) { + return ( +
+
+

+ {event.title} +

+

+ {event.date}
{event.location} +

+ {event.variant === 'main' && ( + + )} +
+ + {event.variant === 'main' && ( +
+ )} + + {event.variant === 'main' && ( +
+ +
+ )} +
+ ); +} diff --git a/app/(home)/components/UpcomingEvents.tsx b/app/(home)/components/UpcomingEvents.tsx new file mode 100644 index 0000000..318793f --- /dev/null +++ b/app/(home)/components/UpcomingEvents.tsx @@ -0,0 +1,78 @@ +import { Container } from '@/components/ui/container'; +import React from 'react'; +import EventCard from './EventCard'; +import CountdownTimer from './CountdownTimer'; +import { Button } from '@/components/ui/button'; +import Link from 'next/link'; + +interface Event { + title: string; + date: string; + location: string; + variant: 'main' | 'regular'; + link: string; +} + +const EVENTS: Event[] = [ + { + title: 'Pycon Mini Davao', + date: 'June 20, 2025', + location: 'Mugna Tech, Davao City', + variant: 'main', + link: '/404', + }, + { + title: 'RAGs & DAGs', + date: 'June 20, 2025', + location: 'Mugna Tech, Davao City', + variant: 'regular', + link: '/404', + }, + { + title: 'RAGs & DAGs', + date: 'June 20, 2025', + location: 'Mugna Tech, Davao City', + variant: 'regular', + link: '/404', + }, + { + title: 'RAGs & DAGs', + date: 'June 20, 2025', + location: 'Mugna Tech, Davao City', + variant: 'regular', + link: '/404', + }, +]; + +const UpcomingEvents = () => { + return ( + + {/* Title */} +

+ Upcoming Events +

+ + {/* Featured */} + + + {/* Countdown Timer */} +
+ +
+ + {/* Other events */} +
+ {EVENTS.slice(1).map((event, idx) => ( + + ))} +
+ + {/* See more Events Button */} + +
+ ); +}; + +export default UpcomingEvents; diff --git a/app/(home)/page.tsx b/app/(home)/page.tsx index 3362a3a..5e1245d 100644 --- a/app/(home)/page.tsx +++ b/app/(home)/page.tsx @@ -4,6 +4,8 @@ import { CTASection } from './components/CTASection'; import { StatsAndReviews } from './components/StatsAndReviews'; import { PythonFoundation } from './components//PythonFoundation'; import { Partners } from './components//Partners'; +import UpcomingEvents from './components//UpcomingEvents'; +import { Footer } from './components//Footer'; export default function HomePage() { return ( @@ -14,6 +16,8 @@ export default function HomePage() { + +