diff --git a/src/app/points/page.tsx b/src/app/points/page.tsx index 3a98811..0a99b6e 100644 --- a/src/app/points/page.tsx +++ b/src/app/points/page.tsx @@ -56,6 +56,26 @@ export default function PointsPage() { throw new Error('User ID not available') } + // Get consistent user ID from backend + // This ensures we're using the same ID that the backend has stored + // even if the frontend has a different ID due to reauthentication + try { + // Import the function directly here to keep the change minimal + const { findUserByEmail } = await import('../../services/userPointsService'); + + if (userId.includes('@')) { + console.log('Using email to get consistent user ID:', userId); + const user = await findUserByEmail(userId); + if (user && user.id) { + console.log('Found consistent user ID from email:', user.id); + userId = user.id; + } + } + } catch (idErr) { + console.log('Error getting consistent user ID:', idErr); + // Continue with original userId as fallback + } + // We'll try to get points and transactions, but we'll handle failures gracefully let pointsError = false; let transactionsError = false; @@ -205,6 +225,9 @@ export default function PointsPage() { Sum of Transaction Points: {transactions.reduce((sum, tx) => sum + (tx.points || 0), 0)}