From cf77395bf35d862f7159f0102d2fce8403473aee Mon Sep 17 00:00:00 2001 From: Josue Date: Thu, 25 Mar 2021 10:59:23 -0400 Subject: [PATCH] refactor: fetch from get_status and use the data with the Anvil component --- striker-ui/components/Anvils.tsx | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/striker-ui/components/Anvils.tsx b/striker-ui/components/Anvils.tsx index dfff97fd..8ee1137b 100644 --- a/striker-ui/components/Anvils.tsx +++ b/striker-ui/components/Anvils.tsx @@ -1,28 +1,27 @@ -import { useState } from 'react'; -import { Switch, Grid } from '@material-ui/core'; +import { Grid } from '@material-ui/core'; import Panel from './Panel'; -import { HeaderText, BodyText } from './Text'; +import Anvil from './Anvil'; +import PeriodicFetch from '../lib/fetchers/periodicFetch'; const Anvils = ({ list }: { list: AnvilList | undefined }): JSX.Element => { - const [checked, setChecked] = useState(true); let anvils: AnvilListItem[] = []; if (list) anvils = list.anvils; + anvils.forEach((anvil: AnvilListItem) => { + const { data } = PeriodicFetch( + `${process.env.NEXT_PUBLIC_API_URL}/anvils/get_status?anvil_uuid=`, + anvil.anvil_uuid, + ); + /* eslint-disable no-param-reassign */ + anvil.anvil_status = data; + }); + return ( - - - - - 0 ? anvils[0].anvil_name : 'Anvil 1'} - /> - - - - setChecked(!checked)} /> - + {anvils.map((anvil) => ( + + ))} );