fix: use qsoId for fetching QSO details in award page modal
The award page was filtering QSOs by callsign/date/band/mode, which could return the wrong QSO when multiple QSOs with the same callsign exist on the same band/mode combination. Changes: - Backend: Add qsoId field to award entity breakdown responses - Backend: Add GET /api/qsos/:id endpoint to fetch QSO by ID - Backend: Implement getQSOById() function in lotw.service.js - Frontend: Update openQSODetailModal() to fetch by qsoId instead of filtering - Frontend: Include qsoId in QSO entry objects for modal click handler Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -13,6 +13,7 @@ import {
|
||||
getUserQSOs,
|
||||
getQSOStats,
|
||||
deleteQSOs,
|
||||
getQSOById,
|
||||
} from './services/lotw.service.js';
|
||||
import {
|
||||
enqueueJob,
|
||||
@@ -489,6 +490,44 @@ const app = new Elysia()
|
||||
}
|
||||
})
|
||||
|
||||
/**
|
||||
* GET /api/qsos/:id
|
||||
* Get a single QSO by ID (requires authentication)
|
||||
*/
|
||||
.get('/api/qsos/:id', async ({ user, params, set }) => {
|
||||
if (!user) {
|
||||
set.status = 401;
|
||||
return { success: false, error: 'Unauthorized' };
|
||||
}
|
||||
|
||||
try {
|
||||
const qsoId = parseInt(params.id);
|
||||
if (isNaN(qsoId)) {
|
||||
set.status = 400;
|
||||
return { success: false, error: 'Invalid QSO ID' };
|
||||
}
|
||||
|
||||
const qso = await getQSOById(user.id, qsoId);
|
||||
|
||||
if (!qso) {
|
||||
set.status = 404;
|
||||
return { success: false, error: 'QSO not found' };
|
||||
}
|
||||
|
||||
return {
|
||||
success: true,
|
||||
qso,
|
||||
};
|
||||
} catch (error) {
|
||||
logger.error('Failed to fetch QSO by ID', { error: error.message, userId: user?.id, qsoId: params.id });
|
||||
set.status = 500;
|
||||
return {
|
||||
success: false,
|
||||
error: 'Failed to fetch QSO',
|
||||
};
|
||||
}
|
||||
})
|
||||
|
||||
/**
|
||||
* GET /api/qsos/stats
|
||||
* Get QSO statistics (requires authentication)
|
||||
|
||||
Reference in New Issue
Block a user