From 9163b13e92a8285deed1c812897035a037202ba2 Mon Sep 17 00:00:00 2001 From: Brandon Egger Date: Thu, 24 Aug 2023 10:11:19 -0500 Subject: [PATCH] add error notice component to resource page --- src/components/notice.tsx | 17 +++++++++++++++++ src/pages/resources/index.tsx | 10 +++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 src/components/notice.tsx diff --git a/src/components/notice.tsx b/src/components/notice.tsx new file mode 100644 index 0000000..e0db851 --- /dev/null +++ b/src/components/notice.tsx @@ -0,0 +1,17 @@ +import { ExclamationTriangleIcon } from "@heroicons/react/24/outline" + +export const ErrorNotice = ({header, body, icon}: {header?: string, body?: string, icon?: boolean}) => { + return <> + {header ? ( +
+ {icon ? ( +
+ +
+ ) : undefined} + {header} + {body ? (

{body}

) : undefined} +
+ ) : undefined} + +} \ No newline at end of file diff --git a/src/pages/resources/index.tsx b/src/pages/resources/index.tsx index d27cb1d..dbcb3f9 100644 --- a/src/pages/resources/index.tsx +++ b/src/pages/resources/index.tsx @@ -8,6 +8,7 @@ import { parseQueryData } from "~/utils/parseSearchForm"; import Footer from "~/components/Footer"; import Header from "~/components/Header"; import { LoadingBarChart } from "~/components/LoadingBarChart"; +import { ErrorNotice } from "~/components/notice"; const Resources = () => { const router = useRouter(); @@ -31,9 +32,16 @@ const Resources = () => { const printLink = `${router.route}/print?${printQueryStr}`; const ConditionalTable = () => { - if (!resourceQuery.data) { + if (resourceQuery.isLoading) { return ; } + + if (!resourceQuery.data || resourceQuery.isError) { + return
+ +
+ } const totalPages = Math.ceil(resourceQuery.data.count / queryData.perPage);