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 (
-
+ );
};
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}
+
+
+
+
+
+
+
+
+
+
Comments:
+ {state.comments.map((comment) => {
+ return (
+
+ );
+ })}
+
+
+
+ );
+};
+
+export default Pool;
diff --git a/src/components/Pools.js b/src/components/Pools.js
index e69de29..62c28ba 100644
--- a/src/components/Pools.js
+++ b/src/components/Pools.js
@@ -0,0 +1,127 @@
+import React, { useState, useEffect } from 'react';
+
+const Pools = (props) => {
+ const [state, setState] = useState({
+ Pools: [
+ {
+ id: 1,
+ pool_title: 'TJ Carpool',
+ 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?',
+ ],
+ },
+ {
+ id: 2,
+ pool_title: 'TJ Carpool',
+ 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?',
+ ],
+ },
+ {
+ id: 3,
+ pool_title: 'TJ Carpool',
+ 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?',
+ ],
+ },
+ {
+ id: 4,
+ pool_title: 'TJ Carpool',
+ 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}/Pools/`, requestOptions)
+ .then((response) => response.json())
+ .then((data) => {
+ if (data !== undefined) {
+ setState(data);
+ }
+ });
+ };
+
+ useEffect(() => {
+ callAPI();
+ }, []);
+ const maybePluralize = (count, noun, suffix = 's') =>
+ `${count} ${noun}${count !== 1 ? suffix : ''}`;
+ return (
+
+
+ Pools
+
+
+ Create Pool
+
+
+
+ {state.Pools.map((Pool, el) => {
+ let background;
+ if (el % 2 == 0) {
+ background = '#F1EAE8';
+ } else {
+ background = '#FFFFFF';
+ }
+ return (
+
+
+ {Pool.pool_title}
+
+
+ Capacity: {Pool.participants.length} / {Pool.capacity}
+
+
Start Time: {Pool.start_time}
+
End Time: {Pool.end_time}
+
+ {maybePluralize(Pool.comments.length, 'comment')}
+
+
+ );
+ })}
+
+
+ );
+};
+
+export default Pools;
diff --git a/src/components/Profile.js b/src/components/Profile.js
index e69de29..f085c07 100644
--- a/src/components/Profile.js
+++ b/src/components/Profile.js
@@ -0,0 +1,96 @@
+import React, { useState, useEffect } from 'react';
+
+const Profile = (props) => {
+ const [state, setState] = useState({
+ user: { username: 'HyperionLegion' },
+ pools: [
+ {
+ pool_title: 'TJ Carpool',
+ pool_text: 'Carpool from TJ track to homes',
+ start_time: '4/10/2021 3:00 PM',
+ id: 1,
+ end_time: '4/10/2021 4:00 PM',
+ capacity: 2,
+ participants: [],
+ comments: [
+ 'What is the covid vaccination status of all the participants?',
+ ],
+ },
+ {
+ pool_title: 'TJ Carpool',
+ pool_text: 'Carpool from TJ track to homes',
+ start_time: '4/10/2021 3:00 PM',
+ id: 2,
+ end_time: '4/10/2021 4:00 PM',
+ capacity: 2,
+ participants: [],
+ comments: [
+ 'What is the covid vaccination status of all the participants?',
+ ],
+ },
+ {
+ pool_title: 'TJ Carpool',
+ pool_text: 'Carpool from TJ track to homes',
+ start_time: '4/10/2021 3:00 PM',
+ id: 3,
+ end_time: '4/10/2021 4:00 PM',
+ capacity: 2,
+ participants: [],
+ comments: [
+ 'What is the covid vaccination status of all the participants?',
+ ],
+ },
+ ],
+ groups: [],
+ });
+ const [stocks, setStocks] = useState([]);
+
+ const requestOptions = {
+ method: 'GET',
+ headers: {
+ Authorization: `Bearer ${localStorage.getItem('token')}`,
+ },
+ };
+
+ const callAPI = () => {
+ fetch(`${process.env.REACT_APP_API_ENDPOINT}/profile/`, requestOptions)
+ .then((response) => response.json())
+ .then((data) => {
+ if (data !== undefined) {
+ setState(data);
+ }
+ });
+ };
+
+ useEffect(() => {
+ callAPI();
+ }, []);
+ return (
+
+
+ Profile
+
+
+
Hello {state.user.username}!
+
Your Pools:
+
+ {state.pools.map((pool) => {
+ return (
+
+ );
+ })}
+
+
+
+ );
+};
+
+export default Profile;
diff --git a/src/components/UpdatePool.js b/src/components/UpdatePool.js
index e69de29..a9e8b26 100644
--- a/src/components/UpdatePool.js
+++ b/src/components/UpdatePool.js
@@ -0,0 +1,136 @@
+import React, { useState, useEffect } from 'react';
+
+const UpdatePool = (props) => {
+ const id = props.match.params.id;
+ const [state, setState] = useState({
+ pool_title: 'TJ Carpool',
+ 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 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);
+ });
+ };
+ useEffect(() => {
+ callAPI();
+ }, []);
+ return (
+
+ );
+};
+
+export default UpdatePool;