diff --git a/src/qqq/components/DashboardWidgets.tsx b/src/qqq/components/DashboardWidgets.tsx index 7d19f6d..5fe63bf 100644 --- a/src/qqq/components/DashboardWidgets.tsx +++ b/src/qqq/components/DashboardWidgets.tsx @@ -22,7 +22,7 @@ import {QInstance} from "@kingsrook/qqq-frontend-core/lib/model/metaData/QInstan import Card from "@mui/material/Card"; import Grid from "@mui/material/Grid"; import parse from "html-react-parser"; -import React, {useEffect, useState} from "react"; +import React, {useEffect, useReducer, useState} from "react"; import {useLocation} from "react-router-dom"; import MDBadgeDot from "qqq/components/Temporary/MDBadgeDot"; import MDBox from "qqq/components/Temporary/MDBox"; @@ -53,6 +53,7 @@ function DashboardWidgets({widgetNameList, entityPrimaryKey}: Props): JSX.Elemen const [widgets, setWidgets] = useState([] as any[]); const [widgetNames, setWidgetNames] = useState([] as any[]); const [widgetCounter, setWidgetCounter] = useState(0); + const [, forceUpdate] = useReducer((x) => x + 1, 0); useEffect(() => { @@ -77,6 +78,7 @@ function DashboardWidgets({widgetNameList, entityPrimaryKey}: Props): JSX.Elemen { widgets[i] = await qController.widget(widgetNameList[i], `id=${entityPrimaryKey}`); setWidgetCounter(widgetCounter + 1); + forceUpdate(); })(); } setWidgets(widgets); @@ -105,20 +107,34 @@ function DashboardWidgets({widgetNameList, entityPrimaryKey}: Props): JSX.Elemen { widgets.map((widget, i) => ( - - { - widget.type === "table" && ( - - ) - } - + { + widget.type === "table" && ( + + ) + } + { + widget.type === "html" && ( + + + + + {widget.title} + + + {parse(widget.html)} + + + + + ) + } )) } @@ -146,22 +162,6 @@ function DashboardWidgets({widgetNameList, entityPrimaryKey}: Props): JSX.Elemen ) } - { - widget.type === "html" && ( - - - - - {widget.title} - - - {parse(widget.html)} - - - - - ) - } { widget.type === "lineChart" && ( diff --git a/src/qqq/components/QRecordSidebar/index.tsx b/src/qqq/components/QRecordSidebar/index.tsx index 88f1eb7..91bc3ac 100644 --- a/src/qqq/components/QRecordSidebar/index.tsx +++ b/src/qqq/components/QRecordSidebar/index.tsx @@ -47,7 +47,7 @@ function QRecordSidebar({tableSections, widgetNames, light}: Props): JSX.Element // insert widgets after identity (first) table section // ///////////////////////////////////////////////////////// const sidebarEntries = [] as SidebarEntry[]; - tableSections.forEach((section, index) => + tableSections && tableSections.forEach((section, index) => { if (index === 1 && widgetNames) {