From 7b8452f84f062ac739a290bac7c567410fae6c1a Mon Sep 17 00:00:00 2001 From: Michael Fatemi Date: Sat, 10 Apr 2021 17:34:43 -0400 Subject: [PATCH] improve pool ui --- .env | 2 +- src/components/Comment.tsx | 13 ++++ src/components/Pool.tsx | 127 ++++++++++++++++++------------------- 3 files changed, 74 insertions(+), 68 deletions(-) create mode 100644 src/components/Comment.tsx diff --git a/.env b/.env index 48a28f2..76f22a1 100644 --- a/.env +++ b/.env @@ -1 +1 @@ -REACT_APP_API_ENDPOINT=http://localhost:8080/api \ No newline at end of file +REACT_APP_API_ENDPOINT=http://localhost:5000/api \ No newline at end of file diff --git a/src/components/Comment.tsx b/src/components/Comment.tsx new file mode 100644 index 0000000..328c73e --- /dev/null +++ b/src/components/Comment.tsx @@ -0,0 +1,13 @@ +import Card from '@material-ui/core/Card'; +import Typography from '@material-ui/core/Typography'; + +export default function Comment({ comment }: { comment: Carpool.Comment }) { + return ( + + + Comment by {comment.author_id} + + {comment.body} + + ); +} diff --git a/src/components/Pool.tsx b/src/components/Pool.tsx index 445e35f..bfcfc28 100644 --- a/src/components/Pool.tsx +++ b/src/components/Pool.tsx @@ -1,19 +1,37 @@ 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'; -const Pool = () => { +export default function Pool({ registered = false }: { registered?: boolean }) { const id = useParams<{ id: string }>().id; - const [state, setState] = useState({ - id: 1, - pool_title: 'TJ Carpool', - pool_text: 'Carpool from TJ track to homes', + 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, - participants: [], - comments: ['What is the covid vaccination status of all the participants?'], + 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 [registered, setRegistered] = useState(false); const onComment = useCallback>((e) => { e.preventDefault(); @@ -29,70 +47,45 @@ const Pool = () => { .then((response) => response.json()) .then((data) => { if (data !== undefined) { - setState(data); + 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} +

-
-
-

{state.pool_title}

-

- Capacity: {state.participants.length} / {state.capacity} -

-

Start Time: {state.start_time}

-

End Time: {state.end_time}

-

{state.pool_text}

-
- -
-
- -
-
-