[CORL-588] Download and token fixes (#2519)

* fix: fixed up download handler to improve error handling

* fix: fixed invalid expiry date being set

* fix: nick found bug
This commit is contained in:
Wyatt Johnson
2019-09-04 17:23:59 -04:00
committed by Kim Gardner
parent a696ef9be5
commit ac1ed45e4b
15 changed files with 442 additions and 370 deletions
@@ -1,5 +1,5 @@
import { Localized } from "fluent-react/compat";
import React, { FunctionComponent } from "react";
import React, { FunctionComponent, useCallback, useState } from "react";
import { Button, HorizontalGutter } from "coral-ui/components";
@@ -10,6 +10,11 @@ interface Props {
}
const DownloadForm: FunctionComponent<Props> = ({ token }) => {
const [submitted, setSubmitted] = useState(false);
const onClick = useCallback(() => {
setSubmitted(true);
}, [setSubmitted]);
return (
<HorizontalGutter size="double">
<form
@@ -23,7 +28,8 @@ const DownloadForm: FunctionComponent<Props> = ({ token }) => {
type="submit"
variant="filled"
color="primary"
fullWidth={false}
disabled={submitted}
onClick={onClick}
className={styles.downloadButton}
>
Download My Comment History
@@ -17,7 +17,7 @@ import styles from "./DownloadRoute.css";
const fetcher = createFetch(
"downloadToken",
async (environment: Environment, variables: { token: string }, { rest }) =>
await rest.fetch<void>("/account/downloadcheck", {
await rest.fetch<void>("/account/download", {
method: "GET",
token: variables.token,
})