1- import React from "react" ;
1+ import React , { useMemo } from "react" ;
22import styled from "styled-components" ;
33import { useSortitionModulePhase } from "hooks/contracts/generated" ;
4- import { GIT_BRANCH , GIT_DIRTY , GIT_HASH , GIT_TAGS , GIT_URL , RELEASE_VERSION } from "consts/index" ;
4+ import { useToggleTheme } from "hooks/useToggleThemeContext" ;
5+ import {
6+ GIT_BRANCH ,
7+ GIT_DIRTY ,
8+ GIT_HASH ,
9+ GIT_TAGS ,
10+ GIT_URL ,
11+ RELEASE_VERSION ,
12+ SERVICES_STATUS_DEVNET_URL ,
13+ SERVICES_STATUS_TESTNET_URL ,
14+ } from "consts/index" ;
515
616const Container = styled . div `
17+ display: flex;
18+ flex-direction: column;
19+ gap: 12px;
20+
721 label,
822 a {
923 font-family: "Roboto Mono", monospace;
@@ -13,6 +27,14 @@ const Container = styled.div`
1327 }
1428` ;
1529
30+ const StyledIframe = styled . iframe `
31+ border: none;
32+ width: 100%;
33+ height: 30px;
34+ background-color: ${ ( { theme } ) => theme . mediumPurple } ;
35+ border-radius: 300px;
36+ ` ;
37+
1638const Version = ( ) => (
1739 < label >
1840 v{ RELEASE_VERSION } { " " }
@@ -25,6 +47,31 @@ const Version = () => (
2547 </ label >
2648) ;
2749
50+ const ServicesStatus = ( ) => {
51+ const [ theme ] = useToggleTheme ( ) ;
52+ const deployment = process . env . REACT_APP_DEPLOYMENT ?? "testnet" ;
53+ let statusUrl : string ;
54+ switch ( deployment ) {
55+ case "devnet" :
56+ statusUrl = SERVICES_STATUS_DEVNET_URL ;
57+ break ;
58+ case "testnet" :
59+ statusUrl = SERVICES_STATUS_TESTNET_URL ;
60+ break ;
61+ default :
62+ throw new Error ( `Unknown deployment: ${ deployment } ` ) ;
63+ }
64+ statusUrl = useMemo (
65+ ( ) => ( theme === "light" ? statusUrl + "?theme=light" : statusUrl + "?theme=dark" ) ,
66+ [ statusUrl , theme ]
67+ ) ;
68+ return (
69+ < label >
70+ < StyledIframe src = { `${ statusUrl } ` } />
71+ </ label >
72+ ) ;
73+ } ;
74+
2875enum Phases {
2976 staking ,
3077 generating ,
@@ -35,21 +82,13 @@ const Phase = () => {
3582 const { data : phase } = useSortitionModulePhase ( {
3683 watch : true ,
3784 } ) ;
38- return (
39- < >
40- { phase !== undefined && (
41- < label >
42- < br />
43- phase: { Phases [ phase ] }
44- </ label >
45- ) }
46- </ >
47- ) ;
85+ return < > { phase !== undefined && < label > Phase: { Phases [ phase ] } </ label > } </ > ;
4886} ;
4987
5088const Debug : React . FC = ( ) => {
5189 return (
5290 < Container >
91+ < ServicesStatus />
5392 < Version />
5493 < Phase />
5594 </ Container >
0 commit comments