import { useState, useEffect, FormEventHandler, useCallback } from 'react'; import { useParams } from 'react-router'; import Button from '@material-ui/core/Button'; import Card from '@material-ui/core/Card'; import Textarea from '@material-ui/core/TextareaAutosize'; import Typography from '@material-ui/core/Typography'; import Comment from './Comment'; export default function Pool({ registered = false }: { registered?: boolean }) { const id = useParams<{ id: string }>().id; const [pool, setPool] = useState({ id: '123', title: 'TJ Carpool', description: 'Carpool from TJ track to homes', start_time: '4/10/2021 3:00 PM', end_time: '4/10/2021 4:00 PM', capacity: 2, participant_ids: [], comments: [ { author_id: 'myfatemi04', id: '1234', body: "what's the vaccination status of everyone?", }, ], driver_id: 'None', create_time: '1234', update_time: '1234', group_id: 'tj', status: 'pending', direction: 'dropoff', author_id: 'michael', type: 'offer', }); const onComment = useCallback>((e) => { e.preventDefault(); fetch(`${process.env.REACT_APP_API_ENDPOINT}/pool/comments`) .then((response) => response.json()) .then((data) => { console.log(data); }); }, []); useEffect(() => { fetch(`${process.env.REACT_APP_API_ENDPOINT}/pool/${id}`) .then((response) => response.json()) .then((data) => { if (data !== undefined) { setPool(data); } }); }, [id]); return ( {pool.title} Capacity: {pool.participant_ids.length} / {pool.capacity} Start Time: {pool.start_time} End Time: {pool.end_time} {pool.description}