Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | 4x 146x 146x 146x 146x 146x 10x 10x 146x 39x 146x 39x 39x 15x 15x 15x 7x 8x 146x | import React from "react";
import OurTable from "main/components/OurTable";
import { useBackend } from "main/utils/useBackend";
import { useParams } from "react-router-dom";
import { timestampToDate } from "main/utils/dateUtils";
const PagedAnnouncementTable = () => {
const refreshJobsIntervalMilliseconds = 5000;
const { commonsId } = useParams();
// Stryker disable all
const {
data: page
} = useBackend(
["/api/announcements/getbycommonsid"],
{
method: "GET",
url: "/api/announcements/getbycommonsid",
params: {
commonsId: commonsId,
}
},
{content: [], totalPages: 0},
{ refetchInterval: refreshJobsIntervalMilliseconds }
);
// Stryker restore all
const testid = "PagedAnnouncementTable";
const columns =
[
{
Header: "Start Date",
accessor: "startDate",
Cell: ({ value }) => timestampToDate(value),
},
{
Header: "End Date",
accessor: "endDate",
Cell: ({ value }) => (value ? timestampToDate(value) : ""),
},
{
Header: 'Important Announcements',
accessor: 'announcementText',
},
];
const sortees = React.useMemo(
() => [
{
id: "startDate",
desc: true
}
],
// Stryker disable next-line all
[]
);
const legalDate = React.useMemo(
() => {
const now = new Date();
return page.content.filter((announcement) => {
const startDate = new Date(announcement.startDate);
const endDate = announcement.endDate ? new Date(announcement.endDate) : null;;
if (!endDate) {
return startDate <= now;
}
else {
return (startDate <= now) && (now <= endDate);
}
});
},
// Stryker disable next-line all
[page.content]
);
return (
<>
< OurTable
data={legalDate}
columns={columns}
testid={testid}
initialState={{ sortBy: sortees }}
/>
</>
);
};
export default PagedAnnouncementTable; |