diff --git a/CHANGELOG.md b/CHANGELOG.md index f14dbc7..e8d6aef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - ability to change user passwords - add default page background - add environment list in [doc](doc/environment.md) +- show error message on homepage in case there is a problem with api connection ### Changed diff --git a/graphql/query/status.query.ts b/graphql/query/status.query.ts new file mode 100644 index 0000000..ebb8893 --- /dev/null +++ b/graphql/query/status.query.ts @@ -0,0 +1,20 @@ +import { QueryHookOptions, QueryResult, useQuery } from '@apollo/client' +import { gql } from '@apollo/client/core' + +interface Data { + status: { + version: string + } +} + +const QUERY = gql` + query status { + status { + version + } + } +` + +export const useStatusQuery = ( + options?: QueryHookOptions +): QueryResult => useQuery(QUERY, options) diff --git a/pages/index.tsx b/pages/index.tsx index 8d31377..a1f83dc 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -1,12 +1,13 @@ -import { Layout } from 'antd' +import { Alert, Layout } from 'antd' import { AuthFooter } from 'components/auth/footer' -import { GetStaticProps, NextPage } from 'next' +import { NextPage } from 'next' import getConfig from 'next/config' import { useRouter } from 'next/router' import React, { useEffect, useState } from 'react' import { useTranslation } from 'react-i18next' import { LoadingPage } from '../components/loading.page' import { Omf } from '../components/omf' +import { useStatusQuery } from '../graphql/query/status.query' import { NextConfigType } from '../next.config.type' const { publicRuntimeConfig } = getConfig() as NextConfigType @@ -17,6 +18,7 @@ const Index: NextPage = () => { const [loading, setLoading] = useState( publicRuntimeConfig.spa || (process.browser && router.pathname !== window.location.pathname) ) + const status = useStatusQuery() useEffect(() => { if (router.pathname !== window.location.pathname) { @@ -67,6 +69,9 @@ const Index: NextPage = () => { src={require('../assets/images/logo_white.png') as string} /> + {status.error && ( + + )} )