From bf7202edc9f691a87ad975695f732fb5bfcd749a Mon Sep 17 00:00:00 2001 From: Mantri Ramkishor Date: Tue, 25 Jun 2024 17:23:31 +0530 Subject: [PATCH] TP-66615 | Agent location infinite loading fix (#1019) * TP-66615 | Agent location infinte loading fix * TP-66615 | Clickstream added --- .../components/AgentsAccordion/index.tsx | 39 +++++++++++++++---- src/service/clickStream.constant.ts | 4 ++ 2 files changed, 35 insertions(+), 8 deletions(-) diff --git a/src/pages/LiveLocationTracker/components/AgentsAccordion/index.tsx b/src/pages/LiveLocationTracker/components/AgentsAccordion/index.tsx index d76ac680..1ff797f8 100644 --- a/src/pages/LiveLocationTracker/components/AgentsAccordion/index.tsx +++ b/src/pages/LiveLocationTracker/components/AgentsAccordion/index.tsx @@ -1,6 +1,6 @@ import { useEffect } from 'react'; import { Accordion } from '@navi/web-ui/lib/primitives'; -import { readQueryParams } from 'src/utils/QueryParamsHelper'; +import { createQueryParams, readQueryParams } from 'src/utils/QueryParamsHelper'; import { AGENT_LIVE_LOCATION } from '../../constants/LiveLocatonTrackerConstants'; import { useDispatch, useSelector } from 'react-redux'; import { RootState } from 'src/store'; @@ -15,7 +15,7 @@ import AccordionHeader from './AccordionHeader'; import AccordionBody from './AccordionBody'; import styles from './index.module.scss'; import { addClickstreamEvent } from 'src/service/clickStreamEventService'; -import { AgentTrackingEvents } from 'src/service/clickStream.constant'; +import { AgentTrackingEvents, CLICKSTREAM_EVENT_NAMES } from 'src/service/clickStream.constant'; import { DateFormat } from 'src/utils/DateHelper'; import cx from 'classnames'; @@ -50,17 +50,40 @@ const AgentsAccordion = () => { return; } - if (queryParams?.AGENTID !== selectedAgent?.referenceId && agentLocations) { + let selectedAgentData; + if (agentLocations) { + selectedAgentData = agentLocations?.find( + agentLocation => agentLocation?.referenceId === queryParams?.AGENTID + ); + if (!selectedAgentData) { + addClickstreamEvent(CLICKSTREAM_EVENT_NAMES.LH_MAP_VIEW_INCORRECT_DATA, { + refId: queryParams?.AGENTID + }); + const url = createQueryParams({ + [AGENT_LIVE_LOCATION]: { + ...queryParams, + AGENTID: '', + LOCATION_TYPE: '', + DATE: '', + SELECTED_FEEDBACK_ID: '', + CUSTOMER_ID: '', + CASES_FILTER: '' + } + }); + navigate(url); + return; + } + dispatch(setSelectedAgent(selectedAgentData)); + } + + if (!selectedAgentData?.referenceId) return; + + if (queryParams?.AGENTID !== selectedAgent?.referenceId) { const payload = { date: queryParams?.DATE || maxInputDate, referenceId: queryParams?.AGENTID }; dispatch(getAgentDetails(payload)); - dispatch( - setSelectedAgent( - agentLocations?.find(agentLocation => agentLocation?.referenceId === queryParams?.AGENTID) - ) - ); } }, [agentLocations, queryParams?.AGENTID]); diff --git a/src/service/clickStream.constant.ts b/src/service/clickStream.constant.ts index ce47fc5b..daf2c6f7 100644 --- a/src/service/clickStream.constant.ts +++ b/src/service/clickStream.constant.ts @@ -763,6 +763,10 @@ export const CLICKSTREAM_EVENT_NAMES = Object.freeze({ LH_TASKS_UNREAD_TOGGLE_CLICKED: { name: 'LH_TASKS_UNREAD_TOGGLE_CLICKED', description: 'Tasks unread toggle clicked' + }, + LH_MAP_VIEW_INCORRECT_DATA: { + name: 'LH_MAP_VIEW_INCORRECT_DATA', + description: 'Wrong reference id in url of map view' } });