mirror of
https://github.com/myfatemi04/wheelshare-frontend.git
synced 2025-04-21 19:29:51 -04:00
feature: creating carpools with pre-invited users: complete!
This commit is contained in:
parent
8b8ef46b3f
commit
bac9a9aa27
|
@ -112,10 +112,14 @@ export default function Carpools() {
|
||||||
setHasCarpool(alreadyInCarpool);
|
setHasCarpool(alreadyInCarpool);
|
||||||
}, [alreadyInCarpool, setHasCarpool]);
|
}, [alreadyInCarpool, setHasCarpool]);
|
||||||
|
|
||||||
const createEmptyCarpool = useCallback(() => {
|
const createCarpoolCallback = useCallback(() => {
|
||||||
setCreationStatus('pending');
|
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 }) => {
|
.then(({ id }) => {
|
||||||
setCreatedCarpoolId(id);
|
setCreatedCarpoolId(id);
|
||||||
setCreationStatus('completed');
|
setCreationStatus('completed');
|
||||||
|
@ -123,7 +127,7 @@ export default function Carpools() {
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
setCreationStatus('errored');
|
setCreationStatus('errored');
|
||||||
});
|
});
|
||||||
}, [event.id, me.name]);
|
}, [event.id, me.name, tentativeInvites]);
|
||||||
|
|
||||||
const tentativeInviteNames = useMemo(() => {
|
const tentativeInviteNames = useMemo(() => {
|
||||||
if (!signups) return [];
|
if (!signups) return [];
|
||||||
|
@ -146,7 +150,7 @@ export default function Carpools() {
|
||||||
<b>You have invited these people to carpool with you:</b>
|
<b>You have invited these people to carpool with you:</b>
|
||||||
{tentativeInviteNames.join(',')}
|
{tentativeInviteNames.join(',')}
|
||||||
<UIButton
|
<UIButton
|
||||||
onClick={createEmptyCarpool}
|
onClick={createCarpoolCallback}
|
||||||
style={{ backgroundColor: lightgrey }}
|
style={{ backgroundColor: lightgrey }}
|
||||||
>
|
>
|
||||||
{creationStatus === null
|
{creationStatus === null
|
||||||
|
@ -162,7 +166,7 @@ export default function Carpools() {
|
||||||
<>
|
<>
|
||||||
<span>Available to drive?</span>
|
<span>Available to drive?</span>
|
||||||
<UIButton
|
<UIButton
|
||||||
onClick={createEmptyCarpool}
|
onClick={createCarpoolCallback}
|
||||||
style={{ backgroundColor: lightgrey }}
|
style={{ backgroundColor: lightgrey }}
|
||||||
>
|
>
|
||||||
{creationStatus === null
|
{creationStatus === null
|
||||||
|
|
|
@ -175,11 +175,13 @@ export async function getCarpool(id: number): Promise<ICarpool> {
|
||||||
export async function createCarpool({
|
export async function createCarpool({
|
||||||
eventId,
|
eventId,
|
||||||
name,
|
name,
|
||||||
|
invitedUserIds,
|
||||||
}: {
|
}: {
|
||||||
eventId: number;
|
eventId: number;
|
||||||
name: string;
|
name: string;
|
||||||
|
invitedUserIds: number[];
|
||||||
}): Promise<{ id: 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) {
|
export async function sendCarpoolInvite(carpoolId: number, userId: number) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user