7.3 KiB
Transactions Troubleshooting Guide
Issue: No Transactions Showing
If you're seeing no transactions on the /transactions page, follow these steps:
Step 1: Verify You're Logged In
The transactions page requires authentication. Make sure you:
- Are logged in via Steam on the frontend
- Have a valid JWT token in your cookies
- The session is active in the database
Quick Check:
// Open browser console (F12) and run:
console.log(document.cookie);
// Should show: accessToken=... and refreshToken=...
If no tokens are present, log in again via Steam.
Step 2: Clear Old Mock Sessions
The seed script initially created mock sessions with fake tokens. These won't work because they're not valid JWTs.
Delete Mock Sessions:
// In MongoDB or using a script:
db.sessions.deleteMany({ token: /^mock_token_/ });
Or via Node:
node -e "
import('mongoose').then(async mongoose => {
await mongoose.connect(process.env.MONGODB_URI || 'mongodb://localhost:27017/turbotrades');
const Session = (await import('./models/Session.js')).default;
const result = await Session.deleteMany({ token: /^mock_token_/ });
console.log('Deleted', result.deletedCount, 'mock sessions');
await mongoose.disconnect();
process.exit(0);
});
"
Step 3: Re-Login and Re-Seed
- Login via Steam on the frontend (
http://localhost:5173) - Verify you're logged in (check profile page)
- Delete existing fake transactions (optional):
node -e " import('mongoose').then(async mongoose => { await mongoose.connect(process.env.MONGODB_URI || 'mongodb://localhost:27017/turbotrades'); const Transaction = (await import('./models/Transaction.js')).default; const result = await Transaction.deleteMany({}); console.log('Deleted', result.deletedCount, 'transactions'); await mongoose.disconnect(); process.exit(0); }); " - Run the seed script again:
node seed-transactions.js
The seed script now only uses real sessions with valid JWT tokens.
Step 4: Verify Transactions in Database
node -e "
import('mongoose').then(async mongoose => {
await mongoose.connect(process.env.MONGODB_URI || 'mongodb://localhost:27017/turbotrades');
const User = (await import('./models/User.js')).default;
const Transaction = (await import('./models/Transaction.js')).default;
const user = await User.findOne().sort({ createdAt: -1 });
console.log('User:', user.username, '- ID:', user._id);
const transactions = await Transaction.find({ userId: user._id });
console.log('Transactions:', transactions.length);
if (transactions.length > 0) {
console.log('Sample:', transactions[0].type, transactions[0].amount);
}
await mongoose.disconnect();
process.exit(0);
});
"
Step 5: Check Browser Console
Open browser DevTools (F12) and look for:
🔄 Fetching transactions...
✅ Transaction response: { success: true, transactions: [...], stats: {...} }
📊 Loaded 28 transactions
Common Errors:
401 Unauthorized:
- Not logged in or token expired
- Solution: Log in again via Steam
500 Server Error:
- Check backend console for errors
- Verify MongoDB is running
Empty Array:
- Transactions exist but for a different user
- Solution: Delete transactions and re-seed after logging in
Step 6: Check Backend Console
Backend should show:
📊 Fetching transactions for user: 6961b31dadcc335cb645e95f
✅ Found 28 transactions
📈 Stats: { totalDeposits: ..., ... }
If you see:
✅ Found 0 transactions
Then transactions don't exist for your logged-in user. Re-run seed script.
Dropdown Styling Issue
The dropdowns were using a non-existent input-field class. This has been fixed with proper Tailwind classes:
<select class="w-full px-4 py-2 bg-surface rounded-lg border border-surface-lighter text-text-primary focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent">
The dropdowns should now look consistent with the rest of the UI.
Complete Reset Procedure
If all else fails, start fresh:
1. Stop servers:
# Kill backend and frontend
2. Clean database:
node -e "
import('mongoose').then(async mongoose => {
await mongoose.connect(process.env.MONGODB_URI || 'mongodb://localhost:27017/turbotrades');
const Session = (await import('./models/Session.js')).default;
const Transaction = (await import('./models/Transaction.js')).default;
await Session.deleteMany({});
await Transaction.deleteMany({});
console.log('✅ Cleaned sessions and transactions');
await mongoose.disconnect();
process.exit(0);
});
"
3. Start backend:
npm run dev
4. Start frontend:
cd frontend
npm run dev
5. Login via Steam:
- Navigate to
http://localhost:5173 - Click "Login with Steam"
- Complete OAuth flow
6. Verify login:
- Go to
http://localhost:5173/profile - Check "Active Sessions" section
- Should see your current session
7. Seed transactions:
node seed-transactions.js
8. View transactions:
- Navigate to
http://localhost:5173/transactions - Should see 20-30 transactions with colored session pills
Expected Result
Once working, you should see:
┌─────────────────────────────────────────────────────────────┐
│ Transaction History 📊 Stats │
├─────────────────────────────────────────────────────────────┤
│ │
│ 💰 Deposit +$121.95 │
│ PayPal deposit │
│ 📅 2 days ago 💻 Session: [DBDBDD] 🖥️ Chrome │
│ ^^^^^^^^ │
│ (colored pill!) │
│ │
│ 🛒 Purchase -$244.67 │
│ Karambit | Fade │
│ 📅 5 days ago 💻 Session: [DBDBE1] 🖥️ Opera │
│ │
└─────────────────────────────────────────────────────────────┘
Key Points
✅ Transactions require authentication - You must be logged in via Steam ✅ JWT tokens are required - Mock tokens from seed script don't work ✅ Sessions must be real - Created by actual Steam login ✅ User IDs must match - Transactions linked to the logged-in user
Still Not Working?
Check these files for console.log output:
Frontend: Browser console (F12)
Backend: Terminal where npm run dev is running
Look for the debug logs added:
🔄 Fetching transactions...📊 Fetching transactions for user:✅ Found X transactions
If you see API 401 errors, you need to log in again to get a valid JWT token.