feat(utils,ui): enhance category mapping for tickets

- Updated category mapping in utils.py to include additional categories: 'broken_streetlight', 'drainage', 'pothole', 'signage', and 'streetlight'.
- Implemented a new mapping function in app.js to align backend categories with frontend display values, ensuring consistent data representation across the application.
- Removed an outdated image file and added a new image file to the uploads directory.
This commit is contained in:
2025-09-27 11:06:39 +08:00
parent 52ac471d3e
commit 6924455d35
5 changed files with 23 additions and 3 deletions

View File

@@ -30,13 +30,28 @@ async function fetchTickets(){
}
}
// Map backend category names to frontend filter categories
function mapCategoryToFrontend(backendCategory) {
const categoryMapping = {
'broken_streetlight': 'streetlight', // Backend AI model category
'garbage': 'trash', // Backend AI model category
// Direct matches (backend and frontend categories are the same)
'pothole': 'pothole',
'drainage': 'drainage',
'signage': 'signage',
'streetlight': 'streetlight',
'other': 'other'
};
return categoryMapping[backendCategory] || backendCategory || 'other';
}
// Normalize API data to expected format
function normalizeReportData(report) {
// Backend is already returning data in correct format
// Just ensure all required fields are present
// Just ensure all required fields are present and map categories
return {
id: report.id,
category: report.category || 'other',
category: mapCategoryToFrontend(report.category),
severity: report.severity || 'low',
status: report.status || 'submitted',
notes: report.notes || '',