diff --git a/src/components/Event/EventCarpools.tsx b/src/components/Event/EventCarpools.tsx index 0dd2a1f..a08e170 100644 --- a/src/components/Event/EventCarpools.tsx +++ b/src/components/Event/EventCarpools.tsx @@ -112,10 +112,14 @@ export default function Carpools() { setHasCarpool(alreadyInCarpool); }, [alreadyInCarpool, setHasCarpool]); - const createEmptyCarpool = useCallback(() => { + const createCarpoolCallback = useCallback(() => { setCreationStatus('pending'); - createCarpool({ name: me.name + "'s Carpool", eventId: event.id }) + createCarpool({ + name: me.name + "'s Carpool", + eventId: event.id, + invitedUserIds: tentativeInvites.toArray(), + }) .then(({ id }) => { setCreatedCarpoolId(id); setCreationStatus('completed'); @@ -123,7 +127,7 @@ export default function Carpools() { .catch(() => { setCreationStatus('errored'); }); - }, [event.id, me.name]); + }, [event.id, me.name, tentativeInvites]); const tentativeInviteNames = useMemo(() => { if (!signups) return []; @@ -146,7 +150,7 @@ export default function Carpools() { You have invited these people to carpool with you: {tentativeInviteNames.join(',')} {creationStatus === null @@ -162,7 +166,7 @@ export default function Carpools() { <> Available to drive? {creationStatus === null diff --git a/src/components/api.ts b/src/components/api.ts index 61fd027..ac09a49 100644 --- a/src/components/api.ts +++ b/src/components/api.ts @@ -175,11 +175,13 @@ export async function getCarpool(id: number): Promise { export async function createCarpool({ eventId, name, + invitedUserIds, }: { eventId: number; name: string; + invitedUserIds: number[]; }): Promise<{ id: number }> { - return await post('/carpools/', { eventId, name }); + return await post('/carpools/', { eventId, name, invitedUserIds }); } export async function sendCarpoolInvite(carpoolId: number, userId: number) {