mirror of
https://dev.azure.com/globalhealthx/EMR/_git/helix-engage
synced 2026-05-18 20:08:19 +00:00
fix: notifications use real data + agent-detail follows new id scheme
1. notification-bell: drop the DEMO_ALERTS fallback (Riya Mehta etc.).
Empty state ("No active alerts") shows when the live computation
returns nothing — which is the truthful state until thresholds are
set on Agent records.
2. use-performance-alerts: bucket calls by c.agentId === agent.id when
the relation is set; fall back to legacy agentName matching only for
un-enriched rows. Fixes conversion% calc going to 0 after backfill.
3. agent-table: Link target uses agent.id (UUID or "legacy:NAME") so
the URL is a stable identifier instead of a display string.
4. agent-detail: parse the route param into UUID vs legacy:NAME, filter
calls by c.agentId or c.agentName accordingly, and resolve display
name via the platform Agents list.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -87,20 +87,39 @@ const DirectionIcon = ({ direction, status }: { direction: CallDirection | null;
|
||||
|
||||
export const AgentDetailPage = () => {
|
||||
const { id } = useParams<{ id: string }>();
|
||||
const { calls, leads, loading } = useData();
|
||||
const { calls, leads, agents, loading } = useData();
|
||||
|
||||
const agentName = id ? decodeURIComponent(id) : '';
|
||||
// Route param is either a platform Agent UUID (new bucketing) or
|
||||
// "legacy:<rawAgentName>" for calls that haven't been enriched yet.
|
||||
// Older bookmarks may still pass the raw display name — handle that too.
|
||||
const rawId = id ? decodeURIComponent(id) : '';
|
||||
const isLegacy = rawId.startsWith('legacy:');
|
||||
const agentUuid = !isLegacy ? rawId : null;
|
||||
const legacyName = isLegacy ? rawId.slice('legacy:'.length) : null;
|
||||
|
||||
// Resolve display name: prefer Agent entity name, else the legacy string.
|
||||
const agentName = useMemo(() => {
|
||||
if (agentUuid) {
|
||||
const a = agents.find((x: any) => x.id === agentUuid);
|
||||
return a?.name ?? rawId;
|
||||
}
|
||||
return legacyName ?? '';
|
||||
}, [agentUuid, legacyName, agents, rawId]);
|
||||
|
||||
const agentCalls = useMemo(
|
||||
() =>
|
||||
calls
|
||||
.filter((c) => c.agentName === agentName)
|
||||
.filter((c) => {
|
||||
if (agentUuid) return c.agentId === agentUuid;
|
||||
if (legacyName) return !c.agentId && c.agentName === legacyName;
|
||||
return false;
|
||||
})
|
||||
.sort((a, b) => {
|
||||
const dateA = a.startedAt ? new Date(a.startedAt).getTime() : 0;
|
||||
const dateB = b.startedAt ? new Date(b.startedAt).getTime() : 0;
|
||||
return dateB - dateA;
|
||||
}),
|
||||
[calls, agentName],
|
||||
[calls, agentUuid, legacyName],
|
||||
);
|
||||
|
||||
// Build lead name map for enrichment
|
||||
|
||||
Reference in New Issue
Block a user