Begin host page

This commit is contained in:
Dane Johnson 2023-02-11 13:30:59 -06:00
parent cef5fc9879
commit dfe2fb98bc
2 changed files with 27 additions and 0 deletions

View File

@ -6,6 +6,7 @@ import Error from "./Error";
import Landing from "./Landing";
import Display from "./Display";
import Contestant from "./Contestant";
import Host from "./Host";
const App = () => {
return (
@ -15,6 +16,7 @@ const App = () => {
<Route path="/" element={<Landing />} />
<Route path="new-game" element={<Display />} />
<Route path="contestant-join/:room" element={<Contestant />} />
<Route path="host-join/:room" element={<Host />} />
<Route path="/*" element={<Error />} />
</Routes>
</BrowserRouter>

25
src/Host.tsx Normal file
View File

@ -0,0 +1,25 @@
import { useEffect } from "react";
import { useParams } from "react-router-dom";
import { Container, Stack, Button } from "react-bootstrap";
import { socket } from "./socket";
const Host = () => {
const { room } = useParams();
useEffect(() => {
socket.emit("host-join", { room });
}, []);
return (
<Container>
<Stack gap={3} className="text-center">
<span>
<Button onClick={() => socket.emit("host-start")}>Start Game</Button>
</span>
</Stack>
</Container>
);
};
export default Host;