From b3756cbe202cfb08507aa618671dd40bb4ef35d9 Mon Sep 17 00:00:00 2001 From: Josue Date: Tue, 27 Apr 2021 19:05:50 -0400 Subject: [PATCH] refactor: modify Network to use useContext for selected anvil --- striker-ui/components/Anvils/AnvilList.tsx | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/striker-ui/components/Anvils/AnvilList.tsx b/striker-ui/components/Anvils/AnvilList.tsx index dbdb039d..8fc7ae2b 100644 --- a/striker-ui/components/Anvils/AnvilList.tsx +++ b/striker-ui/components/Anvils/AnvilList.tsx @@ -1,3 +1,4 @@ +import { useContext } from 'react'; import { makeStyles } from '@material-ui/core/styles'; import { ClassNameMap } from '@material-ui/styles'; import { List, Box, Divider, ListItem } from '@material-ui/core'; @@ -9,6 +10,8 @@ import { GREY, } from '../../lib/consts/DEFAULT_THEME'; import Anvil from './Anvil'; +import { AnvilContext } from '../AnvilContext'; +import sortAnvils from './sortAnvils'; const useStyles = makeStyles(() => ({ root: { @@ -60,15 +63,21 @@ const selectDecorator = ( }; const AnvilList = ({ list }: { list: AnvilListItem[] }): JSX.Element => { + const { setAnvilUuid } = useContext(AnvilContext); const classes = useStyles(); return ( - {list.map((anvil) => { + {sortAnvils(list).map((anvil) => { return ( <> - + setAnvilUuid(anvil.anvil_uuid)} + >