2021-06-25 02:07:36 +02:00
|
|
|
import React from 'react';
|
2021-06-28 11:36:41 +02:00
|
|
|
import {
|
|
|
|
Table,
|
|
|
|
Thead,
|
|
|
|
Tbody,
|
|
|
|
Tr,
|
|
|
|
Th,
|
|
|
|
Td,
|
|
|
|
TableCaption,
|
|
|
|
Switch
|
|
|
|
} from "@chakra-ui/react"
|
2021-06-25 02:07:36 +02:00
|
|
|
import Head from 'next/head'
|
|
|
|
import { useSession } from 'next-auth/client'
|
|
|
|
|
|
|
|
|
2021-06-28 11:36:41 +02:00
|
|
|
function Controller({initialState}) {
|
|
|
|
const [online, setOnline] = React.useState(initialState)
|
|
|
|
|
|
|
|
React.useEffect(()=>{
|
|
|
|
// fake post req
|
|
|
|
console.log(online)
|
|
|
|
}, [online])
|
2021-06-25 02:07:36 +02:00
|
|
|
|
2021-06-28 11:36:41 +02:00
|
|
|
return (
|
|
|
|
<Switch
|
|
|
|
size="lg"
|
|
|
|
colorScheme={'teal'}
|
|
|
|
isChecked={online}
|
|
|
|
value={online}
|
|
|
|
onChange={() => { setOnline(!online) }}
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
}
|
2021-06-25 02:07:36 +02:00
|
|
|
|
|
|
|
function Commands() {
|
|
|
|
const [session, loading] = useSession()
|
2021-06-28 11:36:41 +02:00
|
|
|
|
|
|
|
|
|
|
|
const [commands, setCommands] = React.useState(
|
|
|
|
[
|
|
|
|
{command: 'Help', online: true},
|
|
|
|
{command: 'Help', online: true},
|
|
|
|
{command: 'Help', online: true},
|
|
|
|
{command: 'Help', online: true},
|
|
|
|
]
|
|
|
|
)
|
|
|
|
|
2021-06-25 02:07:36 +02:00
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
{session &&
|
|
|
|
<>
|
|
|
|
<Head>
|
|
|
|
<title>Cath Commands</title>
|
|
|
|
</Head>
|
2021-06-28 11:36:41 +02:00
|
|
|
<Table variant="simple">
|
|
|
|
<TableCaption>Command Controls</TableCaption>
|
|
|
|
<Thead>
|
|
|
|
<Tr>
|
|
|
|
<Th>Command</Th>
|
|
|
|
<Th>Enabled</Th>
|
|
|
|
</Tr>
|
|
|
|
</Thead>
|
|
|
|
<Tbody>
|
|
|
|
{commands.map((command, idx)=>(
|
|
|
|
<Tr key={idx}>
|
|
|
|
<Td>{command.command}</Td>
|
|
|
|
<Td>
|
|
|
|
<Controller initialState={command.online}/>
|
|
|
|
</Td>
|
|
|
|
</Tr>
|
|
|
|
))}
|
|
|
|
|
|
|
|
</Tbody>
|
|
|
|
</Table>
|
2021-06-25 02:07:36 +02:00
|
|
|
</>
|
|
|
|
} {!session && <>
|
|
|
|
<h1>Seems like you're not logged in. Log in to get started!</h1>
|
|
|
|
</>
|
|
|
|
}
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export default Commands
|