diff --git a/src/Host.tsx b/src/Host.tsx
index 7ba2482..edff46f 100644
--- a/src/Host.tsx
+++ b/src/Host.tsx
@@ -1,25 +1,26 @@
import { useEffect } from "react";
import { useParams } from "react-router-dom";
-import { Container, Stack, Button } from "react-bootstrap";
import { socket } from "./socket";
+import { useAppSelector } from "./hooks";
+import { selectCategories } from "./store/cluesSlice";
+import Pregame from "./host/Pregame";
+import CluesDisplay from "./host/CluesDisplay";
const Host = () => {
const { room } = useParams();
+ const categories = useAppSelector(selectCategories);
+
useEffect(() => {
socket.emit("host-join", { room });
}, []);
- return (
-
-
-
-
-
-
-
- );
+ if (categories.length < 6) {
+ return ;
+ } else {
+ return ;
+ }
};
export default Host;
diff --git a/src/host/CluesDisplay.tsx b/src/host/CluesDisplay.tsx
new file mode 100644
index 0000000..41d7564
--- /dev/null
+++ b/src/host/CluesDisplay.tsx
@@ -0,0 +1,24 @@
+import { Container, Button, Stack } from "react-bootstrap";
+
+import { useAppSelector } from "../hooks";
+import { selectCategories } from "../store/cluesSlice";
+
+const CluesDisplay = () => {
+ const categories = useAppSelector(selectCategories);
+ return (
+
+
+ {categories.map(({ name }) => (
+ <>
+ {name}
+ {[200, 400, 600, 800, 1000].map((value) => (
+
+ ))}
+ >
+ ))}
+
+
+ );
+};
+
+export default CluesDisplay;
diff --git a/src/host/Pregame.tsx b/src/host/Pregame.tsx
new file mode 100644
index 0000000..080201b
--- /dev/null
+++ b/src/host/Pregame.tsx
@@ -0,0 +1,27 @@
+import { useState } from "react";
+import { Container, Stack, Button } from "react-bootstrap";
+
+import { socket } from "../socket";
+
+const Pregame = () => {
+ const [loading, setLoading] = useState(false);
+ return (
+
+
+
+
+
+
+
+ );
+};
+
+export default Pregame;
diff --git a/src/socket.ts b/src/socket.ts
index c1012b1..870b203 100644
--- a/src/socket.ts
+++ b/src/socket.ts
@@ -2,6 +2,7 @@ import { io } from "socket.io-client";
import store from "./store";
import { setRoomCode } from "./store/socketSlice";
import { addContestant } from "./store/displaySlice";
+import { addCategory } from "./store/cluesSlice";
export const socket = io(`${window.location.hostname}:5000`);
@@ -17,4 +18,8 @@ export const setup = () => {
socket.on("contestant-joined", (data) => {
store.dispatch(addContestant(data));
});
+
+ socket.on("categories", (data) =>
+ data.forEach((category) => store.dispatch(addCategory(category)))
+ );
};
diff --git a/src/store/cluesSlice.ts b/src/store/cluesSlice.ts
new file mode 100644
index 0000000..cb855f9
--- /dev/null
+++ b/src/store/cluesSlice.ts
@@ -0,0 +1,29 @@
+import { createSlice, PayloadAction } from "@reduxjs/toolkit";
+import type { RootState } from "./";
+
+interface Category {
+ name: string;
+ clues: Clue[];
+}
+
+interface Clue {
+ value: number;
+ question: string;
+ answer?: string;
+}
+
+const initialState: Category[] = [];
+
+export const cluesSlice = createSlice({
+ name: "clues",
+ initialState,
+ reducers: {
+ addCategory: (state, { payload }: PayloadAction) =>
+ (state = [...state, { name: payload, clues: [] }]),
+ },
+});
+
+export const { addCategory } = cluesSlice.actions;
+export const selectCategories = (state: RootState) => state.clues;
+
+export default cluesSlice.reducer;
diff --git a/src/store/index.ts b/src/store/index.ts
index 038010e..b302714 100644
--- a/src/store/index.ts
+++ b/src/store/index.ts
@@ -2,12 +2,14 @@ import { configureStore } from "@reduxjs/toolkit";
import socketReducer from "./socketSlice";
import contestantReducer from "./contestantSlice";
import displayReducer from "./displaySlice";
+import cluesReducer from "./cluesSlice";
const store = configureStore({
reducer: {
socket: socketReducer,
contestant: contestantReducer,
display: displayReducer,
+ clues: cluesReducer,
},
});