"use client"; import { useEffect, useRef } from "react"; import SafeImage from "./SafeImage"; interface Experience { name: string; company: string; position: string; description: string; startDate: string; endDate: string; logo?: string; } interface ExperienceProps { experiences: Experience[]; } function formatDate(d: string) { if (d === "current") return "Present"; const [, m, y] = d.split("-"); const months = ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]; return `${months[parseInt(m) - 1]} ${y}`; } function ExperienceItem({ exp, index }: { exp: Experience; index: number }) { const ref = useRef(null); useEffect(() => { const el = ref.current; if (!el) return; const obs = new IntersectionObserver( ([entry]) => { if (entry.isIntersecting) { setTimeout(() => el.classList.add("visible"), index * 100); obs.disconnect(); } }, { threshold: 0.1 } ); obs.observe(el); return () => obs.disconnect(); }, [index]); const isCurrent = exp.endDate === "current"; return (
{/* Date */}
{isCurrent && (
● NOW
)} {formatDate(exp.startDate)}

{formatDate(exp.endDate)}
{/* Line with dot */}
{/* Content */}
{exp.logo && ( )} {exp.company}

{exp.position}

{exp.description}

); } export default function Experience({ experiences }: ExperienceProps) { const headingRef = useRef(null); useEffect(() => { const el = headingRef.current; if (!el) return; const obs = new IntersectionObserver( ([entry]) => { if (entry.isIntersecting) { el.classList.add("visible"); obs.disconnect(); } }, { threshold: 0.1 } ); obs.observe(el); return () => obs.disconnect(); }, []); return (
Career Path

Experience

{experiences.map((exp, i) => ( ))}
); }