fix: location navigation uses IDs and pipe separators instead of underscore

Critical fix for product management location selection:
- Country/city callback_data now uses pipe | as separator with
  encodeURIComponent/decodeURIComponent for special chars
- District selection uses location ID (prod_loc_{id}, shop_loc_{id})
  instead of underscore-delimited country_city_district text
- Empty district names now show city name as fallback
- LocationService.getLocationsByCountryAndCity() returns id+district
  for building callback_data with location IDs
- All error handlers in admin product navigation use editOrSendCallback
  to avoid chat clutter
- Routes updated: prod_district_ → prod_loc_, shop_district_ → shop_loc_

This fixes the bug where selecting country/city/district in admin panel
or shop failed because split('_') broke on multi-word names or empty
district values.
This commit is contained in:
NW
2026-06-24 22:44:02 +01:00
parent 6ce8da257a
commit 5a9155613e
6 changed files with 56 additions and 47 deletions

View File

@@ -15,7 +15,14 @@ class LocationService {
static async getDistrictsByCountryAndCity(country, city) {
return await db.allAsync(
'SELECT district FROM locations WHERE country = ? AND city = ? ORDER BY district',
'SELECT id, district FROM locations WHERE country = ? AND city = ? ORDER BY district',
[country, city]
);
}
static async getLocationsByCountryAndCity(country, city) {
return await db.allAsync(
'SELECT id, country, city, district FROM locations WHERE country = ? AND city = ? ORDER BY district',
[country, city]
);
}