import { Divider, List } from '@mui/material'; import React, { useEffect, useRef } from 'react'; import { Maybe } from '@apextoaster/js-utils'; import { EventItem } from './events'; export interface HistoryPanelProps { // eslint-disable-next-line @typescript-eslint/no-explicit-any history: Array; scroll: 'auto' | 'instant' | 'smooth' | false; } export function HistoryPanel(props: HistoryPanelProps) { const { history, scroll } = props; const scrollRef = useRef>(undefined); useEffect(() => { if (scrollRef.current && scroll !== false) { scrollRef.current.scrollIntoView({ behavior: scroll as ScrollBehavior, block: 'end' }); } }, [scrollRef.current, props.scroll]); const items = history.map((item, index) => { if (index === history.length - 1) { return ; } return ; }); return {interleave(items)} ; } // eslint-disable-next-line @typescript-eslint/no-explicit-any export function interleave(arr: Array) { // eslint-disable-next-line @typescript-eslint/no-magic-numbers return arr.reduce((acc, val, idx) => acc.concat(val, ), []).slice(0, -1); }