From 6be4377768562b96919d4a62ca3a1b814577cc51 Mon Sep 17 00:00:00 2001 From: Sidney Alcantara Date: Mon, 10 Oct 2022 13:34:09 +1100 Subject: [PATCH] display offline indicator instead of empty table --- src/components/ErrorFallback.tsx | 43 +++++++++++++--------- src/components/Table/EmptyTable.tsx | 55 +++++++++++++++++++---------- 2 files changed, 64 insertions(+), 34 deletions(-) diff --git a/src/components/ErrorFallback.tsx b/src/components/ErrorFallback.tsx index 1b6d0159..ba3b8b97 100644 --- a/src/components/ErrorFallback.tsx +++ b/src/components/ErrorFallback.tsx @@ -93,29 +93,40 @@ export function ErrorFallbackContents({ } else { renderProps = { Icon: ReloadIcon, - message: "New update available", + message: "Update available", description: ( - <> - - Reload this page to get the latest update - - - + ), }; } } if (error.message.includes("Failed to fetch")) { - renderProps = { Icon: OfflineIcon, message: "You’re offline" }; + renderProps = { + Icon: OfflineIcon, + message: "You’re offline", + description: isOffline ? null : ( + + ), + }; } return ; diff --git a/src/components/Table/EmptyTable.tsx b/src/components/Table/EmptyTable.tsx index 726f62f9..b9b3fadc 100644 --- a/src/components/Table/EmptyTable.tsx +++ b/src/components/Table/EmptyTable.tsx @@ -1,9 +1,14 @@ import { useAtom, useSetAtom } from "jotai"; +import { Offline, Online } from "react-detect-offline"; import { Grid, Stack, Typography, Button, Divider } from "@mui/material"; -import { Import as ImportIcon } from "@src/assets/icons"; -import { AddColumn as AddColumnIcon } from "@src/assets/icons"; +import { + Import as ImportIcon, + AddColumn as AddColumnIcon, +} from "@src/assets/icons"; +import OfflineIcon from "@mui/icons-material/CloudOff"; +import EmptyState from "@src/components/EmptyState"; import ImportData from "@src/components/TableToolbar/ImportData/ImportData"; import { @@ -125,21 +130,35 @@ export default function EmptyTable() { } return ( - - {contents} - + <> + + + + + + + {contents} + + + ); }