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 | 4x 14x 1x 13x 13x 13x 13x 13x 13x 13x 13x 13x 10x 3x 2x 1x 4x 129x 129x 129x 14x 14x 13x 1x 115x 61x 4x 4x | import OurTable from "main/components/OurTable";
import PropTypes from "prop-types";
const formatApprovalDate = (dateApproved) => {
if (typeof dateApproved !== "string") {
return null;
}
const dateParts = dateApproved.split("-");
const yearString = dateParts[0];
const monthString = dateParts[1];
const dayString = dateParts[2];
const year = Number(yearString);
const month = Number(monthString);
const day = Number(dayString);
const date = new Date(Date.UTC(year, month - 1, day));
if (Number.isNaN(date.getTime())) {
return null;
}
if (date.toISOString().slice(0, 10) !== dateApproved) {
return null;
}
return `${month}/${day}/${year}`;
};
const columns = [
{
Header: "id",
accessor: "id", // accessor is the "key" in the data
},
{
Header: "First Name",
accessor: "givenName",
},
{
Header: "Last Name",
accessor: "familyName",
},
{
Header: "Email",
accessor: "email",
},
{
Header: "Admin",
id: "admin",
accessor: (row, _rowIndex) => String(row.admin), // hack needed for boolean values to show up
},
{
Header: "Moderator",
id: "moderator",
accessor: (row, _rowIndex) => String(row.moderator),
},
{
Header: "Alias",
accessor: "alias",
},
{
Header: "Proposed Alias",
accessor: "proposedAlias",
},
{
Header: "Status",
accessor: (row) => {
if (row.status === "APPROVED") {
const formattedDate = formatApprovalDate(row.dateApproved);
if (!formattedDate) {
return row.status;
}
return `Approved on ${formattedDate}`;
}
return row.status;
},
},
];
export default function UsersTable({ users }) {
return <OurTable data={users} columns={columns} testid={"UsersTable"} />;
}
UsersTable.propTypes = Object.create(null);
UsersTable.propTypes.users = PropTypes.array.isRequired;
|