import React from 'react';
import { Markdown } from 'react-benzin';
import { useEventLogs } from '../../hooks/APIClient';

interface PropTypes {
  eventId: string;
}

const Logs: React.FC<PropTypes> = ({ eventId }) => {
  const { data: logs } = useEventLogs(eventId);

  const logString = logs?.map(log => {
    const timestamp = new Date(log.createdAt).toLocaleTimeString();
    return `[${timestamp}] ${log.message}`;
  }).join('\n');

  return <Markdown data={'```\n' + logString + '\n```'} />;
};

export default Logs;
