+
{game.title} by {game.maker}
{game.number_of_players} players needed
Skill level is {game.skill_level}
diff --git a/src/components/game/GameManager.js b/src/components/game/GameManager.js
index 290be82..3d81c95 100644
--- a/src/components/game/GameManager.js
+++ b/src/components/game/GameManager.js
@@ -7,8 +7,8 @@ export const getGames = () => {
.then(response => response.json())
}
-export const getGamesById = () => {
- return fetch(`http://localhost:8000/games/${games.id}`, {
+export const getGameById = (id) => {
+ return fetch(`http://localhost:8000/games/${id}`, {
headers:{
"Authorization": `Token ${localStorage.getItem("lu_token")}`
}
diff --git a/src/components/game/UpdateEvent.js b/src/components/game/UpdateEvent.js
index 1f28ea1..73a9b4c 100644
--- a/src/components/game/UpdateEvent.js
+++ b/src/components/game/UpdateEvent.js
@@ -2,48 +2,112 @@ import react, { useState, useEffect, } from "react";
import { useParams, useHistory } from "react-router-dom/cjs/react-router-dom.min";
import { getGames } from "./GameManager";
import { putEvents } from "./EventManager";
+import { getEvents, getEventById } from "./EventManager";
+// getGames is imported to allow the select to display a list of games
export const UpdateEvent = (props) => {
- const [gameList, setGameList] = useState([])
+ const [ gameList, setGameList] = useState([])
+ const [ eventList, setEventList] = useState([])
+ const [ eventToEdit, setEventToEdit ] = useState({})
+
+
let { id } = useParams()
- const history = useHistory()
+ const history = useHistory()
- useEffect(() => {
- getGames().then(data => setGameList(data))
+useEffect(() => {
+ getGames().then(data => setGameList(data))
+ getEvents().then(data => setEventList(data))
+ getEventById(id).then(data =>
+ {
+ setEventToEdit(data)
+
+ }
+ )
},
[]
)
+
// Still need to write out this form and figure out controlled/uncontrolled input for it. Event pk value needs to be passed to the form as props if I'm understanding this correctly
const eventupdateform = () => {
return(
<>
Update Event
>
- // How to associate the event id with the form?
- // Rough form completed, need to change input type to be controlled by React. Import putEvents and then worry about getting state to be controlled by React.
+
)
}
return(
diff --git a/src/components/game/UpdateGame.js b/src/components/game/UpdateGame.js
index e69de29..cc5a740 100644
--- a/src/components/game/UpdateGame.js
+++ b/src/components/game/UpdateGame.js
@@ -0,0 +1,117 @@
+import react, { useState, useEffect, } from "react";
+import { useParams, useHistory } from "react-router-dom/cjs/react-router-dom.min";
+import { getEvents } from "./EventManager";
+import { putGames } from "./GameManager";
+import { getGames, getGameById } from "./GameManager";
+
+// getGames is imported to allow the select to display a list of games
+export const UpdateGame = (props) => {
+ const [ gameList, setGameList] = useState([])
+ const [ eventList, setEventList] = useState([])
+ const [ gameToEdit, setGamegameToEdit ] = useState({})
+
+
+ let { id } = useParams()
+ const history = useHistory()
+
+
+
+
+useEffect(() => {
+ getGames().then(data => setGameList(data))
+ getEvents().then(data => setEventList(data))
+ getGameById(id).then(data =>
+ {
+ setGamegameToEdit(data)
+
+ }
+ )
+ },
+ []
+)
+
+
+
+ const gameupdateform = () => {
+ return(
+ <>
+ Update Event
+
+
+ >
+
+ )
+ }
+ return(
+ gameupdateform()
+ )
+}
+