mirror of
https://github.com/myfatemi04/wheelshare-frontend.git
synced 2025-04-21 11:20:17 -04:00
update getPool API request
This commit is contained in:
parent
9b13a27331
commit
7e6951ac03
|
@ -5,7 +5,7 @@ import Card from '@material-ui/core/Card';
|
||||||
import Textarea from '@material-ui/core/TextareaAutosize';
|
import Textarea from '@material-ui/core/TextareaAutosize';
|
||||||
import Typography from '@material-ui/core/Typography';
|
import Typography from '@material-ui/core/Typography';
|
||||||
import Comment from './Comment';
|
import Comment from './Comment';
|
||||||
import { makeAPIPostCall } from '../api/utils';
|
import { makeAPIGetCall, makeAPIPostCall } from '../api/utils';
|
||||||
import AuthenticationContext from './AuthenticationContext';
|
import AuthenticationContext from './AuthenticationContext';
|
||||||
|
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
|
@ -89,13 +89,11 @@ export default function Pool() {
|
||||||
}, [user, id, pool]);
|
}, [user, id, pool]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetch(`${process.env.REACT_APP_API_ENDPOINT}/pool/${id}`)
|
makeAPIGetCall('/pool', { poolID: id }).then((response) => {
|
||||||
.then((response) => response.json())
|
if (response.data.data) {
|
||||||
.then((data) => {
|
setPool(response.data.data);
|
||||||
if (data !== undefined) {
|
}
|
||||||
setPool(data);
|
});
|
||||||
}
|
|
||||||
});
|
|
||||||
}, [id]);
|
}, [id]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -106,7 +104,7 @@ export default function Pool() {
|
||||||
{pool.title}
|
{pool.title}
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography variant="subtitle1">
|
<Typography variant="subtitle1">
|
||||||
<b>Capacity</b>: {pool.participant_ids.length} / {pool.capacity}
|
<b>Capacity</b>: {pool.participant_ids?.length} / {pool.capacity}
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography variant="subtitle1">
|
<Typography variant="subtitle1">
|
||||||
<b>Start Time</b>: {pool.start_time}
|
<b>Start Time</b>: {pool.start_time}
|
||||||
|
@ -122,7 +120,7 @@ export default function Pool() {
|
||||||
style={{ marginTop: '0.5rem' }}
|
style={{ marginTop: '0.5rem' }}
|
||||||
onClick={onRegister}
|
onClick={onRegister}
|
||||||
>
|
>
|
||||||
{pool.participant_ids.includes(user._id)
|
{pool.participant_ids?.includes(user._id)
|
||||||
? 'Unregister'
|
? 'Unregister'
|
||||||
: 'Register'}
|
: 'Register'}
|
||||||
</Button>
|
</Button>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user