mirror of
https://github.com/mito-systems/ranger-app.git
synced 2026-03-19 08:54:16 +00:00
go
This commit is contained in:
parent
af7c3149d0
commit
1aacb2b381
@ -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() {
|
||||
<span className="font-bold">Sum of Transaction Points:</span> {transactions.reduce((sum, tx) => sum + (tx.points || 0), 0)}
|
||||
</div>
|
||||
<div>
|
||||
<span className="font-bold">Transaction User ID:</span> {transactions.length > 0 ? transactions[0].user_id : 'N/A'}
|
||||
</div>
|
||||
<div className="flex flex-wrap gap-2">
|
||||
<button
|
||||
onClick={async () => {
|
||||
if (!session?.user?.id) return;
|
||||
@ -221,10 +244,30 @@ export default function PointsPage() {
|
||||
</button>
|
||||
<button
|
||||
onClick={() => window.location.href = '/debug/database'}
|
||||
className="px-3 py-1 bg-blue-800 text-blue-200 rounded hover:bg-blue-700"
|
||||
className="px-3 py-1 bg-blue-800 text-blue-200 rounded hover:bg-blue-700 mr-2"
|
||||
>
|
||||
View Database Debug
|
||||
</button>
|
||||
<button
|
||||
onClick={async () => {
|
||||
if (!session?.user?.email) {
|
||||
alert('No email available');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const { mergeDuplicateUsersByEmail } = await import('../../services/userPointsService');
|
||||
const result = await mergeDuplicateUsersByEmail(session.user.email);
|
||||
alert(`Merge result: ${JSON.stringify(result)}`);
|
||||
window.location.reload();
|
||||
} catch (err) {
|
||||
alert(`Error merging users: ${err.message}`);
|
||||
}
|
||||
}}
|
||||
className="px-3 py-1 bg-amber-800 text-amber-200 rounded hover:bg-amber-700"
|
||||
>
|
||||
Merge Duplicate Users
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user