mirror of
https://github.com/oceanprotocol/status-frontend.git
synced 2024-11-22 01:46:56 +01:00
Updating data format & improving error handling
This commit is contained in:
parent
49af074b59
commit
5776751de0
@ -31,12 +31,8 @@ export default function HomePage(): ReactElement {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
async function getStatuses() {
|
async function getStatuses() {
|
||||||
const statusData = await getData()
|
const statusData = await getData()
|
||||||
console.log('statusData', statusData)
|
|
||||||
if (statusData) setStatuses(statusData)
|
if (statusData) setStatuses(statusData)
|
||||||
console.log('statuses', statuses)
|
const summaryData = getSummary(network, statusData)
|
||||||
|
|
||||||
const summaryData = getSummary(network, statuses)
|
|
||||||
console.log('summaryData', summaryData)
|
|
||||||
if (summaryData) setSummary(summaryData)
|
if (summaryData) setSummary(summaryData)
|
||||||
}
|
}
|
||||||
getStatuses()
|
getStatuses()
|
||||||
|
@ -9,7 +9,7 @@ export async function getData(): Promise<Status[]> {
|
|||||||
if (!response || response.status !== 200 || !response.data)
|
if (!response || response.status !== 200 || !response.data)
|
||||||
console.log('ERROR: no data recieved')
|
console.log('ERROR: no data recieved')
|
||||||
|
|
||||||
const data = [...response.data]
|
const data = response.data
|
||||||
console.log('1. data length', data.length)
|
console.log('1. data length', data.length)
|
||||||
console.log('1. data ', data)
|
console.log('1. data ', data)
|
||||||
|
|
||||||
@ -20,33 +20,34 @@ export async function getData(): Promise<Status[]> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function getSummary(network: string, data: Status[]): Summary[] {
|
export function getSummary(network: string, data: Status[]): Summary[] {
|
||||||
console.log('2. data', data)
|
console.log('2. data', network, data)
|
||||||
try {
|
try {
|
||||||
if (data) {
|
if (data) {
|
||||||
let status: Status
|
let status: Status
|
||||||
data.forEach((element) => {
|
data.forEach((element) => {
|
||||||
if (element.network === network) return (status = element)
|
if (element.network === network) return (status = element)
|
||||||
})
|
})
|
||||||
|
console.log('network status: ', status)
|
||||||
const summary: Summary[] = [
|
const summary: Summary[] = [
|
||||||
{ component: 'Aquarius', status: status.aquarius.status },
|
{ component: 'Aquarius', status: status?.aquarius?.status },
|
||||||
{ component: 'Provider', status: status.provider.status },
|
{ component: 'Provider', status: status?.provider?.status },
|
||||||
{ component: 'Subgraph', status: status.subgraph.status },
|
{ component: 'Subgraph', status: status?.subgraph?.status },
|
||||||
{ component: 'Market', status: status.market },
|
{ component: 'Market', status: status?.market },
|
||||||
{ component: 'Port', status: status.port },
|
{ component: 'Port', status: status?.port },
|
||||||
{
|
{
|
||||||
component: 'Data Farming',
|
component: 'Data Farming',
|
||||||
status: status.dataFarming
|
status: status?.dataFarming
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
component: 'Operator Service',
|
component: 'Operator Service',
|
||||||
status: status.operator.status
|
status: status?.operator?.status
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
component: 'DAO Grants',
|
component: 'DAO Grants',
|
||||||
status: status.daoGrants
|
status: status?.daoGrants
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
status.faucet.status &&
|
status?.faucet?.status &&
|
||||||
summary.push({
|
summary.push({
|
||||||
component: 'Faucet',
|
component: 'Faucet',
|
||||||
status: status.faucet.status
|
status: status.faucet.status
|
||||||
|
Loading…
Reference in New Issue
Block a user