import { CenterFocusStrong } from '@material-ui/icons'; import React, { useState, useEffect } from 'react'; const maybePluralize = (count: number, noun: string, suffix = 's') => `${count} ${noun}${count !== 1 ? suffix : ''}`; const Profile = () => { const [state, setState] = useState({ user: { username: 'HyperionLegion', }, pools: [ { title: 'TJ Carpool', description: '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, participant_ids: [], comments: [ 'What is the covid vaccination status of all the participants?', ], }, { title: 'TJ Carpool', description: '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, participant_ids: [], comments: [ 'What is the covid vaccination status of all the participants?', ], }, { title: 'TJ Carpool', description: '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, participant_ids: [], comments: [ 'What is the covid vaccination status of all the participants?', ], }, ], groups: [], }); const callAPI = () => { fetch(`${process.env.REACT_APP_API_ENDPOINT}/profile/`) .then((response) => response.json()) .then((data) => { if (data !== undefined) { setState(data); } }); }; useEffect(() => { callAPI(); }, []); return (

Profile

{state.user.username}'s Pools

{state.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 Profile;