Skip to content

Commit

Permalink
feat: add sortBy network members
Browse files Browse the repository at this point in the history
  • Loading branch information
NoobTW committed Apr 16, 2023
1 parent cb6c647 commit a5bcff7
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions frontend/src/components/NetworkMembers/NetworkMembers.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ import {
AccordionSummary,
Checkbox,
Divider,
FormControlLabel,
Grid,
IconButton,
Radio,
RadioGroup,
TextField,
Typography,
} from "@material-ui/core";
Expand All @@ -29,6 +32,7 @@ function NetworkMembers({ network }) {
const [filter, setFilter] = useState("");
const [filterActive, setFilterActive] = useState(false);
const [filterInactive, setFilterInactive] = useState(false);
const [sortBy, setSortBy] = useState("id");

const fetchData = useCallback(async () => {
try {
Expand Down Expand Up @@ -175,14 +179,14 @@ function NetworkMembers({ network }) {
<RefreshIcon />
</IconButton>
<Grid container>
<Grid item sm={6}>
<Grid item sm={3}>
<Typography>Search (Addr/Name)</Typography>
<TextField
value={filter}
onChange={(e) => setFilter(e.target.value)}
/>
</Grid>
<Grid item sm="auto">
<Grid item sm={3}>
<Typography>Display Filter</Typography>
<Checkbox
checked={filterActive}
Expand All @@ -197,6 +201,13 @@ function NetworkMembers({ network }) {
/>
<span>Inactive</span>
</Grid>
<Grid item sm={3}>
<Typography>Sort by</Typography>
<RadioGroup value={sortBy} onChange={(e) => setSortBy(e.target.value)}>
<FormControlLabel value="name" control={<Radio />} label="Name" />
<FormControlLabel value="id" control={<Radio />} label="Address" />
</RadioGroup>
</Grid>
<Divider />
</Grid>
<Grid container>
Expand All @@ -212,6 +223,7 @@ function NetworkMembers({ network }) {
(filterInactive ? x.online === 0 : true)
)
})
.sort((a, b) => a[sortBy].localeCompare(b[sortBy]))
}
/>
) : (
Expand Down

0 comments on commit a5bcff7

Please sign in to comment.