diff --git a/pwa/src/components/LandingPage.tsx b/pwa/src/components/LandingPage.tsx index 3a787c4..bfccc57 100644 --- a/pwa/src/components/LandingPage.tsx +++ b/pwa/src/components/LandingPage.tsx @@ -1,6 +1,6 @@ import React, { ReactElement } from "react"; import { WhiteSpace, Button } from "antd-mobile"; -import Icon, { UserAddOutlined } from "@ant-design/icons"; +import { UserAddOutlined } from "@ant-design/icons"; import "../scss/LandingPage.scss"; diff --git a/pwa/src/components/Login.tsx b/pwa/src/components/Login.tsx index 5766b06..d181260 100644 --- a/pwa/src/components/Login.tsx +++ b/pwa/src/components/Login.tsx @@ -1,31 +1,29 @@ -import React, { ReactElement } from 'react' -import useApi from '../hooks/useApi' -import {InputItem, Button} from 'antd-mobile' -import '../scss/Login.scss' +import React, { ReactElement } from "react"; +import useApi from "../hooks/useApi"; +import { InputItem, Button } from "antd-mobile"; +import "../scss/Login.scss"; export default function Login(): ReactElement { - const {response, error, isLoading} = useApi("") + const { response, isLoading } = useApi(""); return ( <>
Loading API Fetch: {isLoading.toString()}
- {response && -API Fetch Result: {JSON.stringify(response)}
- } + {response &&API Fetch Result: {JSON.stringify(response)}
} > - ) + ); } diff --git a/pwa/src/hooks/useApi.tsx b/pwa/src/hooks/useApi.tsx index 50eb0cd..a292d8b 100644 --- a/pwa/src/hooks/useApi.tsx +++ b/pwa/src/hooks/useApi.tsx @@ -1,19 +1,18 @@ -import React from 'react' +import React from "react"; const useApi = (route: string) => { const [response, setResponse] = React.useState(null); const [error, setError] = React.useState(null); const [isLoading, setIsLoading] = React.useState(false); - + /* istanbul ignore next */ const getUrl = () => { - if (process.env.environment === "docker"){ - return "http://api:4000/" + if (process.env.environment === "docker") { + return "http://api:4000/"; + } else { + return "http://localhost:4000/"; } - else { - return "http://localhost:4000/" - } - } + }; React.useEffect(() => { const fetchData = async () => { @@ -22,14 +21,15 @@ const useApi = (route: string) => { const res = await fetch(getUrl() + route); const json = await res.json(); setResponse(json); - setIsLoading(false) + setIsLoading(false); } catch (error) { setError(error); } }; fetchData(); + // eslint-disable-next-line react-hooks/exhaustive-deps }, []); return { response, error, isLoading }; }; -export default useApi \ No newline at end of file +export default useApi;