diff --git a/dashboard/src/components/dashboard/MiniEventFeed.jsx b/dashboard/src/components/dashboard/MiniEventFeed.jsx index 4c3f1ad..246a787 100644 --- a/dashboard/src/components/dashboard/MiniEventFeed.jsx +++ b/dashboard/src/components/dashboard/MiniEventFeed.jsx @@ -18,11 +18,14 @@ import { Activity, AlertCircle, FileText, + ChevronLeft, + ChevronRight, } from "lucide-react"; import { format } from "date-fns"; import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"; import { Skeleton } from "@/components/ui/skeleton"; import { EventDialog } from "./EventFeed.jsx"; +import { Button } from "@/components/ui/button"; const METRIC_IDS = { PLACED_ORDER: "Y8cqcF", @@ -319,6 +322,34 @@ const MiniEventFeed = ({ const [error, setError] = useState(null); const [lastUpdate, setLastUpdate] = useState(null); const scrollRef = useRef(null); + const [showLeftArrow, setShowLeftArrow] = useState(false); + const [showRightArrow, setShowRightArrow] = useState(false); + + const handleScroll = () => { + if (scrollRef.current) { + const { scrollLeft, scrollWidth, clientWidth } = scrollRef.current; + setShowLeftArrow(scrollLeft > 0); + setShowRightArrow(scrollLeft < scrollWidth - clientWidth - 1); + } + }; + + const scrollToEnd = () => { + if (scrollRef.current) { + scrollRef.current.scrollTo({ + left: scrollRef.current.scrollWidth, + behavior: 'smooth' + }); + } + }; + + const scrollToStart = () => { + if (scrollRef.current) { + scrollRef.current.scrollTo({ + left: 0, + behavior: 'smooth' + }); + } + }; const fetchEvents = useCallback(async () => { try { @@ -354,6 +385,7 @@ const MiniEventFeed = ({ left: scrollRef.current.scrollWidth, behavior: 'instant' }); + handleScroll(); }, 0); } } catch (error) { @@ -370,37 +402,63 @@ const MiniEventFeed = ({ return () => clearInterval(interval); }, [fetchEvents]); + useEffect(() => { + handleScroll(); + }, [events]); + return (