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

Loading…
Cancel
Save