diff --git a/src/components/BoardSwitcher.jsx b/src/components/BoardSwitcher.jsx
index e99793a..abc429a 100644
--- a/src/components/BoardSwitcher.jsx
+++ b/src/components/BoardSwitcher.jsx
@@ -1,25 +1,45 @@
import React from "react";
+import { useState } from "react";
-function Board(props) {
+function Board({selected, index}) {
let className = "board";
- if (props.selected) {
+
+ if (selected) {
className += " selected";
}
- return
{props.index + 1}
;
+ return {index}
;
}
-function BoardSwitcher(props) {
+function BoardSwitcher({numBoards}) {
let boards = [];
- for (let ii = 0; ii < props.numBoards; ii++) {
- let isSelected = ii === 0;
- boards.push();
+ const [selectedIndex, setSelectedIndex] = useState(0);
+
+ //initializes the board and sets the initial position to be 0
+ for (let boardIndex = 0; boardIndex < numBoards; boardIndex++) {
+ let isSelected = boardIndex === selectedIndex;
+ boards.push();
}
+ //handling board index changies
+ const handleClick = (event) =>{
+
+ // if(selectedIndex === numBoards -1){//if we have reached the end of the boards
+ // //reset to initial board
+ // setSelectedIndex(selectedIndex % numBoards);
+ // }else{
+ // setSelectedIndex(selectedIndex + 1);
+ // }
+
+ setSelectedIndex((selectedIndex + 1) % numBoards);
+
+ console.log(selectedIndex)
+ };
+
return (
{boards}
-
+
);
}
diff --git a/src/main.jsx b/src/main.jsx
index 782f402..316ad56 100644
--- a/src/main.jsx
+++ b/src/main.jsx
@@ -6,6 +6,6 @@ import "./index.css";
const root = ReactDOM.createRoot(document.getElementById("root"));
root.render(
-
+
);