import React from "react";
import { useStatus } from "../../src/core/hooks";
import { Heading, Text, Flex, Spacer, chakra, Spinner } from "@chakra-ui/react";
import { getLayout, getLayoutProps } from "../../src/layouts/InfoPageLayout";
const Status = () => {
const healthyStatusText = "Available";
const downStatusText = "Unavailable";
const healthyStatusColor = "green.900";
const downStatusColor = "red.600";
const shortTimestamp = (rawTimestamp) => {
return rawTimestamp.replace(/^.+T/, "").replace(/\..+/, "");
};
const {
apiServerStatusCache,
ethereumClusterServerStatusCache,
gethStatusCache,
crawlersStatusCache,
dbServerStatusCache,
latestBlockDBStatusCache,
} = useStatus();
const StatusRow = (props) => {
console.log(props.cache.data);
return (
{props.title}
{!props.cache.isLoading && props.children}
{props.cache.isLoading && }
);
};
return (
<>
{`Status page`}
{apiServerStatusCache?.data?.status == "ok"
? healthyStatusText
: downStatusText}
{ethereumClusterServerStatusCache?.data
? healthyStatusText
: downStatusText}
{gethStatusCache?.data?.current_block
? gethStatusCache.data.current_block
: 0}
{crawlersStatusCache?.data?.ethereum_txpool_timestamp
? shortTimestamp(
crawlersStatusCache?.data?.ethereum_txpool_timestamp
)
: downStatusText}
{crawlersStatusCache?.data?.ethereum_trending_timestamp
? shortTimestamp(
crawlersStatusCache?.data?.ethereum_trending_timestamp
)
: downStatusText}
{dbServerStatusCache?.data?.status == "ok"
? healthyStatusText
: downStatusText}
{latestBlockDBStatusCache?.data?.block_number
? latestBlockDBStatusCache.data.block_number
: 0}
>
);
};
Status.getLayout = getLayout;
export async function getStaticProps() {
const metaTags = {
title: "Moonstream: Status page",
description: "Status of moonstream.to services",
keywords:
"blockchain, crypto, data, trading, smart contracts, ethereum, solana, transactions, defi, finance, decentralized, analytics, product, whitepapers",
url: "https://www.moonstream.to/status",
};
const layoutProps = getLayoutProps();
layoutProps.props.metaTags = { ...layoutProps.props.metaTags, ...metaTags };
return { ...layoutProps };
}
export default Status;