diff --git a/src/App.tsx b/src/App.tsx index e586d61..7aa58b9 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -9,7 +9,7 @@ import CreatePool from './components/CreatePool'; import CreateGroup from './components/CreateGroup'; import Groups from './components/Groups'; import MyGroups from './components/MyGroups'; - +import MyPools from './components/MyPools'; import UpdatePool from './components/UpdatePool'; import Home from './components/Home'; import Main from './components/Main'; @@ -28,9 +28,10 @@ function App() { + - + diff --git a/src/components/MyPools.js b/src/components/MyPools.js new file mode 100644 index 0000000..dbf0489 --- /dev/null +++ b/src/components/MyPools.js @@ -0,0 +1,118 @@ +import React, { useState, useEffect } from 'react'; +import { API_ENDPOINT } from '../api'; + +const MyPools = (props) => { + // const id = props.match.params.id; + const [pools, setPools] = useState([ + { + 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?', + ], + }, + ]); + + useEffect(() => { + console.log(process.env); + fetch(`${API_ENDPOINT}/my_pools`) + .then((response) => response.json()) + .then((json) => { + if (json) { + setPools(json.data); + } + }); + }, []); + + const maybePluralize = (count, noun, suffix = 's') => + `${count} ${noun}${count !== 1 ? suffix : ''}`; + return ( +
+

+ Pools +

+ + Create Pool + +
+

+ {pools.map((pool, index) => { + let background; + if (index % 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 MyPools; diff --git a/src/components/Nav.tsx b/src/components/Nav.tsx index dff85a9..2b6429a 100644 --- a/src/components/Nav.tsx +++ b/src/components/Nav.tsx @@ -34,6 +34,11 @@ const Nav = () => { MyGroups +
  • + + MyPools + +