blob: a675f8eeadbc039930e48df42583a0a60210e196 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
/** @jsx jsx */
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";
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>();
const [form, setForm] = useState<Form>();
useEffect(() => {
getForm(id).then(form => {
setForm(form);
})
})
if (!form) {
return <Loading/>
}
return <div>
<HeaderBar title={form.title}/>
<div css={{marginLeft: "20px"}}>
<h1>{form.description}</h1>
<Link to="/" css={{color: "white"}}>Return home</Link>
</div>
</div>
}
export default FormPage;
|