From ea7d1e5eb6e66301467d1281908520716a5d56c7 Mon Sep 17 00:00:00 2001 From: spaenleh Date: Mon, 25 Mar 2024 11:55:58 +0100 Subject: [PATCH] fix: make PR changes --- src/components/APIChecker.tsx | 36 +++++++---------------------------- 1 file changed, 7 insertions(+), 29 deletions(-) diff --git a/src/components/APIChecker.tsx b/src/components/APIChecker.tsx index da1cab8d..59719041 100644 --- a/src/components/APIChecker.tsx +++ b/src/components/APIChecker.tsx @@ -1,5 +1,3 @@ -import { useState } from 'react'; - import { Replay } from '@mui/icons-material'; import { LoadingButton } from '@mui/lab'; import { Alert, AlertTitle, Box, Stack, Typography } from '@mui/material'; @@ -9,42 +7,22 @@ import { useAuthTranslation } from '../config/i18n'; import { axios, useQuery } from '../config/queryClient'; import { AUTH } from '../langs/constants'; -const APIChecker = (): JSX.Element | null => { +const APIChecker = (): JSX.Element | false => { const { t } = useAuthTranslation(); - const [noConnection, setNoConnection] = useState(false); - const { isSuccess, isLoading, refetch } = useQuery({ + const { isSuccess, isLoading, refetch, isError } = useQuery({ queryKey: ['apiStatus'], queryFn: () => axios .get(`${API_HOST}/status`, { withCredentials: false }) - .then(({ data }) => data) - .catch(() => setNoConnection(true)), - retry: 1, + .then(({ data }) => data), + retry: 0, }); if (isSuccess) { - return ( - - - - - - Connected to Graasp backend - - - ); + return false; } - if (noConnection) { + if (isError) { return ( @@ -66,6 +44,6 @@ const APIChecker = (): JSX.Element | null => { ); } - return null; + return false; }; export default APIChecker;