import { useState, useEffect } from 'react'; import { API_ENDPOINT } from '../api/api'; import { makeAPIGetCall } from '../api/utils'; const maybePluralize = (count: number, noun: string, suffix = 's') => `${count} ${noun}${count !== 1 ? suffix : ''}`; const Pools = () => { 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(() => { makeAPIGetCall('/my_pools').then((res) => { if (res.data.data) { setPools(res.data.data); } }); }, []); return (

Pools

Create Pool


{pools.map((pool, index) => { let background; if (index % 2 === 0) { background = '#F1EAE8'; } else { background = '#FFFFFF'; } return (
{pool.title}

Capacity: {pool.participant_ids.length} / {pool.capacity}

Start Time: {pool.start_time}

End Time: {pool.end_time}

{maybePluralize(pool.comments.length, 'comment')}

); })}
); }; export default Pools;