This commit is contained in:
zramsay 2025-03-21 20:31:11 -04:00
parent 17fb74863e
commit 9146a69c99
3 changed files with 36 additions and 1 deletions

View File

@ -393,6 +393,13 @@ export async function POST(req: NextRequest): Promise<NextResponse> {
species
});
// Log wallet address for debugging token award
console.log('Starting token award with address:', {
walletAddressFromForm: walletAddress,
species: species,
hasAddress: !!walletAddress
});
// Attempt to award tokens for this wildlife sighting
const tokenResult = await awardTokensForSighting(species, undefined, walletAddress);

View File

@ -38,6 +38,16 @@ export default function PointsPage() {
if (userIdentifier) {
console.log('Loading points using email identifier:', userIdentifier);
loadUserPoints(userIdentifier);
// Set up an interval to refresh points periodically
const refreshInterval = setInterval(() => {
console.log('Automatically refreshing points data...');
loadUserPoints(userIdentifier);
}, 10000); // Refresh every 10 seconds
return () => {
clearInterval(refreshInterval);
};
} else {
// Fallback to ID if somehow email is missing
const userId = session.user.id;

View File

@ -66,9 +66,27 @@ const WildlifeIdentifier: React.FC = () => {
formData.append('image', selectedImage);
// Add wallet address to the request if connected
const userAddress = getWalletAddress();
// Get the wallet address both from memory and localStorage as backup
let userAddress = getWalletAddress();
// If no in-memory address, try localStorage as fallback
if (!userAddress && typeof window !== 'undefined') {
try {
const storedAddress = localStorage.getItem('wildlife_wallet_address');
if (storedAddress) {
console.log('Using wallet address from localStorage:', storedAddress);
userAddress = storedAddress;
}
} catch (e) {
console.warn('Error accessing localStorage:', e);
}
}
if (userAddress) {
console.log('Found wallet address to include in upload:', userAddress);
formData.append('walletAddress', userAddress);
} else {
console.log('No wallet address found for upload');
}
console.log('Uploading image for analysis...');