mirror of
https://github.com/oceanprotocol/status-frontend.git
synced 2024-11-23 10:27:27 +01:00
fixes
This commit is contained in:
parent
d7afe55abc
commit
09e25b9eed
@ -1,6 +1,7 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
statusApiUri: process.env.NEXT_STATUS_API_URI || 'http://localhost:8000',
|
statusApiUri:
|
||||||
|
process.env.NEXT_PUBLIC_STATUS_API_URI || 'http://localhost:8000',
|
||||||
availableNetworks:
|
availableNetworks:
|
||||||
process.env.NEXT_NETWORKS ||
|
process.env.NEXT_PUBLIC_NETWORKS ||
|
||||||
'["mainnet","polygon","bsc","moonriver","energyweb","mumbai","moonbase","goerli"]'
|
'["mainnet","polygon","bsc","moonriver","energyweb","mumbai","moonbase","goerli"]'
|
||||||
}
|
}
|
||||||
|
@ -41,8 +41,10 @@ export default function HomePage(): ReactElement {
|
|||||||
async function getStatuses() {
|
async function getStatuses() {
|
||||||
const statusData = await getData()
|
const statusData = await getData()
|
||||||
const summaryData = getSummary(network, statusData)
|
const summaryData = getSummary(network, statusData)
|
||||||
|
console.log('summaryData', summaryData)
|
||||||
if (summaryData) setSummary(summaryData)
|
if (summaryData) setSummary(summaryData)
|
||||||
const networkSummary = getNetworkSUmmary(statusData)
|
const networkSummary = getNetworkSUmmary(statusData)
|
||||||
|
console.log('networkSummary', networkSummary)
|
||||||
if (networkSummary) setNetworks(networkSummary)
|
if (networkSummary) setNetworks(networkSummary)
|
||||||
}
|
}
|
||||||
getStatuses()
|
getStatuses()
|
||||||
|
@ -3,13 +3,22 @@ import { NetworkSummary, State, Status, Summary } from '../@types'
|
|||||||
import { statusApiUri } from '../../app.config'
|
import { statusApiUri } from '../../app.config'
|
||||||
import { availableNetworks } from '../../app.config'
|
import { availableNetworks } from '../../app.config'
|
||||||
|
|
||||||
export async function getData(): Promise<Status[]> {
|
export async function getData(): Promise<Status[][]> {
|
||||||
try {
|
try {
|
||||||
const response: AxiosResponse<Status[]> = await axios.get(`${statusApiUri}`)
|
console.log(
|
||||||
|
'statusApiUri',
|
||||||
|
process.env,
|
||||||
|
process.env.NEXT_PUBLIC_STATUS_API_URI,
|
||||||
|
statusApiUri
|
||||||
|
)
|
||||||
|
const response: AxiosResponse<Status[][]> = await axios.get(
|
||||||
|
`${statusApiUri}`
|
||||||
|
)
|
||||||
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('data', data)
|
||||||
|
|
||||||
return data
|
return data
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -17,12 +26,13 @@ export async function getData(): Promise<Status[]> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getSummary(network: string, data: Status[]): Summary[] {
|
export function getSummary(network: string, data: Status[][]): Summary[] {
|
||||||
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[0].network === network) return (status = element[0])
|
||||||
})
|
})
|
||||||
|
|
||||||
const summary: Summary[] = [
|
const summary: Summary[] = [
|
||||||
@ -57,7 +67,7 @@ export function getSummary(network: string, data: Status[]): Summary[] {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getNetworkSUmmary(data: Status[]): NetworkSummary[] {
|
export function getNetworkSUmmary(data: Status[][]): NetworkSummary[] {
|
||||||
const networks: string[] = JSON.parse(availableNetworks)
|
const networks: string[] = JSON.parse(availableNetworks)
|
||||||
const networkSummary: NetworkSummary[] = []
|
const networkSummary: NetworkSummary[] = []
|
||||||
networks.forEach((network) => {
|
networks.forEach((network) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user