refactor: use server_uuid to fetch a resource

main
Josue 4 years ago
parent 8f353679bb
commit e728e3b5f9
  1. 30
      striker-ui/pages/server/[uuid].tsx

@ -1,13 +1,14 @@
import { useRouter } from 'next/router';
import { Box } from '@material-ui/core'; import { Box } from '@material-ui/core';
import { makeStyles } from '@material-ui/core/styles'; import { makeStyles } from '@material-ui/core/styles';
import CPU from '../components/CPU'; import PeriodicFetch from '../../lib/fetchers/periodicFetch';
import Memory from '../components/Memory'; import CPU from '../../components/CPU';
import Resource from '../components/Resource'; import Memory from '../../components/Memory';
import PeriodicFetch from '../lib/fetchers/periodicFetch'; import Resource from '../../components/Resource';
import Display from '../components/Display'; import Display from '../../components/Display';
import Header from '../components/Header'; import Header from '../../components/Header';
import Domain from '../components/Domain'; import Domain from '../../components/Domain';
const useStyles = makeStyles((theme) => ({ const useStyles = makeStyles((theme) => ({
child: { child: {
@ -40,17 +41,20 @@ const useStyles = makeStyles((theme) => ({
}, },
})); }));
const Home = (): JSX.Element => { const Server = (): JSX.Element => {
const classes = useStyles(); const classes = useStyles();
const { data } = PeriodicFetch<AnvilList>( const router = useRouter();
`${process.env.NEXT_PUBLIC_API_URL}/anvils/get_anvils`, const { uuid } = router.query;
const { data } = PeriodicFetch<AnvilReplicatedStorage>(
`${process.env.NEXT_PUBLIC_API_URL}/anvils/get_replicated_storage?server_uuid=${uuid}`,
); );
return ( return (
<> <>
<Header /> <Header />
{data?.anvils && ( {typeof uuid === 'string' && data && (
<Box className={classes.container}> <Box className={classes.container}>
<Box className={classes.child}> <Box className={classes.child}>
<CPU /> <CPU />
@ -61,7 +65,7 @@ const Home = (): JSX.Element => {
<Domain /> <Domain />
</Box> </Box>
<Box className={classes.child}> <Box className={classes.child}>
<Resource /> <Resource resource={data} />
</Box> </Box>
</Box> </Box>
)} )}
@ -69,4 +73,4 @@ const Home = (): JSX.Element => {
); );
}; };
export default Home; export default Server;
Loading…
Cancel
Save