Begin host page
This commit is contained in:
parent
cef5fc9879
commit
dfe2fb98bc
@ -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
25
src/Host.tsx
Normal 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;
|
Loading…
Reference in New Issue
Block a user