diff --git a/src/App.js b/src/App.js index 0eb065d..e7f2e16 100644 --- a/src/App.js +++ b/src/App.js @@ -1,35 +1,37 @@ -import React, { useState } from "react"; -import { BrowserRouter, Route, Switch } from "react-router-dom"; -import Nav from "./components/Nav"; -import Signin from "./components/auth/Signin"; -import Signup from "./components/auth/Signup"; -import Pools from "./components/Pools"; -import Pool from "./components/Pool"; -import Profile from "./components/Profile"; -import CreatePool from "./components/CreatePool"; -import Main from "./components/Main"; -import "bootstrap/dist/css/bootstrap.min.css"; -import "bootstrap/dist/js/bootstrap.bundle.min"; -import "./App.css"; -import ProtectedRoute from "./components/ProtectedRoute.js"; +import React, { useState } from 'react'; +import { BrowserRouter, Route, Switch } from 'react-router-dom'; +import Nav from './components/Nav'; +import Signin from './components/auth/Signin'; +import Signup from './components/auth/Signup'; +import Pools from './components/Pools'; +import Pool from './components/Pool'; +import Profile from './components/Profile'; +import CreatePool from './components/CreatePool'; +import UpdatePool from './components/UpdatePool'; +import Main from './components/Main'; +import 'bootstrap/dist/css/bootstrap.min.css'; +import 'bootstrap/dist/js/bootstrap.bundle.min'; +import './App.css'; +import ProtectedRoute from './components/ProtectedRoute.js'; function App() { - return ( -
- -
- ); + return ( +
+ +
+ ); } export default App; diff --git a/src/components/CreatePool.js b/src/components/CreatePool.js index f322464..9e210bb 100644 --- a/src/components/CreatePool.js +++ b/src/components/CreatePool.js @@ -1,83 +1,107 @@ -import React, { useState, useEffect } from "react"; +import React, { useState, useEffect } from 'react'; const CreatePool = (props) => { - const onSubmit = (e) => { - e.preventDefault(); - const requestOptions = { - method: "Pool", - headers: { - "Content-Type": "application/json", - Authorization: `Bearer ${localStorage.getItem("token")}`, - }, - body: JSON.stringify({ Poolid: props.id }), - }; - fetch(`${process.env.REACT_APP_API_ENDPOINT}/createPool`, requestOptions) - .then((response) => response.json()) - .then((data) => { - console.log(data); - }); - }; - return ( -
-
-
-
-

- Create Pool -

- - -
-
- - -
-
- - -
+ const onSubmit = (e) => { + e.preventDefault(); + const requestOptions = { + method: 'Pool', + headers: { + 'Content-Type': 'application/json', + Authorization: `Bearer ${localStorage.getItem('token')}`, + }, + body: JSON.stringify({ Poolid: props.id }), + }; + fetch(`${process.env.REACT_APP_API_ENDPOINT}/createPool`, requestOptions) + .then((response) => response.json()) + .then((data) => { + console.log(data); + }); + }; + return ( +
+
+ +
+

+ Create Pool +

+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
- -
- -
-
- ); + +
+ +
+
+ ); }; export default CreatePool; diff --git a/src/components/Nav.js b/src/components/Nav.js index 3051b39..1fc371e 100644 --- a/src/components/Nav.js +++ b/src/components/Nav.js @@ -1,40 +1,40 @@ -import React from "react"; +import React from 'react'; const Nav = (props) => { - return ( - - ); + return ( + + ); }; export default Nav; diff --git a/src/components/Pool.js b/src/components/Pool.js index e69de29..ed95c0d 100644 --- a/src/components/Pool.js +++ b/src/components/Pool.js @@ -0,0 +1,99 @@ +import React, { useState, useEffect } from 'react'; + +const Pool = (props) => { + const id = props.match.params.id; + const [state, setState] = useState({ + pool_title: 'TJ Carpool', + id: 1, + pool_text: 'Carpool from TJ track to homes', + start_time: '4/10/2021 3:00 PM', + end_time: '4/10/2021 4:00 PM', + capacity: 2, + participants: [], + comments: ['What is the covid vaccination status of all the participants?'], + }); + + const requestOptions = { + method: 'GET', + headers: { + Authorization: `Bearer ${localStorage.getItem('token')}`, + }, + }; + + const callAPI = () => { + fetch(`${process.env.REACT_APP_API_ENDPOINT}/pool/${id}`, requestOptions) + .then((response) => response.json()) + .then((data) => { + if (data !== undefined) { + setState(data); + } + }); + }; + const onComment = (e) => { + e.preventDefault(); + const requestOptions = { + method: 'pool', + headers: { + 'Content-Type': 'application/json', + Authorization: `Bearer ${localStorage.getItem('token')}`, + }, + body: JSON.stringify({ poolid: props.id }), + }; + fetch(`${process.env.REACT_APP_API_ENDPOINT}/pool/comments`, requestOptions) + .then((response) => response.json()) + .then((data) => { + console.log(data); + }); + }; + useEffect(() => { + callAPI(); + }, []); + return ( +
+

+ Pool {id} +

+
+
+

{state.pool_title}

+

+ Capacity: {state.participants.length} / {state.capacity} +

+

Start Time: {state.start_time}

+

End Time: {state.end_time}

+

{state.pool_text}

+
+
+
+ +
+ + +
+
+
+
+ ); +}; + +export default UpdatePool;