Skip to content

Commit

Permalink
no stats endpoint -- no stats page
Browse files Browse the repository at this point in the history
  • Loading branch information
isstuev committed May 24, 2023
1 parent f8eeafb commit 72de8ab
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
7 changes: 6 additions & 1 deletion lib/hooks/useNavItems.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,12 @@ export default function useNavItems(): ReturnType {
icon: appsIcon,
isActive: pathname.startsWith('/app'),
} : null,
{ text: 'Charts & stats', nextRoute: { pathname: '/stats' as const }, icon: statsIcon, isActive: pathname === '/stats' },
appConfig.statsApi.endpoint ? {
text: 'Charts & stats',
nextRoute: { pathname: '/stats' as const },
icon: statsIcon,
isActive: pathname === '/stats',
} : null,
{
text: 'API',
icon: apiDocsIcon,
Expand Down
14 changes: 12 additions & 2 deletions pages/stats.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import type { NextPage } from 'next';
import type { NextPage, GetServerSideProps } from 'next';
import Head from 'next/head';
import React from 'react';

import appConfig from 'configs/app/config';
import type { Props } from 'lib/next/getServerSideProps';
import { getServerSideProps as getServerSidePropsBase } from 'lib/next/getServerSideProps';

import Stats from '../ui/pages/Stats';

Expand All @@ -17,4 +19,12 @@ const StatsPage: NextPage = () => {

export default StatsPage;

export { getServerSideProps } from 'lib/next/getServerSideProps';
export const getServerSideProps: GetServerSideProps<Props> = async(args) => {
if (!appConfig.statsApi.endpoint) {
return {
notFound: true,
};
}

return getServerSidePropsBase(args);
};

0 comments on commit 72de8ab

Please sign in to comment.