TP-56443 | hotfix (#910)

* TP-56443 | hotfix

* TP-56443 | hotfix

* TP-111|Kunal|ameyo hrc recalibrate

* TP-111|Kunal|ameyo hrc recalibrate

* TP-111|Kunal|ameyo hrc recalibrate

---------

Co-authored-by: kunalsharma <kunal.sharma@navi.com>
This commit is contained in:
Varnit Goyal
2024-03-30 13:52:39 +05:30
committed by GitHub
parent 78fcd2078c
commit ca8f1048cc
5 changed files with 105 additions and 5 deletions

View File

@@ -5,5 +5,6 @@ export enum LITMUS_EXPERIMENT_NAMES {
COLLECTION_LONGHORN_THEME_ENABLE = 'collection-enable-theme',
COLLECTION_AMEYO_TELE_POLLING = 'collection-ameyo-tele-polling',
COLLECTION_AMEYO_TELE_V2 = 'collection-ameyo-tele-v2',
COLLECTION_AMEYO_TELE_V3 = 'collection-ameyo-tele-v3'
COLLECTION_AMEYO_TELE_V3 = 'collection-ameyo-tele-v3',
HRC_RECALIBRATE_ENABLE = 'hrc-recalibrate-enable'
}

View File

@@ -13,6 +13,7 @@ import store, { RootState } from 'src/store';
import {
refreshCallData,
setCampaignId,
setDisconnectApiLoading,
setIsAgentOnline,
setIsAmeyoErroneous,
setIsCallConnected,
@@ -24,14 +25,18 @@ import {
setSlackNotificationSent
} from 'src/reducers/humanReminderSlice';
import {
AMEYO_CALL_EVENTS,
AMEYO_STATUS_CODES,
AMEYO_STATUS_RANKS,
ErrorTypes
ErrorTypes,
IAmeyoRecalibratedData
} from 'src/service/naviExtension.service';
import { toast } from '@navi/web-ui/lib/primitives/Toast';
import {
getAgentStats,
getCustomerDetails,
getCustomerDetailsRecalibrate,
getCustomerImage,
sendSlackAlert,
setAgentAvailability,
setCallStatus,
@@ -42,6 +47,7 @@ import ameyoRinging from '../../assets/audio/ring.wav';
import CallWaitingScreen from './dc-97/CallWaitingScreen';
import {
resetHumanReminderCustomerDetails,
setHumanReminderCustomerDetails,
setHumanReminderCustomerDetailsLoading
} from 'src/reducers/commonSlice';
import HrCustomerDetails from './HrCustomerDetails';
@@ -51,12 +57,21 @@ import { HRC_CALL_DISCONNECT_SOURCE_TYPE } from 'src/constants/Common.constants'
import {
AGENT_AVAILABILITY,
ameyoErroneousErrorMessage,
BACKEND_AUDIT_STATUSES,
HRC_ALERTS_SLACK_CHANNEL,
HRC_API_TIMEOUT,
PreviousReminderRefId,
SLACK_NOTIFICATION_INTERVAL,
spadeCallingCampaignId
} from './dc-97/dc97Constant';
import { pushToLocalStorage } from '../../utils/StorageUtils';
import { noop } from '@utils/common';
import { resetState, setCurrentState } from '@cp/reducers/ameyoSlice';
import { AmeyoCallState } from '@cp/components/Ameyo/constants';
import isLitmusExperimentEnabled from '@cp/utils/isLitmusExperimentEnabled';
import { LITMUS_EXPERIMENT_NAMES } from '@cp/constants/litmusExperimentNames';
import { getCurrentAmeyoCallState } from '@cp/components/Ameyo/utils';
import axiosInstance, { ApiKeys, getApiUrl, logError } from '@cp/utils/ApiHelper';
const HrDashBoard = () => {
const dispatch = useDispatch();
@@ -77,7 +92,9 @@ const HrDashBoard = () => {
isSidebarSwitchDisable,
isAmeyoErroneous,
ameyoUserId,
ameyoPassword
ameyoPassword,
userReferenceId,
disconnectApiLoading
} = useSelector((state: RootState) => ({
showMainScreen: state.humanReminder.showMainScreen,
userData: state.common.userData,
@@ -91,7 +108,9 @@ const HrDashBoard = () => {
isSidebarSwitchDisable: state?.humanReminder?.isSidebarSwitchDisable,
isAmeyoErroneous: state.humanReminder.isAmeyoErronous,
ameyoUserId: state.humanReminder.ameyoManualLoginEmail,
ameyoPassword: state.humanReminder.ameyoManualLoginEmail
ameyoPassword: state.humanReminder.ameyoManualLoginEmail,
userReferenceId: state?.common?.userData?.referenceId,
disconnectApiLoading: state?.humanReminder?.disconnectApiLoading
}));
const callDisconnectSource = useRef<HRC_CALL_DISCONNECT_SOURCE_TYPE | null>(null);
@@ -127,6 +146,8 @@ const HrDashBoard = () => {
const refId = getReminderRefId();
const slackNotificationStatus = getSlackNotificationStatus();
if (refId) {
ExtensionHandler.getCurrentCallStatus();
dispatch(setHumanReminderCustomerDetailsLoading(true));
dispatch(
getCustomerDetails(refId, () => {
@@ -391,6 +412,58 @@ const HrDashBoard = () => {
isAvailable ? AGENT_AVAILABILITY.AGENT_ONLINE : AGENT_AVAILABILITY.AGENT_OFFLINE
);
};
const onSendCurrentCallStatus = async (ameyoData: IAmeyoRecalibratedData) => {
const isEnabled = await isLitmusExperimentEnabled(
LITMUS_EXPERIMENT_NAMES.HRC_RECALIBRATE_ENABLE,
{
'x-customer-id': userReferenceId
}
);
if (!isEnabled.result) {
return;
}
const customerDetails = await getCustomerDetailsRecalibrate(reminderRefId || '');
const currentBackendStatus = customerDetails?.data?.body?.status;
if (
(ameyoData?.callStatus === AMEYO_CALL_EVENTS.DISCONNECTED ||
ameyoData?.callStatus === AMEYO_CALL_EVENTS.IDLE) &&
currentBackendStatus === BACKEND_AUDIT_STATUSES.ACTIVE
) {
//call disconnect api again
dispatch(
setCallStatusDisconnected({
humanReminderReferenceId: reminderRefId || '',
agentRefId: userData?.referenceId || '',
campaignId,
cleanup: () => {
dispatch(setIsFeedbackBtnEnable(true));
dispatch(setIsCallConnected(false));
ExtensionHandler.updateIsPending(true);
handleSlackNotificationToTL();
},
phoneNumber: customerDetails?.data?.body?.customerDetails?.connectedNumber + '',
lan: customerDetails?.data?.body?.loanDetails?.loanAccountNumber,
crtObjectId: ''
})
);
} else if (
(ameyoData?.callStatus === AMEYO_CALL_EVENTS.DISCONNECTED ||
ameyoData?.callStatus === AMEYO_CALL_EVENTS.IDLE) &&
currentBackendStatus === BACKEND_AUDIT_STATUSES.DISPOSED
) {
//resetting state and go back to main screen
dispatch(resetState());
} else if (
(ameyoData?.callStatus === AMEYO_CALL_EVENTS.DISCONNECTED ||
ameyoData?.callStatus === AMEYO_CALL_EVENTS.IDLE) &&
currentBackendStatus === BACKEND_AUDIT_STATUSES.DISCONNECTED
) {
//set feedback button enabled again
dispatch(setIsFeedbackBtnEnable(true));
}
};
const onErrorCallback = (err: any) => {
// TODO : if >2 branching is there, make the following as switch case and not if else
if (err?.type === ErrorTypes.AUTH_ERROR) {
@@ -527,6 +600,11 @@ const HrDashBoard = () => {
EXTENSION_LISTENER_TYPES.ameyoReloaded,
onAmeyoReloadedCallback
);
ExtensionHelper.addExtensionListener(
EXTENSION_LISTENER_TYPES.sendCurrentCallStatusAndRecalibrate,
onSendCurrentCallStatus
);
}, []);
const onCallDisConnectedCallback = (phoneNumber: number, lan: string, crtObjectId: string) => {
@@ -545,6 +623,13 @@ const HrDashBoard = () => {
});
if (ExtensionHandler.currentCallStatus().acceptedAt) {
setTimeout(() => {
if (disconnectApiLoading) {
ExtensionHandler.getCurrentCallStatus();
} else {
return;
}
}, HRC_API_TIMEOUT);
dispatch(
setCallStatusDisconnected({
humanReminderReferenceId: reminderRefId || '',

View File

@@ -257,3 +257,8 @@ export const sendSlackAlert = (channelName: string, message: string) => {
)
.then(noop);
};
export async function getCustomerDetailsRecalibrate(humanReferenceId: string) {
const url = getApiUrl(ApiKeys.HUMAN_REMINDER_CUSTOMER_DETAILS, { humanReferenceId });
return axiosInstance.get(url, { headers: { donotHandleError: true } });
}

View File

@@ -96,4 +96,10 @@ export const HrcDisconnectTextConstants = {
DISCONNECTED: 'Disconnected'
};
export enum BACKEND_AUDIT_STATUSES {
ACTIVE = 'ACTIVE',
DISCONNECTED = 'DISCONNECTED',
DISPOSED = 'DISPOSED'
}
export const HRC_API_TIMEOUT = 3000;

View File

@@ -26,7 +26,10 @@ export const Footer = (props: FooterProps) => {
);
const [callDuration, setCallDuration] = useState(0);
const onDisableClick = () => {
if (isCallEnded || disconnectApiLoading) return;
if (isCallEnded || disconnectApiLoading) {
ExtensionHandler.getCurrentCallStatus();
return;
}
disConnectHandler();
};
const handleCallDuration = (value: number) => {