fix(admin): endpoint names in selects, per_type merge, category labels, cmd datalist

- Load name+direction in botConfig() endpoint query (was missing name column)
- Show friendly endpoint names in all flow select dropdowns (was showing raw key)
- Fix per_type save: merge with existing data instead of replacing (was wiping custom flows/commands per category)
- Fix category labels: Categoría 1 = Solo reporta, 2 = Solo recibe, 3 = Reporta y recibe
- Remove incorrect "menú debe ser de tipo botón" restriction text
- Add datalist to command action inputs so admin can pick from existing menu/flow IDs

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Lizandro Guarnizo
2026-06-28 17:09:47 -05:00
co-authored by Claude Sonnet 4.6
parent 2c0ac04993
commit 1116b8ece9
2 changed files with 31 additions and 20 deletions
+8 -8
View File
@@ -477,20 +477,20 @@ $routes = [
if ($aiProvider !== '') $config['ai_provider'] = $aiProvider;
$config['ai_for_media'] = isset($_POST['ai_for_media']);
// Per-category menus
// Per-category menus — merge sobre la config existente para no perder flows/commands por categoría
$perTypeMenus = $_POST['per_type_menu'] ?? [];
$perType = [];
$perType = $config['per_type'] ?? [];
foreach ([1, 2, 3] as $cat) {
$mk = trim($perTypeMenus[$cat] ?? '');
$key = (string)$cat;
if ($mk !== '') {
$perType[(string)$cat] = [
'greeting_menu' => $mk,
'greeting' => '',
'fallback' => '',
];
$perType[$key] = array_merge($perType[$key] ?? [], ['greeting_menu' => $mk]);
} elseif (isset($perType[$key]['greeting_menu'])) {
unset($perType[$key]['greeting_menu']);
if (empty($perType[$key])) unset($perType[$key]);
}
}
if (!empty($perType)) $config['per_type'] = $perType;
$config['per_type'] = $perType;
// General
$greeting = trim($_POST['greeting'] ?? '');