mirror of
https://github.com/myfatemi04/wheelshare-frontend.git
synced 2025-04-21 11:20:17 -04:00
improve Group page API
This commit is contained in:
parent
2eb0871d14
commit
28274b3fc7
|
@ -38,12 +38,17 @@ const SAMPLE_POOLS: Carpool.Pool[] = [
|
|||
export default function Group() {
|
||||
// eslint-disable-next-line
|
||||
const { id } = useParams<{ id: string }>();
|
||||
const [error, setError] = useState(false);
|
||||
const [group, setGroup] = useState<Carpool.Group>();
|
||||
const [pools, setPools] = useState<Carpool.Pool[]>(SAMPLE_POOLS);
|
||||
|
||||
useEffect(() => {
|
||||
makeAPIGetCall('/group', { groupID: id }).then((res) => {
|
||||
setGroup(res.data.data);
|
||||
if ('error' in res.data) {
|
||||
setError(true);
|
||||
} else {
|
||||
setGroup(res.data.data);
|
||||
}
|
||||
});
|
||||
|
||||
makeAPIGetCall('/group_pools', { groupID: id }).then((res) => {
|
||||
|
@ -51,6 +56,10 @@ export default function Group() {
|
|||
});
|
||||
}, [id]);
|
||||
|
||||
if (error) {
|
||||
return <h1 style={{ textAlign: 'center' }}>Group Not Found</h1>;
|
||||
}
|
||||
|
||||
if (!group) {
|
||||
return <h1 style={{ textAlign: 'center' }}>Loading</h1>;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user