From 416b0a3ce730880d43b8642d915d2ed0bde62bfc Mon Sep 17 00:00:00 2001 From: Josue Date: Mon, 29 Mar 2021 11:23:27 -0400 Subject: [PATCH] refactor: perform data checks inside of components instead of in index --- striker-ui/pages/index.tsx | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/striker-ui/pages/index.tsx b/striker-ui/pages/index.tsx index c9b1f8e7..3ba25e67 100644 --- a/striker-ui/pages/index.tsx +++ b/striker-ui/pages/index.tsx @@ -19,7 +19,7 @@ const Home = (): JSX.Element => { const classes = useStyles(); const { data } = PeriodicFetch( - 'http://localhost:8080', + process.env.NEXT_PUBLIC_API_URL || 'http://localhost:8080', '/anvils/get_anvils', ); @@ -33,7 +33,7 @@ const Home = (): JSX.Element => { className={classes.grid} > - + @@ -53,19 +53,13 @@ const Home = (): JSX.Element => { direction="column" className={classes.grid} > - 0 ? data.anvils[0] : 'no uuid'} - /> - 0 ? data.anvils[0].anvil_uuid : 'no uuid' - } - /> - 0 ? data.anvils[0].anvil_uuid : 'no uuid' - } - /> + {data?.anvils?.length ? ( + <> + + + + + ) : null}