refactor: perform data checks inside of components instead of in index

main
Josue 4 years ago committed by Tsu-ba-me
parent a909260779
commit 416b0a3ce7
  1. 24
      striker-ui/pages/index.tsx

@ -19,7 +19,7 @@ const Home = (): JSX.Element => {
const classes = useStyles(); const classes = useStyles();
const { data } = PeriodicFetch<AnvilList>( const { data } = PeriodicFetch<AnvilList>(
'http://localhost:8080', process.env.NEXT_PUBLIC_API_URL || 'http://localhost:8080',
'/anvils/get_anvils', '/anvils/get_anvils',
); );
@ -33,7 +33,7 @@ const Home = (): JSX.Element => {
className={classes.grid} className={classes.grid}
> >
<Anvils list={data} /> <Anvils list={data} />
<Nodes /> <Nodes anvil={data?.anvils[0]} />
</Grid> </Grid>
</Grid> </Grid>
<Grid item xs={5}> <Grid item xs={5}>
@ -53,19 +53,13 @@ const Home = (): JSX.Element => {
direction="column" direction="column"
className={classes.grid} className={classes.grid}
> >
<SharedStorage {data?.anvils?.length ? (
anvil={data?.anvils?.length > 0 ? data.anvils[0] : 'no uuid'} <>
/> <SharedStorage anvil={data.anvils[0]} />
<CPU <CPU uuid={data.anvils[0].anvil_uuid} />
uuid={ <Memory uuid={data.anvils[0].anvil_uuid} />
data?.anvils?.length > 0 ? data.anvils[0].anvil_uuid : 'no uuid' </>
} ) : null}
/>
<Memory
uuid={
data?.anvils?.length > 0 ? data.anvils[0].anvil_uuid : 'no uuid'
}
/>
</Grid> </Grid>
</Grid> </Grid>
</Grid> </Grid>

Loading…
Cancel
Save