Replaced dummy data in commands page to API data

This commit is contained in:
qt-coder 2021-07-04 18:42:43 +08:00
parent 2fa79da9d7
commit f38696e60e

View file

@ -13,6 +13,7 @@ import {
import Head from 'next/head'
import { useSession } from 'next-auth/client'
import axios from 'axios'
import { FaBullseye } from 'react-icons/fa';
function Controller({ initialState }) {
@ -29,6 +30,13 @@ function Controller({ initialState }) {
)
}
function processOnline(status) {
console.log(status)
if (status == 'online') { return true }
if (status == 'offline') { return false }
if (status == 'maintenance') { return false }
}
function Commands() {
const [session, loading] = useSession()
@ -70,7 +78,7 @@ function Commands() {
<Tr key={commandIdx}>
<Td>{command.name}</Td>
<Td>
<Controller initialState={command.online} />
<Controller initialState={processOnline(command.status)} />
</Td>
</Tr>
))}