import { ReactElement, useEffect, useState } from 'react' import { getPrettyDateString } from '../utils/date' import { getHistorySafe, HistoryItem, HISTORY_KEYS } from '../utils/local-storage' import ExpandableList from './ExpandableList' import ExpandableListItemLink from './ExpandableListItemLink' interface Props { title: string localStorageKey: HISTORY_KEYS } export function History({ title, localStorageKey }: Props): ReactElement | null { const [items, setItems] = useState([]) useEffect(() => { setItems(getHistorySafe(localStorageKey)) }, [localStorageKey]) if (!items.length) { return null } return ( {items.map((x, i) => ( ))} ) }