From d5c3db00e846ddb3f763014ad06d6381bc2a26fa Mon Sep 17 00:00:00 2001 From: Sean Pennino Date: Mon, 13 Dec 2021 14:03:39 -0800 Subject: [PATCH 1/6] Initial Submissions page setup --- frontend-react/src/App.tsx | 6 ++++++ .../components/header/ReportStreamHeader.tsx | 16 ++++++++++++++++ frontend-react/src/pages/Submissions.tsx | 18 ++++++++++++++++++ 3 files changed, 40 insertions(+) create mode 100644 frontend-react/src/pages/Submissions.tsx diff --git a/frontend-react/src/App.tsx b/frontend-react/src/App.tsx index 80dae676cd3..6b1d223a818 100644 --- a/frontend-react/src/App.tsx +++ b/frontend-react/src/App.tsx @@ -21,6 +21,7 @@ import { AuthorizedRoute } from "./components/AuthorizedRoute"; import { PERMISSIONS } from "./resources/PermissionsResource"; import { permissionCheck, reportReceiver } from "./webreceiver-utils"; import { Upload } from "./pages/Upload"; +import { Submissions } from "./pages/Submissions"; import { CODES, ErrorPage } from "./pages/error/ErrorPage"; import GlobalContextProvider from "./components/GlobalContextProvider"; import { logout } from "./utils/UserUtils"; @@ -128,6 +129,11 @@ const App = () => { authorize={PERMISSIONS.SENDER} component={Upload} /> + { ); } + + if (permissionCheck(PERMISSIONS.PRIME_ADMIN, authState)) { + itemsMenu.splice( + 1, + 0, + + ); + } } return ( diff --git a/frontend-react/src/pages/Submissions.tsx b/frontend-react/src/pages/Submissions.tsx new file mode 100644 index 00000000000..62d8e2f9afc --- /dev/null +++ b/frontend-react/src/pages/Submissions.tsx @@ -0,0 +1,18 @@ + +import { Helmet } from "react-helmet"; +import { NetworkErrorBoundary } from "rest-hooks"; +import { ErrorPage } from "./error/ErrorPage"; + +function Submissions() { + return ( + } + > + + Submissions | {process.env.REACT_APP_TITLE} + + + ); +} + +export default Submissions; \ No newline at end of file From e70895bfb87d83c810aef102c5f3a63506e706f2 Mon Sep 17 00:00:00 2001 From: Sean Pennino Date: Mon, 13 Dec 2021 14:30:40 -0800 Subject: [PATCH 2/6] Basic submissions fetch --- frontend-react/src/App.tsx | 2 +- frontend-react/src/pages/Submissions.tsx | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/frontend-react/src/App.tsx b/frontend-react/src/App.tsx index 6b1d223a818..f230471d0ae 100644 --- a/frontend-react/src/App.tsx +++ b/frontend-react/src/App.tsx @@ -21,12 +21,12 @@ import { AuthorizedRoute } from "./components/AuthorizedRoute"; import { PERMISSIONS } from "./resources/PermissionsResource"; import { permissionCheck, reportReceiver } from "./webreceiver-utils"; import { Upload } from "./pages/Upload"; -import { Submissions } from "./pages/Submissions"; import { CODES, ErrorPage } from "./pages/error/ErrorPage"; import GlobalContextProvider from "./components/GlobalContextProvider"; import { logout } from "./utils/UserUtils"; import TermsOfServiceForm from "./pages/tos-sign/TermsOfServiceForm"; import Spinner from "./components/Spinner"; +import Submissions from "./pages/Submissions"; const OKTA_AUTH = new OktaAuth(oktaAuthConfig); diff --git a/frontend-react/src/pages/Submissions.tsx b/frontend-react/src/pages/Submissions.tsx index 62d8e2f9afc..2de7f71fb29 100644 --- a/frontend-react/src/pages/Submissions.tsx +++ b/frontend-react/src/pages/Submissions.tsx @@ -2,8 +2,27 @@ import { Helmet } from "react-helmet"; import { NetworkErrorBoundary } from "rest-hooks"; import { ErrorPage } from "./error/ErrorPage"; +import { useOktaAuth } from "@okta/okta-react"; +import { GLOBAL_STORAGE_KEYS } from "../components/GlobalContextProvider"; function Submissions() { + const { authState } = useOktaAuth(); + const organization = localStorage.getItem(GLOBAL_STORAGE_KEYS.GLOBAL_ORG); + + let submissions:[]= []; + fetch( + `${process.env.REACT_APP_BACKEND_URL}/api/history/${organization}/submissions`, + { + headers: { + Authorization: `Bearer ${authState?.accessToken?.accessToken}`, + }, + } + ) + .then(res => res.json()) + .then(submissionsJson => { + submissions = submissionsJson; + }) + return ( } @@ -11,6 +30,7 @@ function Submissions() { Submissions | {process.env.REACT_APP_TITLE} + {submissions} ); } From b6c80e91e4e5cbc0a22630f3817e566ea200aca8 Mon Sep 17 00:00:00 2001 From: Sean Pennino Date: Mon, 13 Dec 2021 17:51:36 -0800 Subject: [PATCH 3/6] Submissions table --- frontend-react/src/pages/Submissions.tsx | 63 +++++++++++++++++++++++- 1 file changed, 61 insertions(+), 2 deletions(-) diff --git a/frontend-react/src/pages/Submissions.tsx b/frontend-react/src/pages/Submissions.tsx index 2de7f71fb29..57ce0f40c64 100644 --- a/frontend-react/src/pages/Submissions.tsx +++ b/frontend-react/src/pages/Submissions.tsx @@ -1,15 +1,27 @@ +import { Suspense } from "react"; import { Helmet } from "react-helmet"; import { NetworkErrorBoundary } from "rest-hooks"; import { ErrorPage } from "./error/ErrorPage"; import { useOktaAuth } from "@okta/okta-react"; +import { useOrgName } from "../utils/OrganizationUtils"; import { GLOBAL_STORAGE_KEYS } from "../components/GlobalContextProvider"; +import moment from "moment"; + +const OrgName = () => { + const orgName: string = useOrgName(); + return ( + + {orgName} + + ); +}; function Submissions() { const { authState } = useOktaAuth(); const organization = localStorage.getItem(GLOBAL_STORAGE_KEYS.GLOBAL_ORG); - let submissions:[]= []; + let submissions:[] = []; fetch( `${process.env.REACT_APP_BACKEND_URL}/api/history/${organization}/submissions`, { @@ -30,7 +42,54 @@ function Submissions() { Submissions | {process.env.REACT_APP_TITLE} - {submissions} +
+

+ + Loading Info... + + } + > + + +

+

COVID-19

+
+
+
+

Test results

+ + + + + + + + + + + + {submissions.map((s, i) => { + return ( + + + {/* File name */} + + + + + ); + })} + +
Date/time submittedFileRecordsReport IDWarnings
+ {moment + .utc(s["createdAt"]) + .local() + .format("YYYY-MM-DD HH:mm")} + {s["reportItemCount"]}{s["id"]}{s["warningCount"]}
+
+
); } From 027bff86e47338c01f61252a693f8cf44c5a933d Mon Sep 17 00:00:00 2001 From: Sean Pennino Date: Mon, 13 Dec 2021 17:53:34 -0800 Subject: [PATCH 4/6] Lint fixes --- frontend-react/src/pages/Submissions.tsx | 38 ++++++++++++++---------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/frontend-react/src/pages/Submissions.tsx b/frontend-react/src/pages/Submissions.tsx index 57ce0f40c64..1ad5fd9c448 100644 --- a/frontend-react/src/pages/Submissions.tsx +++ b/frontend-react/src/pages/Submissions.tsx @@ -1,12 +1,13 @@ - import { Suspense } from "react"; import { Helmet } from "react-helmet"; import { NetworkErrorBoundary } from "rest-hooks"; -import { ErrorPage } from "./error/ErrorPage"; import { useOktaAuth } from "@okta/okta-react"; +import moment from "moment"; + import { useOrgName } from "../utils/OrganizationUtils"; import { GLOBAL_STORAGE_KEYS } from "../components/GlobalContextProvider"; -import moment from "moment"; + +import { ErrorPage } from "./error/ErrorPage"; const OrgName = () => { const orgName: string = useOrgName(); @@ -21,7 +22,7 @@ function Submissions() { const { authState } = useOktaAuth(); const organization = localStorage.getItem(GLOBAL_STORAGE_KEYS.GLOBAL_ORG); - let submissions:[] = []; + let submissions: [] = []; fetch( `${process.env.REACT_APP_BACKEND_URL}/api/history/${organization}/submissions`, { @@ -30,10 +31,10 @@ function Submissions() { }, } ) - .then(res => res.json()) - .then(submissionsJson => { - submissions = submissionsJson; - }) + .then((res) => res.json()) + .then((submissionsJson) => { + submissions = submissionsJson; + }); return (

Test results

- +
@@ -73,16 +77,18 @@ function Submissions() { {submissions.map((s, i) => { return ( - {/* File name */} - - - + + {/* File name */} + + + ); })} @@ -94,4 +100,4 @@ function Submissions() { ); } -export default Submissions; \ No newline at end of file +export default Submissions; From 9a728a29732f0b389176d87758e74cf40550418f Mon Sep 17 00:00:00 2001 From: Sean Pennino Date: Mon, 13 Dec 2021 17:58:20 -0800 Subject: [PATCH 5/6] Add title --- frontend-react/src/pages/Submissions.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend-react/src/pages/Submissions.tsx b/frontend-react/src/pages/Submissions.tsx index 1ad5fd9c448..278cad35b1f 100644 --- a/frontend-react/src/pages/Submissions.tsx +++ b/frontend-react/src/pages/Submissions.tsx @@ -59,7 +59,7 @@ function Submissions() {
-

Test results

+

Submissions

Date/time submitted
+ {moment .utc(s["createdAt"]) .local() .format("YYYY-MM-DD HH:mm")} - - {s["reportItemCount"]}{s["id"]}{s["warningCount"]} + {s["reportItemCount"]} + {s["id"]}{s["warningCount"]}
Date: Mon, 13 Dec 2021 18:24:37 -0800 Subject: [PATCH 6/6] useState for submissions --- frontend-react/src/pages/Submissions.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/frontend-react/src/pages/Submissions.tsx b/frontend-react/src/pages/Submissions.tsx index 278cad35b1f..b24773f95dc 100644 --- a/frontend-react/src/pages/Submissions.tsx +++ b/frontend-react/src/pages/Submissions.tsx @@ -1,4 +1,4 @@ -import { Suspense } from "react"; +import { useState, Suspense } from "react"; import { Helmet } from "react-helmet"; import { NetworkErrorBoundary } from "rest-hooks"; import { useOktaAuth } from "@okta/okta-react"; @@ -21,8 +21,8 @@ const OrgName = () => { function Submissions() { const { authState } = useOktaAuth(); const organization = localStorage.getItem(GLOBAL_STORAGE_KEYS.GLOBAL_ORG); + const [submissions, setSubmissions] = useState([]); - let submissions: [] = []; fetch( `${process.env.REACT_APP_BACKEND_URL}/api/history/${organization}/submissions`, { @@ -32,8 +32,8 @@ function Submissions() { } ) .then((res) => res.json()) - .then((submissionsJson) => { - submissions = submissionsJson; + .then((submissionJson) => { + setSubmissions(JSON.parse(submissionJson)); }); return (