From 115bd30708a25134c4a6596b474f2adb4bbedb15 Mon Sep 17 00:00:00 2001 From: Vyacheslav Matyukhin Date: Sun, 10 Apr 2022 16:49:45 +0300 Subject: [PATCH] feat: 404 on non-existent dashboards --- src/pages/dashboards/view/[id].tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/pages/dashboards/view/[id].tsx b/src/pages/dashboards/view/[id].tsx index bce791b..128f9f5 100644 --- a/src/pages/dashboards/view/[id].tsx +++ b/src/pages/dashboards/view/[id].tsx @@ -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 = async ( platformsConfig ); + if (!dashboardItem) { + context.res.statusCode = 404; + } + return { props: { dashboardForecasts: frontendDashboardForecasts, @@ -89,7 +94,9 @@ const ViewDashboardPage: NextPage = ({
{dashboardItem ? ( - ) : null} + ) : ( + + )}