diff options
| author | 2020-12-14 19:18:19 +0000 | |
|---|---|---|
| committer | 2020-12-14 19:18:19 +0000 | |
| commit | a1963eb56f9682a6315a06a075d09314822dbfd9 (patch) | |
| tree | d0856e1326516447a33951de623770787f6ef996 /src/pages | |
| parent | Merge pull request #29 from python-discord/dependabot/npm_and_yarn/ini-1.3.8 (diff) | |
| parent | Simplify Axios client baseURL definition (diff) | |
Merge pull request #30 from python-discord/ks123/discovery
Diffstat (limited to 'src/pages')
| -rw-r--r-- | src/pages/FormPage.tsx | 14 | ||||
| -rw-r--r-- | src/pages/LandingPage.tsx | 19 | 
2 files changed, 19 insertions, 14 deletions
diff --git a/src/pages/FormPage.tsx b/src/pages/FormPage.tsx index a675f8e..ad746c7 100644 --- a/src/pages/FormPage.tsx +++ b/src/pages/FormPage.tsx @@ -2,26 +2,16 @@  import { jsx } from "@emotion/core";  import { Link } from "react-router-dom"; -import { HashLoader } from "react-spinners"; -  import { useParams } from "react-router";  import HeaderBar from "../components/HeaderBar";  import { useEffect, useState } from "react";  import { Form, getForm } from "../api/forms"; +import Loading from "../components/Loading";  interface PathParams {      id: string  } -function Loading() { -    return <div> -        <HeaderBar title={"Loading..."}/> -        <div css={{display: "flex", justifyContent: "center"}}> -            <HashLoader color="white"/> -        </div> -    </div> -} -  function FormPage() {      const { id } = useParams<PathParams>(); @@ -38,7 +28,7 @@ function FormPage() {      }      return <div> -        <HeaderBar title={form.title}/> +        <HeaderBar title={form.name}/>          <div css={{marginLeft: "20px"}}>              <h1>{form.description}</h1>              <Link to="/" css={{color: "white"}}>Return home</Link> diff --git a/src/pages/LandingPage.tsx b/src/pages/LandingPage.tsx index 2e2bfd6..127f166 100644 --- a/src/pages/LandingPage.tsx +++ b/src/pages/LandingPage.tsx @@ -1,13 +1,28 @@  /** @jsx jsx */  import { css, jsx } from "@emotion/core"; +import { useEffect, useState } from "react";  import HeaderBar from "../components/HeaderBar";  import FormListing from "../components/FormListing"; -import { getForms } from "../api/forms"; +import { getForms, Form } from "../api/forms";  import OAuth2Button from "../components/OAuth2Button"; +import Loading from "../components/Loading";  function LandingPage() { +  const [forms, setForms] = useState<Form[]>(); + +  useEffect(() => { +    const fetchForms = async () => { +      setForms(await getForms()); +    } +    fetchForms(); +  }); + +  if (!forms) { +    return <Loading/>; +  } +    return <div>      <HeaderBar/>      <div> @@ -22,7 +37,7 @@ function LandingPage() {          <OAuth2Button/> -        {getForms().map(form => ( +        {forms.map(form => (            <FormListing key={form.id} form={form}/>          ))}        </div>  |