fix(striker-ui): remove static UUID in Anvil status page

main
Tsu-ba-me 4 years ago
parent 409a888974
commit cee5f9735f
  1. 22
      striker-ui/pages/anvils/[uuid].tsx
  2. 16
      striker-ui/pages/anvils/index.tsx

@ -1,16 +1,17 @@
import { NextPage } from 'next'; import { NextPage } from 'next';
import styled from 'styled-components'; import styled from 'styled-components';
import { useRouter } from 'next/dist/client/router';
import DEFAULT_THEME from '../lib/consts/DEFAULT_THEME'; import DEFAULT_THEME from '../../lib/consts/DEFAULT_THEME';
import Header from '../components/organisms/Header'; import Header from '../../components/organisms/Header';
import List from '../components/molecules/List'; import List from '../../components/molecules/List';
import PageCenterContainer from '../components/organisms/PageCenterContainer'; import PageCenterContainer from '../../components/organisms/PageCenterContainer';
import PageContainer from '../components/organisms/PageContainer'; import PageContainer from '../../components/organisms/PageContainer';
import ToggleSwitch from '../components/atoms/ToggleSwitch'; import ToggleSwitch from '../../components/atoms/ToggleSwitch';
import useOneAnvil from '../lib/anvil/useOneAnvil'; import useOneAnvil from '../../lib/anvil/useOneAnvil';
import Label from '../components/atoms/Label'; import Label from '../../components/atoms/Label';
const StyledAnvilNodeStatus = styled.div` const StyledAnvilNodeStatus = styled.div`
display: flex; display: flex;
@ -42,11 +43,14 @@ StyledAnvilNodePower.defaultProps = {
}; };
const DemoAnvilStatus: NextPage = (): JSX.Element => { const DemoAnvilStatus: NextPage = (): JSX.Element => {
const router = useRouter();
const { uuid } = router.query;
const anvilUUID: string = uuid instanceof Array ? uuid[0] : uuid ?? '';
const { const {
anvilStatus: { nodes, timestamp }, anvilStatus: { nodes, timestamp },
error, error,
isLoading, isLoading,
} = useOneAnvil(`d61c0383-5d82-4d9f-a193-b4a31cff1ceb`); } = useOneAnvil(anvilUUID);
const lastUpdatedDatetime: string = new Date(timestamp * 1000).toLocaleString( const lastUpdatedDatetime: string = new Date(timestamp * 1000).toLocaleString(
'en-US', 'en-US',

@ -1,14 +1,14 @@
import { GetServerSidePropsResult, InferGetServerSidePropsType } from 'next'; import { GetServerSidePropsResult, InferGetServerSidePropsType } from 'next';
import API_BASE_URL from '../lib/consts/API_BASE_URL'; import API_BASE_URL from '../../lib/consts/API_BASE_URL';
import Button from '../components/atoms/Button'; import Button from '../../components/atoms/Button';
import Header from '../components/organisms/Header'; import Header from '../../components/organisms/Header';
import List from '../components/molecules/List'; import List from '../../components/molecules/List';
import PageCenterContainer from '../components/organisms/PageCenterContainer'; import PageCenterContainer from '../../components/organisms/PageCenterContainer';
import PageContainer from '../components/organisms/PageContainer'; import PageContainer from '../../components/organisms/PageContainer';
import fetchJSON from '../lib/fetchers/fetchJSON'; import fetchJSON from '../../lib/fetchers/fetchJSON';
export async function getServerSideProps(): Promise< export async function getServerSideProps(): Promise<
GetServerSidePropsResult<AnvilList> GetServerSidePropsResult<AnvilList>
@ -32,7 +32,7 @@ function DemoAnvilList({
key={anvil.uuid} key={anvil.uuid}
imageProps={{ src: '/pngs/anvil_icon_on.png' }} imageProps={{ src: '/pngs/anvil_icon_on.png' }}
labelProps={{ text: anvil.uuid }} labelProps={{ text: anvil.uuid }}
linkProps={{ href: '/demo-anvil-status' }} linkProps={{ href: `/anvils/${anvil.uuid}` }}
/> />
), ),
)} )}
Loading…
Cancel
Save