mirror of
https://github.com/myfatemi04/wheelshare-frontend.git
synced 2025-04-16 00:50:18 -04:00
use new api for finding potential invitees
This commit is contained in:
parent
2eea5f0dc5
commit
b6b1701df9
|
@ -1,8 +1,7 @@
|
||||||
import CancelIcon from '@material-ui/icons/Cancel';
|
import CancelIcon from '@material-ui/icons/Cancel';
|
||||||
import PersonAddIcon from '@material-ui/icons/PersonAdd';
|
import PersonAddIcon from '@material-ui/icons/PersonAdd';
|
||||||
import { useContext, useEffect, useMemo } from 'react';
|
import { useContext, useEffect, useMemo } from 'react';
|
||||||
import { getEventSignups } from '../api';
|
import { getPotentialInvitees, PotentialInvitee } from '../api';
|
||||||
import { IEventSignup } from '../types';
|
|
||||||
import useImmutable from '../useImmutable';
|
import useImmutable from '../useImmutable';
|
||||||
import { CarpoolContext } from './Carpool';
|
import { CarpoolContext } from './Carpool';
|
||||||
|
|
||||||
|
@ -46,10 +45,10 @@ export default function InvitationList() {
|
||||||
const eventId = carpool.event.id;
|
const eventId = carpool.event.id;
|
||||||
|
|
||||||
const [availableSignups, setAvailableSignups] =
|
const [availableSignups, setAvailableSignups] =
|
||||||
useImmutable<IEventSignup[] | null>(null);
|
useImmutable<PotentialInvitee[] | null>(null);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
getEventSignups(eventId).then(setAvailableSignups);
|
getPotentialInvitees(eventId).then(setAvailableSignups);
|
||||||
}, [eventId, setAvailableSignups]);
|
}, [eventId, setAvailableSignups]);
|
||||||
|
|
||||||
const invitedUserIDs = useMemo(
|
const invitedUserIDs = useMemo(
|
||||||
|
|
|
@ -228,3 +228,18 @@ export async function getActiveEvents() {
|
||||||
export async function getActiveCarpools() {
|
export async function getActiveCarpools() {
|
||||||
return (await get('/users/@me/active_carpools')) as ICarpool[];
|
return (await get('/users/@me/active_carpools')) as ICarpool[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type PotentialInvitee = {
|
||||||
|
user: {
|
||||||
|
id: number;
|
||||||
|
name: string;
|
||||||
|
};
|
||||||
|
latitude: number;
|
||||||
|
longitude: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
export async function getPotentialInvitees(
|
||||||
|
carpoolId: number
|
||||||
|
): Promise<PotentialInvitee[]> {
|
||||||
|
return await get(`/carpools/${carpoolId}/potential_invitees`);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user