mirror of
https://github.com/myfatemi04/wheelshare-frontend.git
synced 2025-04-16 00:50:18 -04:00
make it use the right placeId and canDrive when loading again
This commit is contained in:
parent
785934b863
commit
f443921761
|
@ -1,4 +1,4 @@
|
||||||
import { useCallback, useRef } from 'react';
|
import { useCallback, useEffect, useRef } from 'react';
|
||||||
import { green, lightgrey } from '../../lib/colors';
|
import { green, lightgrey } from '../../lib/colors';
|
||||||
import getPlaceDetails from '../../lib/getPlaceDetails';
|
import getPlaceDetails from '../../lib/getPlaceDetails';
|
||||||
import { addOrUpdateEventSignup, removeEventSignup } from '../api';
|
import { addOrUpdateEventSignup, removeEventSignup } from '../api';
|
||||||
|
@ -15,6 +15,15 @@ export default function EventInterestForm() {
|
||||||
const placeIdRef = useRef<string | null>(null);
|
const placeIdRef = useRef<string | null>(null);
|
||||||
const canDriveRef = useRef(false);
|
const canDriveRef = useRef(false);
|
||||||
|
|
||||||
|
{
|
||||||
|
const signup = event.signups[me.id];
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
placeIdRef.current = signup?.placeId ?? null;
|
||||||
|
canDriveRef.current = signup?.canDrive ?? false;
|
||||||
|
}, [signup?.canDrive, signup?.placeId]);
|
||||||
|
}
|
||||||
|
|
||||||
const updateSignup = useCallback(async () => {
|
const updateSignup = useCallback(async () => {
|
||||||
const placeId = placeIdRef.current;
|
const placeId = placeIdRef.current;
|
||||||
const canDrive = canDriveRef.current;
|
const canDrive = canDriveRef.current;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user