tweak data ordering

This commit is contained in:
Matthias Kretschmann 2022-10-19 18:05:19 +01:00
parent 99320cffe4
commit a9d6a68545
Signed by: m
GPG Key ID: 606EEEF3C479A91F
2 changed files with 9 additions and 6 deletions

View File

@ -37,7 +37,7 @@ export default function HomePage(): ReactElement {
async function getStatuses() {
setIsloading(true)
const data = await getData()
if (!data) setError(`Could not fetch data from ${statusApiUri}`)
if (!data) setError(`Could not get data from ${statusApiUri}`)
setData(data)
setIsloading(false)
}
@ -76,7 +76,9 @@ export default function HomePage(): ReactElement {
) : (
Object.entries(data || {}).map(([networkName, value]) => (
<Fragment key={networkName}>
<h2 className={styles.networkName}>{networkName}</h2>
<h2 className={styles.networkName}>
{networkName == 'general' ? null : networkName}
</h2>
<div className={styles.grid}>
{value.components.map((component) => (
<div

View File

@ -8,12 +8,13 @@ export async function getData(): Promise<{ [key: string]: Status }> {
if (!response?.data || response.status !== 200)
throw Error('ERROR: no data recieved')
// transform data into object with network names as keys,
// and make sure 'general' is always the first key
const output = Object.fromEntries(
// transform data into object with network names as keys
let output = Object.fromEntries(
response.data?.map((item) => [item.network, item])
)
console.log('Got new data', output)
// make sure 'general' is always the first key
output = Object.assign({ general: output['general'] }, output)
console.log('Got new data', JSON.stringify(output))
return output
} catch (error) {
console.error(error.message)