last20Messages von Redux bekommen, so wird Übergabparameter und props nicht brauchen
This commit is contained in:
@@ -1,13 +1,35 @@
|
|||||||
"use client";
|
"use client";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
import { useSelector } from "react-redux";
|
||||||
|
import { RootState } from "../../../redux/store";
|
||||||
|
|
||||||
interface Last20MessagesTableProps {
|
const Last20MessagesTable: React.FC = () => {
|
||||||
last20Messages: string[][];
|
const rawLast20Messages = useSelector(
|
||||||
}
|
(state: RootState) => state.variables.last20Messages
|
||||||
|
);
|
||||||
|
|
||||||
|
// Hilfsfunktion zum Parsen der Nachrichten
|
||||||
|
const parseMessages = (messages: string | null) => {
|
||||||
|
if (typeof messages === "string") {
|
||||||
|
messages = messages
|
||||||
|
.replace(/<tr>/g, "\n")
|
||||||
|
.replace(/<\/?td>/g, "")
|
||||||
|
.replace(/<\/tr>/g, "")
|
||||||
|
.trim();
|
||||||
|
const rows = messages.split("\n");
|
||||||
|
return rows.map((row) => [
|
||||||
|
row.substring(0, 5),
|
||||||
|
row.substring(5, 10),
|
||||||
|
row.substring(10, 29),
|
||||||
|
row.substring(33, row.length - 1),
|
||||||
|
row.substring(row.length - 1),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
return [];
|
||||||
|
};
|
||||||
|
|
||||||
|
const last20Messages = parseMessages(rawLast20Messages);
|
||||||
|
|
||||||
const Last20MessagesTable: React.FC<Last20MessagesTableProps> = ({
|
|
||||||
last20Messages,
|
|
||||||
}) => {
|
|
||||||
return (
|
return (
|
||||||
<div className="bg-white shadow-md rounded-lg w-full lg:w-2/3 overflow-auto flex ">
|
<div className="bg-white shadow-md rounded-lg w-full lg:w-2/3 overflow-auto flex ">
|
||||||
<table className="min-w-full border border-gray-200 text-left table-fixed ">
|
<table className="min-w-full border border-gray-200 text-left table-fixed ">
|
||||||
|
|||||||
@@ -5,5 +5,5 @@
|
|||||||
2: Patch oder Hotfix (Bugfixes oder kleine Änderungen).
|
2: Patch oder Hotfix (Bugfixes oder kleine Änderungen).
|
||||||
|
|
||||||
*/
|
*/
|
||||||
const webVersion = "1.6.20";
|
const webVersion = "1.6.21";
|
||||||
export default webVersion;
|
export default webVersion;
|
||||||
|
|||||||
@@ -159,7 +159,7 @@ function Dashboard() {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex flex-col lg:flex-row gap-0 overflow-hidden flex-grow">
|
<div className="flex flex-col lg:flex-row gap-0 overflow-hidden flex-grow">
|
||||||
<Last20MessagesTable last20Messages={last20Messages} />
|
<Last20MessagesTable />
|
||||||
|
|
||||||
<div
|
<div
|
||||||
className="shadow-md rounded-lg
|
className="shadow-md rounded-lg
|
||||||
|
|||||||
Reference in New Issue
Block a user