diff options
| author | 2020-12-14 10:52:14 +0200 | |
|---|---|---|
| committer | 2020-12-14 10:52:14 +0200 | |
| commit | ba72b3c5f4c44d45a5eeaf5212b1ec50db747968 (patch) | |
| tree | 4dcb2064e6750a1600a10b3f63da953b51436834 | |
| parent | Update FormListing component to match with new forms interface (diff) | |
Update LandingPage to use forms from API
| -rw-r--r-- | src/pages/LandingPage.tsx | 19 | 
1 files changed, 17 insertions, 2 deletions
| 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> | 
