diff --git a/src/components/ApplicationViews.js b/src/components/ApplicationViews.js
index 30114df..6827238 100644
--- a/src/components/ApplicationViews.js
+++ b/src/components/ApplicationViews.js
@@ -4,6 +4,7 @@ import { EventList } from "./game/EventList.js"
import { GameList } from "./game/GameList.js"
import { GameForm } from "./game/GameForm.js"
import { EventForm } from "./game/EventForm.js"
+import { UpdateEvent } from "./game/UpdateEvent.js"
export const ApplicationViews = () => {
return <>
{
+
+
+
>
}
\ No newline at end of file
diff --git a/src/components/game/EventList.js b/src/components/game/EventList.js
index 18b3667..70b15f8 100644
--- a/src/components/game/EventList.js
+++ b/src/components/game/EventList.js
@@ -1,15 +1,20 @@
-import React, { useEffect, useState } from "react"
-import { getEvents } from "./EventManager.js"
+import React, { useEffect, useState, } from "react"
+import { getEvents, } from "./EventManager.js"
+import { UpdateEvent } from "./UpdateEvent.js"
+import { useHistory } from "react-router-dom/cjs/react-router-dom.min"
export const EventList = (props) => {
const [ events, setEvents ] = useState([])
+ const history = useHistory()
useEffect(() => {
getEvents().then(data => setEvents(data))
}, [])
return (
+
+
{
- events.map(event => {
- return
+ events.map(
+ event => {
+ return(
+ <>
+
+
{event.description}
The event is happening on {event.date} at {event.time}.
- })
- }
+ >
+ )
+
+ }
+ )
+ }
+
+
+
)
}
\ No newline at end of file
diff --git a/src/components/game/EventManager.js b/src/components/game/EventManager.js
index 86daf5f..4245cb0 100644
--- a/src/components/game/EventManager.js
+++ b/src/components/game/EventManager.js
@@ -5,4 +5,22 @@ export const getEvents = () => {
}
})
.then(response => response.json())
+}
+export const putEvents = (evt) => {
+ return fetch(`http://localhost:8000/events/${evt.id}`, {
+ method: "PUT",
+ body: JSON.stringify(
+ evt
+ ),
+ headers:{
+ "Authorization": `Token ${localStorage.getItem("lu_token")}`
+ }
+ }
+ )
+ .then(response => {response => {
+ return response.json()
+ }
+ }
+ )
+
}
\ No newline at end of file
diff --git a/src/components/game/GameList.js b/src/components/game/GameList.js
index f5c9a48..a18a04a 100644
--- a/src/components/game/GameList.js
+++ b/src/components/game/GameList.js
@@ -1,9 +1,11 @@
import React, { useEffect, useState } from "react"
import { getGames } from "./GameManager.js"
+import { UpdateEvent } from "./UpdateEvent.js"
export const GameList = (props) => {
const [ games, setGames ] = useState([])
+
useEffect(() => {
getGames().then(data => setGames(data))
},
@@ -11,6 +13,8 @@ export const GameList = (props) => {
)
return (
+ <>
+
+ >
)
}
\ No newline at end of file
diff --git a/src/components/game/GameManager.js b/src/components/game/GameManager.js
index 572a835..290be82 100644
--- a/src/components/game/GameManager.js
+++ b/src/components/game/GameManager.js
@@ -7,6 +7,15 @@ export const getGames = () => {
.then(response => response.json())
}
+export const getGamesById = () => {
+ return fetch(`http://localhost:8000/games/${games.id}`, {
+ headers:{
+ "Authorization": `Token ${localStorage.getItem("lu_token")}`
+ }
+ })
+ .then(response => response.json())
+}
+
export const createGame = (game) => {
return fetch("http://localhost:8000/games", {
headers:{
diff --git a/src/components/game/UpdateEvent.js b/src/components/game/UpdateEvent.js
index 4520dd1..1f28ea1 100644
--- a/src/components/game/UpdateEvent.js
+++ b/src/components/game/UpdateEvent.js
@@ -1,9 +1,53 @@
-import react, { useState, useEffect, useHistory} from "react";
+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";
-export const UpdateEvent = () => {
- const [intialvalue, setinitialvalue ] = useState("")
+export const UpdateEvent = (props) => {
+ const [gameList, setGameList] = useState([])
+ let { id } = useParams()
+ const history = useHistory()
+
+
+
+
+ useEffect(() => {
+ getGames().then(data => setGameList(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(
+ eventupdateform()
+ )
}
-const eventupdateform = () => {
-
-}
\ No newline at end of file