From 7e6951ac03c999802d18c061c143e1057c7f603c Mon Sep 17 00:00:00 2001 From: Michael Fatemi Date: Sat, 10 Apr 2021 21:26:27 -0400 Subject: [PATCH] update getPool API request --- src/components/Pool.tsx | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/components/Pool.tsx b/src/components/Pool.tsx index 5713f45..0b2d2ab 100644 --- a/src/components/Pool.tsx +++ b/src/components/Pool.tsx @@ -5,7 +5,7 @@ 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'; -import { makeAPIPostCall } from '../api/utils'; +import { makeAPIGetCall, makeAPIPostCall } from '../api/utils'; import AuthenticationContext from './AuthenticationContext'; // eslint-disable-next-line @@ -89,13 +89,11 @@ export default function Pool() { }, [user, id, pool]); useEffect(() => { - fetch(`${process.env.REACT_APP_API_ENDPOINT}/pool/${id}`) - .then((response) => response.json()) - .then((data) => { - if (data !== undefined) { - setPool(data); - } - }); + makeAPIGetCall('/pool', { poolID: id }).then((response) => { + if (response.data.data) { + setPool(response.data.data); + } + }); }, [id]); return ( @@ -106,7 +104,7 @@ export default function Pool() { {pool.title} - Capacity: {pool.participant_ids.length} / {pool.capacity} + Capacity: {pool.participant_ids?.length} / {pool.capacity} Start Time: {pool.start_time} @@ -122,7 +120,7 @@ export default function Pool() { style={{ marginTop: '0.5rem' }} onClick={onRegister} > - {pool.participant_ids.includes(user._id) + {pool.participant_ids?.includes(user._id) ? 'Unregister' : 'Register'}