aboutsummaryrefslogtreecommitdiff
path: root/src/components/EventCard/Logs.tsx
blob: d78fbd88668f0ffef0ead30f6e2d399991dc3b5a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import React from 'react';
import { Markdown } from 'react-benzin';
import { useEventLogs } from '../../hooks/APIClient';

interface PropTypes {
  eventId: string;
}

const DATE_OPTIONS = { dateStyle: 'short' };

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;