-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #526 from ITPNYU/feature/equipment
Equipment user page
- Loading branch information
Showing
12 changed files
with
202 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// app/liaison/page.tsx | ||
|
||
"use client"; | ||
|
||
import Equipment from "@/components/src/client/routes/equipment/Equipment"; | ||
import { Suspense } from "react"; | ||
|
||
const EquipmentPage: React.FC = () => { | ||
return ( | ||
<Suspense fallback={<div>Loading...</div>}> | ||
<Equipment /> | ||
</Suspense> | ||
); | ||
}; | ||
|
||
export default EquipmentPage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
o4Qd0YDOKtCR95EUyQ2Rbp5UbNUa:XkfbKenefg7ntnRR1D3r3nTo_lQa |
16 changes: 16 additions & 0 deletions
16
booking-app/components/src/client/routes/admin/components/Approvers.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Typography } from "@mui/material"; | ||
import { EquipmentUsers } from "./EquipmentUsers"; | ||
import { Liaisons } from "./Liaisons"; | ||
|
||
export const Approvers = () => ( | ||
<div> | ||
<Typography style={{ marginBottom: 24 }} variant="h6"> | ||
Liaison Users | ||
</Typography> | ||
<Liaisons /> | ||
<Typography style={{ marginTop: 48, marginBottom: 24 }} variant="h6"> | ||
Equipment Users | ||
</Typography> | ||
<EquipmentUsers /> | ||
</div> | ||
); |
60 changes: 60 additions & 0 deletions
60
booking-app/components/src/client/routes/admin/components/EquipmentUsers.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { useContext, useMemo } from "react"; | ||
|
||
import { ApproverLevel, TableNames } from "../../../../policy"; | ||
import { formatDate } from "../../../utils/date"; | ||
import AddRow from "../../components/AddRow"; | ||
import ListTable from "../../components/ListTable"; | ||
import { DatabaseContext } from "../../components/Provider"; | ||
|
||
const AddEquipmentForm = ({ equipmentEmails, reloadEquipmentEmails }) => { | ||
return ( | ||
<AddRow | ||
addDuplicateErrorMessage="This user is already registered" | ||
addFailedErrorMessage="Failed to add user as equipments" | ||
columnNameUniqueValue="email" | ||
inputPlaceholder="Add email" | ||
tableName={TableNames.APPROVERS} | ||
rows={equipmentEmails} | ||
rowsRefresh={reloadEquipmentEmails} | ||
title="Equipment Users" | ||
extra={{ | ||
values: { level: ApproverLevel.EQUIPMENT }, | ||
}} | ||
/> | ||
); | ||
}; | ||
|
||
export const EquipmentUsers = () => { | ||
const { equipmentUsers, reloadApproverUsers } = useContext(DatabaseContext); | ||
const equipmentEmails = useMemo<string[]>( | ||
() => equipmentUsers.map((user) => user.email), | ||
[equipmentUsers] | ||
); | ||
|
||
const rows = useMemo(() => { | ||
const filtered = equipmentUsers.map((liaison) => { | ||
const { level, ...other } = liaison; | ||
return other; | ||
}); | ||
const sorted = filtered.sort((a, b) => | ||
a.department.localeCompare(b.department) | ||
); | ||
return sorted as unknown as { [key: string]: string }[]; | ||
}, [equipmentUsers]); | ||
|
||
return ( | ||
<ListTable | ||
tableName={TableNames.APPROVERS} | ||
columnNameToRemoveBy="email" | ||
rows={rows} | ||
rowsRefresh={reloadApproverUsers} | ||
topRow={ | ||
<AddEquipmentForm | ||
equipmentEmails={equipmentEmails} | ||
reloadEquipmentEmails={reloadApproverUsers} | ||
/> | ||
} | ||
columnFormatters={{ createdAt: formatDate }} | ||
/> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.