fix: resolve volunteer signup issue
Overview
This MR fixes incorrect volunteer signup state persistence across different camps by introducing camp-specific tracking in localStorage.
Previously, signup status from one camp was reused globally, causing users to be incorrectly redirected (e.g., to the QR page) when accessing a different camp.
What does this MR do and why?
The issue occurred because volunteer signup state was stored without associating it with a specific camp_id. As a result:
- If a user signed up for one camp
- Then opened another camp
- The app incorrectly assumed they were already signed up
Solution
- Introduced camp-specific caching using
camp_id - Ensured cached data is reused only when it matches the current camp
- Cleared stale data when switching camps or logging out
This guarantees correct behavior across multiple camps and avoids false redirects.
Changes Made
-
src/lib/api.ts-
Added camp-specific
localStoragekeys:volunteer_already_signed_upvolunteer_signed_up_camp_id
-
Updated
getVolunteerCampSignupStatus():- Stores
camp_idwhen signup is true - Validates cached signup state against current
camp_id - Clears stale cache if camp mismatch is detected
- Stores
-
Prevents previous camp signup state from affecting new camps
-
-
src/contexts/AuthContext.tsx-
Updated
clearAuthToken():- Removes
volunteer_signed_up_camp_idfromlocalStorage
- Removes
-
Ensures signup state is reset on logout
-
Technical Details
Root Cause
- Signup state was stored globally without any reference to
camp_id - This caused stale state reuse across different camps
Fix Approach
-
Introduced camp-scoped caching
-
Added validation logic:
- Compare stored
camp_idwith current camp - Use cache only if they match
- Compare stored
-
Cleanup strategy:
- Remove stale cache when mismatch occurs
- Clear cache on logout
Trade-offs
- Slight increase in
localStorageusage - Added conditional logic, but improves correctness and UX significantly
Type of Change
-
🐛 Bug fix (non-breaking change that fixes an issue) -
✨ New feature -
💥 Breaking change -
📝 Documentation update -
🎨 UI/UX improvement -
♻ ️ Refactor -
⚡ Performance improvement -
🧪 Test update -
🔧 Configuration change -
🚨 Security fix
Related Issues / References
- Fixes incorrect volunteer signup state reuse across camps
Screenshots or Screen Recordings
Before:
After :
How to Set Up and Validate Locally
-
Pull this branch:
git checkout <volunteer-signup-qrcode> -
Install dependencies:
npm install -
Run the app:
npm run dev -
Test scenarios:
-
Signup as volunteer in Camp A
-
Open Camp B
-
Verify:
- User is NOT redirected to QR page
- Fresh signup state is shown
-
-
Logout and verify:
- Signup state is cleared
- No stale data persists
Testing Done
-
Manual testing completed -
Unit tests added/updated
Code Quality Checklist
Code Standards
-
Code follows project conventions -
No console logs -
No unused variables -
No duplicate code -
ESLint & Prettier pass
React Best Practices
-
Proper hook usage -
Clean state management -
No unnecessary re-renders
API & Data Fetching
-
Proper state handling -
Error cases considered
Error Handling
-
Stale state handled gracefully -
No incorrect redirects
Documentation
-
README.md updated -
.env.exampleupdated
Known Limitations / Technical Debt
- Signup state still relies on
localStorage - No expiration mechanism for cached data (can be improved later)
Additional Notes
- This fix improves multi-camp user experience
- Prevents incorrect navigation flows (especially QR page redirection)
- Future improvement: move caching to server or add TTL

