diff --git a/src/components/Event/EventInterestForm.tsx b/src/components/Event/EventInterestForm.tsx index db39f61..73e2c4e 100644 --- a/src/components/Event/EventInterestForm.tsx +++ b/src/components/Event/EventInterestForm.tsx @@ -1,4 +1,4 @@ -import { useCallback, useRef } from 'react'; +import { useCallback, useEffect, useRef } from 'react'; import { green, lightgrey } from '../../lib/colors'; import getPlaceDetails from '../../lib/getPlaceDetails'; import { addOrUpdateEventSignup, removeEventSignup } from '../api'; @@ -15,6 +15,15 @@ export default function EventInterestForm() { const placeIdRef = useRef(null); 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 placeId = placeIdRef.current; const canDrive = canDriveRef.current;