diff --git a/tests/test_gateway_ui.py b/tests/test_gateway_ui.py index 5420b87..74073b2 100644 --- a/tests/test_gateway_ui.py +++ b/tests/test_gateway_ui.py @@ -317,8 +317,11 @@ def test_operator_ui_can_fix_customer_name_from_call_views(): assert "function saveLiveCallCustomerName" in app_js assert "function saveCustomerProfileName" in app_js assert "function openCustomerProfileNameEditor" in app_js + assert "function customerProfileVoiceNameContext" in app_js assert "data-customer-name-form" in app_js assert 'data-customer-action="edit-name"' in app_js + assert "customer-profile-name-meta" in app_js + assert "customer-profile-name-flash" in app_js assert "function applyCustomerNamePatchLocally" in app_js assert "function updateLiveCallNameEditorsUi" in app_js assert "function handleLiveCallTableClick" in app_js @@ -329,6 +332,9 @@ def test_operator_ui_can_fix_customer_name_from_call_views(): assert ".live-call-card-actions {" in styles_css assert ".customer-profile-name-editor {" in styles_css assert ".customer-profile-name-row {" in styles_css + assert ".customer-profile-name-meta {" in styles_css + assert ".customer-profile-name-note {" in styles_css + assert ".customer-profile-name-flash {" in styles_css def test_operator_ui_surfaces_voice_name_state_across_call_views(): @@ -349,8 +355,8 @@ def test_operator_ui_surfaces_voice_name_state_across_call_views(): assert ".micro-badge.name-confirmed {" in styles_css assert ".micro-badge.name-followup {" in styles_css assert ".micro-badge.name-missing {" in styles_css - assert "/operator/assets/styles.css?v=track22-customer-profile-name1" in index_html - assert "/operator/assets/app.js?v=track41-customer-profile-name1" in index_html + assert "/operator/assets/styles.css?v=track23-customer-profile-name-meta1" in index_html + assert "/operator/assets/app.js?v=track42-customer-profile-name-meta1" in index_html def test_operator_ui_hides_whatsapp_behind_feature_flag(): diff --git a/ui/operator/app.js b/ui/operator/app.js index 57d1e85..f26d161 100644 --- a/ui/operator/app.js +++ b/ui/operator/app.js @@ -47,6 +47,7 @@ const state = { draft: '', saving: false, error: '', + flash: '', }, }, telegram: { @@ -1074,15 +1075,40 @@ function emptyCustomerSpotlightMarkup(title, description) { `; } -function customerProfileNameEditorMarkup(customer) { +function customerProfileVoiceNameContext(liveCalls = []) { + const latestCall = latestItemByTime(liveCalls, ['last_transition_at', 'ended_at', 'connected_at', 'started_at', 'updated_at']); + if (!latestCall) { + return { + statusMeta: null, + sourceLabel: '', + }; + } + const voiceContext = voiceSummaryForItem(latestCall) || latestCall || {}; + return { + statusMeta: voiceCustomerNameStatusMeta(voiceContext?.customer_name_status), + sourceLabel: formatVoiceCustomerNameSource(voiceContext?.customer_name_source), + }; +} + +function customerProfileNameEditorMarkup(customer, context = {}) { const editor = state.customers.nameEditor; const isOpen = editor.open && editor.customerId === customer.customer_id; + const statusMeta = context.statusMeta || null; + const sourceLabel = String(context.sourceLabel || '').trim(); + const flash = editor.flash && editor.customerId === customer.customer_id ? editor.flash : ''; const statusText = editor.error || (editor.saving ? 'Сохраняем имя клиента...' : 'Имя сохранится в профиле клиента и voice-контуре.'); return `
${escapeHtml(customerLeadCompany(customer))}
+ ${(statusMeta || sourceLabel || flash) ? ` + + ` : ''}