fix: improve server selection in the server component

main
Josue 4 years ago
parent b5770ab02d
commit 025d64b0fc
  1. 16
      striker-ui/components/Servers.tsx

@ -103,12 +103,10 @@ const Servers = ({ anvil }: { anvil: AnvilListItem[] }): JSX.Element => {
if (index === -1) { if (index === -1) {
selected.push(server_uuid); selected.push(server_uuid);
setSelected([...selected]); setSelected([...selected]);
} else selected.splice(index, 1); } else {
}; selected.splice(index, 1);
setSelected([...selected]);
const isSelected = (server: string): boolean => { }
const thing = selected.find((s) => s === server);
return thing !== 'undefined';
}; };
const anvilIndex = anvil.findIndex((a) => a.anvil_uuid === uuid); const anvilIndex = anvil.findIndex((a) => a.anvil_uuid === uuid);
@ -175,7 +173,11 @@ const Servers = ({ anvil }: { anvil: AnvilListItem[] }): JSX.Element => {
<Box className={classes.checkbox}> <Box className={classes.checkbox}>
<Checkbox <Checkbox
key={server.server_uuid} key={server.server_uuid}
checked={isSelected(server.server_uuid)} checked={
selected.find(
(s) => s === server.server_uuid,
) !== undefined
}
onChange={() => handleChange(server.server_uuid)} onChange={() => handleChange(server.server_uuid)}
inputProps={{ 'aria-label': 'primary checkbox' }} inputProps={{ 'aria-label': 'primary checkbox' }}
/> />

Loading…
Cancel
Save