|
|
|
|
@@ -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 || '',
|
|
|
|
|
|