import * as React from 'react'; import { HistoryChanges } from '../types/column.type'; import { Avatar, CircularProgress, List, ListItem, ListItemAvatar, ListItemText } from '@mui/material'; import { Edit, ModeCommentTwoTone } from '@mui/icons-material'; import { TableArrowTooltip, TableBodyHistoryButtonContent, TableBodyHistoryMenuPopup, TableBodyHistoryButton, } from './style'; interface HistoryTooltipProps { className?: string, messages: { changesHistory: string, noChanges: string, }, formatValue?: (value: any) => string, getChangeHistory?: () => Promise, } export const HistoryTooltip: React.FC = ({ className, messages, formatValue, getChangeHistory }) => { const [history, setHistory] = React.useState(null); const [show, setShow] = React.useState(false); const formatChangeHistoryDate = (change: any) => { const date = change && change.date ? typeof change.date === 'number' ? change.date : isNaN(Number(change.date)) ? 0 : Number(change.date) : 0; return date ? `(${new Date(date).toDateString()}, ${new Date(date).toLocaleTimeString('en-US')}) ` : ''; } const handleCellContextMenuOpen = (event: any) => { setShow(!show); if (getChangeHistory) { getChangeHistory() .then(response => { if (response && response.changes) { setHistory(response.changes); } }); } } const onClose = () => { setShow(!show); setHistory(null); }; return ( { history && history.length > 0 ? history.map((change: any, key: any) => ( )) : history && {messages.noChanges} } ) : ( ) } placement="bottom" > ); }