From 167f3f1070a1086a9e745af2c6a206ab2bd1d5eb Mon Sep 17 00:00:00 2001 From: David Vitor Antonio Date: Fri, 23 Feb 2024 16:47:54 -0300 Subject: [PATCH] fix(hitlnext): issues if agent user is deleted --- modules/hitlnext/src/helper.ts | 4 ++++ modules/hitlnext/src/views/full/app/components/Comment.tsx | 2 +- .../hitlnext/src/views/full/app/components/HandoffItem.tsx | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/modules/hitlnext/src/helper.ts b/modules/hitlnext/src/helper.ts index 264d4c1d52..a6069eec91 100644 --- a/modules/hitlnext/src/helper.ts +++ b/modules/hitlnext/src/helper.ts @@ -1,6 +1,10 @@ import { IAgent } from './types' export function agentName(agent: IAgent) { + if (!agent) { + return '-' + } + const { firstname, lastname } = agent.attributes || {} if (firstname || lastname) { diff --git a/modules/hitlnext/src/views/full/app/components/Comment.tsx b/modules/hitlnext/src/views/full/app/components/Comment.tsx index ff52619629..230d39f752 100644 --- a/modules/hitlnext/src/views/full/app/components/Comment.tsx +++ b/modules/hitlnext/src/views/full/app/components/Comment.tsx @@ -20,7 +20,7 @@ const Comment: FC = props => { if (state.currentAgent?.agentId === props.agentId) { return lang.tr('module.hitlnext.handoff.you') } else { - return agentName(agent) + return (agent && agentName(agent)) || props.agentId } } diff --git a/modules/hitlnext/src/views/full/app/components/HandoffItem.tsx b/modules/hitlnext/src/views/full/app/components/HandoffItem.tsx index c0fc77601b..cbae79b18a 100644 --- a/modules/hitlnext/src/views/full/app/components/HandoffItem.tsx +++ b/modules/hitlnext/src/views/full/app/components/HandoffItem.tsx @@ -52,7 +52,7 @@ const HandoffItem: FC = ({ createdAt, id, status, agentId, userConvers return lang.tr('module.hitlnext.handoff.you') } else if (agentId) { const agent = state.agents[agentId] - return agentName(agent) + return (agent && agentName(agent)) || agentId } } const getHandoffStyle = (createdAt, status) => {