From c852da10418cbeb21fceda4b93339b2c82ea9838 Mon Sep 17 00:00:00 2001 From: Callum Forrester Date: Tue, 16 Apr 2024 12:18:54 +0100 Subject: [PATCH] Display logs in a table --- src/App.tsx | 31 ++++++++++++++++++++++++++++--- src/components/Box.tsx | 38 ++++++++++++++++++-------------------- 2 files changed, 46 insertions(+), 23 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index d3020f3..42518ab 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -3,9 +3,17 @@ import { useEffect, useState } from "react"; import { theme } from "./theme"; import BoxBasic from "./components/Box"; +import Table from '@mui/material/Table'; +import TableBody from '@mui/material/TableBody'; +import TableCell from '@mui/material/TableCell'; +import TableContainer from '@mui/material/TableContainer'; +import TableRow from '@mui/material/TableRow'; +import Paper from '@mui/material/Paper'; + + function App() { - const [logMessage, setLog] = useState([]); + const [logs, setLogs] = useState([]); useEffect(() => { async function fetchData( url: string, @@ -37,7 +45,7 @@ function App() { // Parsing the response as JSON const logdata = await response.json(); const message = getMessage(logdata) || ["No logs found"]; - setLog(message); + setLogs(message); } catch (error) { console.error("Error fetching data:", error); throw error; @@ -108,7 +116,24 @@ function App() { return (

Athena Logpanel

- {logMessage}

}>
+ + + + + {logs.map((log) => ( + + + {log} + + + ))} + +
+
+
); } diff --git a/src/components/Box.tsx b/src/components/Box.tsx index 4ea74ba..179ef6d 100644 --- a/src/components/Box.tsx +++ b/src/components/Box.tsx @@ -1,26 +1,24 @@ import * as React from 'react'; import Box from '@mui/material/Box'; -// Define the potential types for the Box -type Content = string| JSX.Element | number | (() => React.ReactNode); -interface BoxProps { - content:T; +interface BoxProps { + children?: React.ReactNode; +} + +const BoxBasic = (props: BoxProps) => { + return ( + + {props.children} + + ); } -// FC React functional component. -const BoxBasic:React.FC> = ({content}) =>{ - return ( - - {typeof content === 'function' ? content() : content} - - ); - } export default BoxBasic;