aboutsummaryrefslogtreecommitdiffstats
path: root/src/pages/FormPage/ErrorPage.tsx
blob: 351170b71678a25fefc83ff814b20dab6155d9d9 (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
/** @jsx jsx */
import {jsx, css} from "@emotion/react";
import {Link} from "react-router-dom";
import React from "react";

import HeaderBar from "../../components/HeaderBar";

import {Form} from "../../api/forms";
import {clearAuth} from "../../api/auth";
import * as styles from "../../commonStyles";


interface ErrorProps {
    form: Form
    message: string
}

const refreshStyles = css`
    padding: 0.55rem 4.25rem;
`;


export default function ErrorPage(props: ErrorProps): JSX.Element {
    clearAuth();

    return (
        <div>
            <HeaderBar title={props.form.name} description={props.form.description}/>
            <div css={[styles.unselectable, styles.mainTextStyles]}>
                <h3 css={styles.selectable}>{props.message}</h3>
                <div css={styles.navigationStyles}>
                    <Link css={styles.returnButtonStyles} to="/">Return Home</Link>
                    <div css={styles.actionButtonStyles}>
                        <button
                            type="button" css={refreshStyles}
                            onClick={location.reload.bind(window.location)} // TODO: State should probably be saved here
                        >
                            Refresh
                        </button>
                    </div>
                </div>
            </div>
        </div>
    );
}