feat: 404 on non-existent dashboards

This commit is contained in:
Vyacheslav Matyukhin 2022-04-10 16:49:45 +03:00
parent 986f7ab888
commit 115bd30708
No known key found for this signature in database
GPG Key ID: 3D2A774C5489F96C

View File

@ -1,4 +1,5 @@
import { GetServerSideProps, NextPage } from "next";
import Error from "next/error";
import Link from "next/link";
import { DashboardItem } from "../../../backend/dashboards";
@ -32,6 +33,10 @@ export const getServerSideProps: GetServerSideProps<Props> = async (
platformsConfig
);
if (!dashboardItem) {
context.res.statusCode = 404;
}
return {
props: {
dashboardForecasts: frontendDashboardForecasts,
@ -89,7 +94,9 @@ const ViewDashboardPage: NextPage<Props> = ({
<div className="flex flex-col my-8 space-y-8">
{dashboardItem ? (
<DashboardMetadata dashboardItem={dashboardItem} />
) : null}
) : (
<Error statusCode={404} />
)}
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
<DisplayForecasts