import React, { useEffect, useRef, useState } from 'react'; interface HistoryItem { id: string; title: string; date: string; status: 'Completed' | 'Pending'; } const TEST_DATA: HistoryItem[] = [ { id: '1', title: 'General Well-being Check', date: '2025/02/01', status: 'Completed' }, { id: '2', title: 'Symptom Severity Scale', date: '2025/02/05', status: 'Completed' }, { id: '3', title: 'Daily Activity Log', date: '2025/02/06', status: 'Completed' }, { id: '4', title: 'Pain Assessment', date: '2025/02/07', status: 'Pending' }, { id: '5', title: 'Sleep Quality Survey', date: '2025/02/07', status: 'Pending' }, { id: '6', title: 'Dietary Intake Record', date: '2025/02/08', status: 'Pending' }, { id: '7', title: 'Mental Health Screening', date: '2025/02/10', status: 'Pending' }, { id: '8', title: 'Medication Adherence', date: '2025/02/12', status: 'Pending' }, { id: '9', title: 'Follow-up Consultation', date: '2025/02/15', status: 'Pending' }, { id: '10', title: 'Monthly Health Summary', date: '2025/02/28', status: 'Pending' }, ]; interface TestHistoryProps { testMode?: boolean; } const TestHistory: React.FC = ({ testMode = true }) => { const [items, setItems] = useState([]); const [showTopHint, setShowTopHint] = useState(false); const [showBottomHint, setShowBottomHint] = useState(true); // Default to true assuming content overflows const listRef = useRef(null); const topSentinelRef = useRef(null); const bottomSentinelRef = useRef(null); useEffect(() => { if (testMode) { setItems(TEST_DATA); } else { // Future: Fetch real PROMs data here setItems([]); } }, [testMode]); useEffect(() => { const observer = new IntersectionObserver( (entries) => { entries.forEach((entry) => { if (entry.target === topSentinelRef.current) { // If top sentinel is visible, HIDE top hint (we are at the top) setShowTopHint(!entry.isIntersecting); } if (entry.target === bottomSentinelRef.current) { // If bottom sentinel is visible, HIDE bottom hint (we are at the bottom) setShowBottomHint(!entry.isIntersecting); } }); }, { root: listRef.current, threshold: 0.1 // Trigger as soon as even a pixel is visible } ); if (topSentinelRef.current) observer.observe(topSentinelRef.current); if (bottomSentinelRef.current) observer.observe(bottomSentinelRef.current); return () => observer.disconnect(); }, [items]); // Re-run when items change return (
{/* .wrapper translation */}
{/* Title */}

Your Health Journey

{/* Description */}

A professional record of your care. These questionnaires help us tailor your treatment specifically for you.

{/* .list-wrapper */}
{/* Top Gradient Hint */}
{/* .list (Scrollable Area) */}
{/* Top Sentinel for Observer */}
{items.map((item) => (
{item.title} {item.status === 'Completed' && ( )}
{item.date}
))} {/* Bottom Sentinel for Observer */}
{/* Bottom Gradient Hint */}
{!testMode && items.length === 0 && (
No questionnaires pending.
)}
); }; export default TestHistory;