fix bug back navigation

This commit is contained in:
NW
2024-12-15 02:04:43 +00:00
parent 9d9e0e80ad
commit 2cfa37ea86
3 changed files with 30 additions and 11 deletions

View File

@@ -2,10 +2,16 @@ import db from "../config/database.js";
class CategoryService {
static async getCategoriesByLocationId(locationId) {
return await db.allAsync(
'SELECT id, name FROM categories WHERE location_id = ? ORDER BY name',
[locationId]
);
try {
const categories = await db.allAsync(
'SELECT * FROM categories WHERE location_id = ?',
[locationId]
);
return categories;
} catch (error) {
console.error('Error fetching categories by location ID:', error);
throw new Error('Failed to fetch categories');
}
}
static async getSubcategoriesByCategoryId(categoryId) {

View File

@@ -20,10 +20,16 @@ class LocationService {
}
static async getLocation(country, city, district) {
return await db.getAsync(
'SELECT id FROM locations WHERE country = ? AND city = ? AND district = ?',
[country, city, district]
);
try {
const location = await db.getAsync(
'SELECT * FROM locations WHERE country = ? AND city = ? AND district = ?',
[country, city, district]
);
return location;
} catch (error) {
console.error('Error fetching location:', error);
throw new Error('Failed to fetch location');
}
}
static async getLocationById(locationId) {