This commit is contained in:
qt-coder 2021-06-22 08:19:52 +08:00
parent df436e9832
commit 8d750fd31c
2 changed files with 37 additions and 26 deletions

View file

@ -8,6 +8,7 @@ import IconButton from '@material-ui/core/IconButton';
import MenuIcon from '@material-ui/icons/Menu'; import MenuIcon from '@material-ui/icons/Menu';
import Link from 'next/link' import Link from 'next/link'
import AuthButton from './AuthButton' import AuthButton from './AuthButton'
import { useSession } from 'next-auth/client'
const useStyles = makeStyles((theme) => ({ const useStyles = makeStyles((theme) => ({
root: { root: {
@ -22,6 +23,7 @@ const useStyles = makeStyles((theme) => ({
})); }));
export default function ButtonAppBar() { export default function ButtonAppBar() {
const [session, loading] = useSession()
const classes = useStyles(); const classes = useStyles();
return ( return (
@ -38,9 +40,9 @@ export default function ButtonAppBar() {
Cath.exe Cath.exe
</Link> </Link>
</Typography> </Typography>
<Button color="inherit">Stats</Button> {session && <Button color="inherit">Stats</Button>}
<AuthButton/> <AuthButton/>
<Link href='/controlpanel'><Button color="inherit">Control Panel</Button></Link> {session && <Link href='/controlpanel'><Button color="inherit">Control Panel</Button></Link>}
</Toolbar> </Toolbar>
</AppBar> </AppBar>
</div> </div>

View file

@ -8,6 +8,7 @@ import TableHead from '@material-ui/core/TableHead';
import TableRow from '@material-ui/core/TableRow'; import TableRow from '@material-ui/core/TableRow';
import Paper from '@material-ui/core/Paper'; import Paper from '@material-ui/core/Paper';
import Head from 'next/head' import Head from 'next/head'
import { useSession } from 'next-auth/client'
const useStyles = makeStyles({ const useStyles = makeStyles({
table: { table: {
@ -27,9 +28,12 @@ const rows = [
]; ];
function Commands() { function Commands() {
const [session, loading] = useSession()
const classes = useStyles(); const classes = useStyles();
return ( return (
<>
{session &&
<> <>
<Head> <Head>
<title>Cath Commands</title> <title>Cath Commands</title>
@ -57,6 +61,11 @@ function Commands() {
</Table> </Table>
</TableContainer> </TableContainer>
</> </>
} {!session && <>
<h1>Seems like you&apos;re not logged in. Log in to get started!</h1>
</>
}
</>
); );
} }