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 #60 from ucsb-cs156-s22/Aaron-HelpRequest-Table
MERGE THIRD: Add Help Request Table and Corresponding Test
- Loading branch information
Showing
3 changed files
with
143 additions
and
53 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,74 @@ | ||
import OurTable, { _ButtonColumn } from "main/components/OurTable"; | ||
// import { useBackendMutation } from "main/utils/useBackend"; | ||
// import { cellToAxiosParamsDelete, onDeleteSuccess } from "main/utils/UCSBDateUtils" | ||
// import { useNavigate } from "react-router-dom"; | ||
// import { hasRole } from "main/utils/currentUser"; | ||
|
||
export default function HelpRequestsTable({ helpRequests, _currentUser }) { | ||
|
||
// const navigate = useNavigate(); | ||
|
||
// const editCallback = (cell) => { | ||
// navigate(`/ucsbdates/edit/${cell.row.values.id}`) | ||
// } | ||
|
||
// Stryker disable all : hard to test for query caching | ||
// const deleteMutation = useBackendMutation( | ||
// cellToAxiosParamsDelete, | ||
// { onSuccess: onDeleteSuccess }, | ||
// ["/api/ucsbdates/all"] | ||
// ); | ||
// Stryker enable all | ||
|
||
// Stryker disable next-line all : TODO try to make a good test for this | ||
// const deleteCallback = async (cell) => { deleteMutation.mutate(cell); } | ||
|
||
const columns = [ | ||
{ | ||
Header: 'id', | ||
accessor: 'id', // accessor is the "key" in the data | ||
}, | ||
{ | ||
Header: 'Requester Email', | ||
accessor: 'requesterEmail', | ||
}, | ||
{ | ||
Header: 'Team ID', | ||
accessor: 'teamId', | ||
}, | ||
{ | ||
Header: 'Table or Breakout Room', | ||
accessor: 'tableOrBreakoutRoom', | ||
}, | ||
{ | ||
Header: 'Request Time', | ||
accessor: 'requestTime', | ||
}, | ||
{ | ||
Header: 'Explanation', | ||
accessor: 'explanation', | ||
}, | ||
{ | ||
Header: 'Solved?', | ||
id: 'solved', | ||
accessor: (row, _rowIndex) => String(row.solved) // hack needed for boolean values to show up | ||
}, | ||
]; | ||
|
||
// const columnsIfAdmin = [ | ||
// ...columns, | ||
// ButtonColumn("Edit", "primary", editCallback, "UCSBDatesTable"), | ||
// ButtonColumn("Delete", "danger", deleteCallback, "UCSBDatesTable") | ||
// ]; | ||
|
||
// const columnsToDisplay = hasRole(currentUser, "ROLE_ADMIN") ? columnsIfAdmin : columns; | ||
|
||
const columnsToDisplay = columns; | ||
|
||
return <OurTable | ||
data={helpRequests} | ||
columns={columnsToDisplay} | ||
testid={"HelpRequestsTable"} | ||
/>; | ||
}; | ||
|
23 changes: 19 additions & 4 deletions
23
frontend/src/main/pages/HelpRequests/HelpRequestsIndexPage.js
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