fix: define CONFIG and ENDPOINTS in bot-config page for addFlowCard
addFlowCard() referenced CONFIG.menus, CONFIG.flows and ENDPOINTS but those variables were only defined in the conversation-tree page (a different route). On /admin/bot-config the access threw ReferenceError, aborting the function before insertAdjacentHTML ran, so no card appeared. Compute botConfigJson/botEndpointsJson from already-loaded PHP data and emit them as const CONFIG / ENDPOINTS at the top of the page's <script>. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
4c93c20482
commit
e0c873cb4c
@@ -2559,6 +2559,13 @@ CATHTML;
|
||||
$aiModel4o = $aiModelVal === 'gpt-4o' ? ' selected' : '';
|
||||
$aiModel35 = $aiModelVal === 'gpt-3.5-turbo' ? ' selected' : '';
|
||||
|
||||
// JS data for addFlowCard — needs CONFIG.menus/flows and ENDPOINTS
|
||||
$botConfigJson = json_encode(['menus' => $menus, 'flows' => $flows], JSON_UNESCAPED_UNICODE | JSON_HEX_TAG);
|
||||
$botEndpointsJson = json_encode(
|
||||
array_column($companyEndpoints, null, 'endpoint_key'),
|
||||
JSON_UNESCAPED_UNICODE | JSON_HEX_TAG
|
||||
);
|
||||
|
||||
echo <<<HTML
|
||||
<form method="POST" action="/admin/bot-config/save">
|
||||
<input type="hidden" name="company_id" value="{$cId}">
|
||||
@@ -3031,6 +3038,9 @@ HTML;
|
||||
</div>
|
||||
|
||||
<script>
|
||||
const CONFIG = {$botConfigJson};
|
||||
const ENDPOINTS = {$botEndpointsJson};
|
||||
|
||||
function switchTab(tab, btn) {
|
||||
document.querySelectorAll('.tab-content').forEach(t => t.classList.remove('active'));
|
||||
document.querySelectorAll('.tab-btn').forEach(t => t.classList.remove('active'));
|
||||
|
||||
Reference in New Issue
Block a user