mirror of
https://github.com/myfatemi04/wheelshare-frontend.git
synced 2025-04-21 11:20:17 -04:00
make it possible to sign up for an event without giving your address
This commit is contained in:
parent
cadcaa39cb
commit
5ae2f33ca1
|
@ -1,5 +1,9 @@
|
||||||
import { useCallback, useEffect, useRef, useState } from 'react';
|
import { useCallback, useEffect, useRef, useState } from 'react';
|
||||||
import { addEventSignup, getEventSignups, removeEventSignup } from './api';
|
import {
|
||||||
|
addOrUpdateEventSignup,
|
||||||
|
getEventSignups,
|
||||||
|
removeEventSignup,
|
||||||
|
} from './api';
|
||||||
import { green, lightgrey } from './colors';
|
import { green, lightgrey } from './colors';
|
||||||
import { useMe } from './hooks';
|
import { useMe } from './hooks';
|
||||||
import latlongdist, { R_miles } from './latlongdist';
|
import latlongdist, { R_miles } from './latlongdist';
|
||||||
|
@ -312,9 +316,9 @@ export default function Event({ event }: { event: IEvent }) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const addSignup = () => {
|
const addOrUpdateSignup = () => {
|
||||||
if (!prev.interested) {
|
if (!prev.interested) {
|
||||||
addEventSignup(event.id, placeId!)
|
addOrUpdateEventSignup(event.id, placeId)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
prev.placeId = placeId;
|
prev.placeId = placeId;
|
||||||
prev.eventId = event.id;
|
prev.eventId = event.id;
|
||||||
|
@ -328,10 +332,8 @@ export default function Event({ event }: { event: IEvent }) {
|
||||||
|
|
||||||
if (!interested) {
|
if (!interested) {
|
||||||
removeSignup();
|
removeSignup();
|
||||||
} else if (placeId == null) {
|
|
||||||
removeSignup();
|
|
||||||
} else {
|
} else {
|
||||||
addSignup();
|
addOrUpdateSignup();
|
||||||
}
|
}
|
||||||
}, [event.id, interested, placeId, updating]);
|
}, [event.id, interested, placeId, updating]);
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,10 @@ export async function getEventSignups(
|
||||||
return await get(`/events/${eventId}/signups`);
|
return await get(`/events/${eventId}/signups`);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function addEventSignup(eventId: number, placeId: string) {
|
export async function addOrUpdateEventSignup(
|
||||||
|
eventId: number,
|
||||||
|
placeId: string | null
|
||||||
|
) {
|
||||||
return await post(`/events/${eventId}/signup`, {
|
return await post(`/events/${eventId}/signup`, {
|
||||||
placeId,
|
placeId,
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue
Block a user