-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add participant list to landing page (#27)
- Loading branch information
1 parent
4c91812
commit 07e621a
Showing
4 changed files
with
86 additions
and
46 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { | ||
FormControl, | ||
InputLabel, | ||
Select, | ||
MenuItem, | ||
SelectChangeEvent, | ||
} from "@mui/material"; | ||
import { useLocation, useNavigate } from "react-router-dom"; | ||
import { Report } from "./capabilityTypes"; | ||
|
||
export const ParticipantSelector = ({ | ||
report, | ||
hideIfNoParticipant, | ||
}: { | ||
report: Report; | ||
hideIfNoParticipant?: boolean; | ||
}) => { | ||
const location = useLocation(); | ||
const navigate = useNavigate(); | ||
const ussp = parseInt(location.pathname.split("/")[1]); | ||
|
||
const handleUsspSelect = (event: SelectChangeEvent<number>) => { | ||
const id = event.target.value; | ||
navigate(`/${id}`); | ||
}; | ||
if (hideIfNoParticipant && Number.isNaN(ussp)) { | ||
return null; | ||
} | ||
return ( | ||
<FormControl size="small"> | ||
<InputLabel id="ussp-select-label">USSP</InputLabel> | ||
<Select | ||
displayEmpty={true} | ||
label="USSP" | ||
value={ussp} | ||
onChange={handleUsspSelect} | ||
labelId="ussp-select-label" | ||
> | ||
{report.participants?.map((p, i) => ( | ||
<MenuItem value={i} key={i}> | ||
{p} | ||
</MenuItem> | ||
))} | ||
</Select> | ||
</FormControl> | ||
); | ||
}; |
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