-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Admins can view submission history #3441
Changes from all commits
d5c3db0
e70895b
b6c80e9
027bff8
9a728a2
111f05e
f429356
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
import { useState, Suspense } from "react"; | ||
import { Helmet } from "react-helmet"; | ||
import { NetworkErrorBoundary } from "rest-hooks"; | ||
import { useOktaAuth } from "@okta/okta-react"; | ||
import moment from "moment"; | ||
|
||
import { useOrgName } from "../utils/OrganizationUtils"; | ||
import { GLOBAL_STORAGE_KEYS } from "../components/GlobalContextProvider"; | ||
|
||
import { ErrorPage } from "./error/ErrorPage"; | ||
|
||
const OrgName = () => { | ||
const orgName: string = useOrgName(); | ||
return ( | ||
<span id="orgName" className="text-normal text-base"> | ||
{orgName} | ||
</span> | ||
); | ||
}; | ||
|
||
function Submissions() { | ||
const { authState } = useOktaAuth(); | ||
const organization = localStorage.getItem(GLOBAL_STORAGE_KEYS.GLOBAL_ORG); | ||
const [submissions, setSubmissions] = useState([]); | ||
|
||
fetch( | ||
`${process.env.REACT_APP_BACKEND_URL}/api/history/${organization}/submissions`, | ||
{ | ||
headers: { | ||
Authorization: `Bearer ${authState?.accessToken?.accessToken}`, | ||
}, | ||
} | ||
) | ||
.then((res) => res.json()) | ||
.then((submissionJson) => { | ||
setSubmissions(JSON.parse(submissionJson)); | ||
}); | ||
|
||
return ( | ||
<NetworkErrorBoundary | ||
fallbackComponent={() => <ErrorPage type="page" />} | ||
> | ||
<Helmet> | ||
<title>Submissions | {process.env.REACT_APP_TITLE}</title> | ||
</Helmet> | ||
<section className="grid-container margin-top-5"> | ||
<h3 className="margin-bottom-0"> | ||
<Suspense | ||
fallback={ | ||
<span className="text-normal text-base"> | ||
Loading Info... | ||
</span> | ||
} | ||
> | ||
<OrgName /> | ||
</Suspense> | ||
</h3> | ||
<h1 className="margin-top-0 margin-bottom-0">COVID-19</h1> | ||
</section> | ||
<div className="grid-container usa-section margin-bottom-10"> | ||
<div className="grid-col-12"> | ||
<h2>Submissions</h2> | ||
<table | ||
className="usa-table usa-table--borderless prime-table" | ||
aria-label="Submission history from the last 30 days" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice |
||
> | ||
<thead> | ||
<tr> | ||
<th scope="col">Date/time submitted</th> | ||
<th scope="col">File</th> | ||
<th scope="col">Records</th> | ||
<th scope="col">Report ID</th> | ||
<th scope="col">Warnings</th> | ||
</tr> | ||
</thead> | ||
<tbody id="tBody" className="font-mono-2xs"> | ||
{submissions.map((s, i) => { | ||
return ( | ||
<tr key={"submission_" + i}> | ||
<th scope="row"> | ||
{moment | ||
.utc(s["createdAt"]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have a general dislike of the For example, this can be done like this with standard javascript: console.log(new Intl.DateTimeFormat('en-US', {
year: 'numeric', month: 'numeric', day: 'numeric',
hour: 'numeric', minute: 'numeric', second: 'numeric',
}).format(new Date())); // 12/14/2021, 7:56:30 AM But it's fine to leave it, just adding this comment for awareness. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like this. I used moment since that is what we use on the /daily-data page. I'll create a ticket to clean up uses of moment |
||
.local() | ||
.format("YYYY-MM-DD HH:mm")} | ||
</th> | ||
<th scope="row"></th> {/* File name */} | ||
<th scope="row"> | ||
{s["reportItemCount"]} | ||
</th> | ||
<th scope="row">{s["id"]}</th> | ||
<th scope="row">{s["warningCount"]}</th> | ||
</tr> | ||
); | ||
})} | ||
</tbody> | ||
</table> | ||
</div> | ||
</div> | ||
</NetworkErrorBoundary> | ||
); | ||
} | ||
|
||
export default Submissions; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated but somewhat related, it appears that nav links aren't styled differently when active anymore. This might be solved when we're able to go to
react-router 6.x.x
since I know they deprecatedactiveClassName
in favor of a new way of styling active links.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought the react-router6 issue was related to okta's plugin that we use?
okta/okta-react#178