= {};
- for (const e in columns) {
- const item = columns[e].id;
- rowObject[item] = null;
- }
- return new Array(size).fill(rowObject);
+export function getLoadingRows(size = 10): loadingTableRows[] {
+ const rows = new Array(size).fill({});
+ console.log(rows);
+ return rows;
}
/***********************************
diff --git a/packages/ui/src/components/Section/SectionItem.tsx b/packages/ui/src/components/Section/SectionItem.tsx
index acfa4c448..df6aedfeb 100644
--- a/packages/ui/src/components/Section/SectionItem.tsx
+++ b/packages/ui/src/components/Section/SectionItem.tsx
@@ -8,7 +8,7 @@ import sectionStyles from "./sectionStyles";
import { createShortName } from "../Summary/utils";
import PartnerLockIcon from "../PartnerLockIcon";
import SectionViewToggle from "./SectionViewToggle";
-import { ReactNode, useState } from "react";
+import { ReactNode, useEffect, useState } from "react";
import { VIEW } from "../../constants";
import { SummaryLoader } from "../PublicationsDrawer";
@@ -46,7 +46,7 @@ function SectionItem({
entity,
showEmptySection = false,
showContentLoading = false,
- loadingMessage,
+ loadingMessage = "Loading data. This may take some time...",
renderChart,
defaultView = VIEW.table,
}: SectionItemProps): ReactNode {
@@ -55,6 +55,15 @@ function SectionItem({
const shortName = createShortName(definition);
let hasData = false;
const [selectedView, setSelectedView] = useState(defaultView);
+ const [showDelayLoadingMessage, setShowDelayLoadingMessage] = useState(false);
+
+ useEffect(() => {
+ const delayLoaderTimer = setTimeout(() => setShowDelayLoadingMessage(true), 5000);
+
+ return () => {
+ clearTimeout(delayLoaderTimer);
+ };
+ }, []);
if (data && entity && data[entity]) {
hasData = definition.hasData(data[entity]);
@@ -62,6 +71,23 @@ function SectionItem({
if (!hasData && !showEmptySection && !loading) return null;
+ function getSelectedView(): ReactNode {
+ if (error) return ;
+ if (showContentLoading && loading)
+ return (
+ <>
+
+ {showDelayLoadingMessage && loadingMessage}
+
+
+ >
+ );
+ if (selectedView === VIEW.table) return renderBody();
+ if (selectedView === VIEW.chart) return renderChart();
+ // if (!loading && !hasData && showEmptySection)
+ return No data available for this {entity}.
;
+ }
+
return (
@@ -109,32 +135,7 @@ function SectionItem({
-
- <>
- {error && }
- {showContentLoading &&
- loading &&
- (loadingMessage ? (
- theme.palette.grey[100]}
- display="flex"
- flexDirection="column"
- justifyContent="center"
- >
-
-
- ) : (
-
- ))}
- {hasData && selectedView === VIEW.table && renderBody()}
- {hasData && selectedView === VIEW.chart && renderChart()}
- {showEmptySection && (
- No data available for this {entity}.
- )}
- >
-
+ {getSelectedView()}