diff --git a/packages/app/src/components/DataTable.tsx b/packages/app/src/components/DataTable.tsx index aab60b76..f1333343 100644 --- a/packages/app/src/components/DataTable.tsx +++ b/packages/app/src/components/DataTable.tsx @@ -93,6 +93,7 @@ export const DataTable = () => { const [visibleSets, setVisibleSets] = useState(null); const [hiddenSets, setHiddenSets] = useState(null); const [loading, setLoading] = useState(false); + const [error, setError] = useState(false); useEffect(() => { setLoading(true); @@ -102,12 +103,16 @@ export const DataTable = () => { localforage.getItem("visibleSets"), localforage.getItem("hiddenSets") ]).then(([storedData, storedRows, storedVisibleSets, storedHiddenSets]) => { - console.log("Fetched items!"); + if (storedData === null || storedRows === null || storedVisibleSets === null || storedHiddenSets === null) { + setError(true); + setLoading(false); + return; + } setData(storedData as CoreUpsetData); setRows(storedRows as ReturnType); setVisibleSets(storedVisibleSets as string[]); setHiddenSets(storedHiddenSets as string[]); - }); + }) setLoading(false); }, []); @@ -196,71 +201,74 @@ export const DataTable = () => { return ( <> - - - - - -
-

UpSet Data Table

- downloadElementsAsCSV(tableRows, ["elementName", "size"], "upset2_datatable")} /> -
- -
- -
-

Visible Sets

- downloadElementsAsCSV(visibleSetRows, ["setName", "size"], "upset2_visiblesets_table")} /> -
- + { error ? +

Error fetching data...

: + + + + + +
+

UpSet Data Table

+ downloadElementsAsCSV(tableRows, ["elementName", "size"], "upset2_datatable")} /> +
+ +
+ +
+

Visible Sets

+ downloadElementsAsCSV(visibleSetRows, ["setName", "size"], "upset2_visiblesets_table")} /> +
+ +
+ +
+

Hidden Sets

+ downloadElementsAsCSV(hiddenSetRows, ["setName", "size"], "upset2_hiddensets_table")} /> +
+ +
- -
-

Hidden Sets

- downloadElementsAsCSV(hiddenSetRows, ["setName", "size"], "upset2_hiddensets_table")} /> -
- -
-
+ } ) } \ No newline at end of file