diff --git a/assets/exclamation-triangle.svg b/assets/exclamation-triangle.svg
new file mode 100644
index 0000000000..46bef5bcba
--- /dev/null
+++ b/assets/exclamation-triangle.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/components/common/ErrorMessage.js b/components/common/ErrorMessage.js
new file mode 100644
index 0000000000..5747f2269f
--- /dev/null
+++ b/components/common/ErrorMessage.js
@@ -0,0 +1,14 @@
+import React from 'react';
+import { FormattedMessage } from 'react-intl';
+import Icon from './Icon';
+import Exclamation from 'assets/exclamation-triangle.svg';
+import styles from './ErrorMessage.module.css';
+
+export default function ErrorMessage() {
+ return (
+
- {!data ? (
-
- ) : (
+ {!data && loading &&
}
+ {error &&
}
+ {data && !error && (
<>
}
diff --git a/components/metrics/MetricsTable.js b/components/metrics/MetricsTable.js
index 3ac8a395db..6850a3bf9d 100644
--- a/components/metrics/MetricsTable.js
+++ b/components/metrics/MetricsTable.js
@@ -13,6 +13,7 @@ import { formatNumber, formatLongNumber } from 'lib/format';
import useDateRange from 'hooks/useDateRange';
import usePageQuery from 'hooks/usePageQuery';
import styles from './MetricsTable.module.css';
+import ErrorMessage from '../common/ErrorMessage';
export default function MetricsTable({
websiteId,
@@ -36,7 +37,7 @@ export default function MetricsTable({
query: { url },
} = usePageQuery();
- const { data } = useFetch(
+ const { data, loading, error } = useFetch(
`/api/website/${websiteId}/rankings`,
{
type,
@@ -61,7 +62,7 @@ export default function MetricsTable({
return items;
}
return [];
- }, [data, dataFilter, filterOptions]);
+ }, [data, error, dataFilter, filterOptions]);
const handleSetFormat = () => setFormat(state => !state);
@@ -86,8 +87,9 @@ export default function MetricsTable({
return (
- {!data &&
}
- {data && (
+ {!data && loading &&
}
+ {error &&
}
+ {data && !error && (
<>
{title}
diff --git a/components/metrics/WebsiteChart.js b/components/metrics/WebsiteChart.js
index ea86ad3ec8..6a07afe5e2 100644
--- a/components/metrics/WebsiteChart.js
+++ b/components/metrics/WebsiteChart.js
@@ -13,6 +13,7 @@ import usePageQuery from 'hooks/usePageQuery';
import { getDateArray, getDateLength } from 'lib/date';
import Times from 'assets/times.svg';
import styles from './WebsiteChart.module.css';
+import ErrorMessage from '../common/ErrorMessage';
export default function WebsiteChart({
websiteId,
@@ -31,7 +32,7 @@ export default function WebsiteChart({
query: { url },
} = usePageQuery();
- const { data, loading } = useFetch(
+ const { data, loading, error } = useFetch(
`/api/website/${websiteId}/pageviews`,
{
start_at: +startDate,
@@ -83,6 +84,7 @@ export default function WebsiteChart({
+ {error &&
}
= 400) {
+ setError(data);
+ setData(null);
+ } else {
+ setData(data);
+ }
+
setStatus(status);
onDataLoad(data);
} catch (e) {
diff --git a/package.json b/package.json
index f5fe6909ee..0d602350bc 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "umami",
- "version": "0.76.0",
+ "version": "0.77.0",
"description": "A simple, fast, website analytics alternative to Google Analytics. ",
"author": "Mike Cao ",
"license": "MIT",