TP-51704 | Phone number Skip Tracing (#772)

* TP-51704 | Phone number Skip Tracing

* TP-51704 | Fix for retaining sources

* TP-51704 | Product UAT fixes

* TP-51704 UAT fixes done
This commit is contained in:
Shri Prakash Bajpai
2024-01-17 12:28:35 +05:30
committed by GitHub
parent c6d11866f0
commit 2f0b2ca259
3 changed files with 49 additions and 24 deletions

View File

@@ -1,5 +1,5 @@
import { Button, Typography } from '@navi/web-ui/lib/primitives';
import React, { useCallback, useMemo, useState } from 'react';
import React, { useCallback, useMemo, useState, useRef } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import { useParams, useSearchParams } from 'react-router-dom';
import CallHistory from 'src/components/CallHistory/CallHistory';
@@ -32,6 +32,13 @@ interface DefaultContactsProps {
currentCallType: ECallingType;
}
interface Telephone {
value: string;
label: string;
source: JSX.Element;
rightAdornment: JSX.Element;
}
const DefaultContacts: React.FC<DefaultContactsProps> = props => {
const { feedback, dispatchFeedback, currentCallType } = props;
const dispatch = useDispatch();
@@ -118,36 +125,50 @@ const DefaultContacts: React.FC<DefaultContactsProps> = props => {
return newTelephoneList;
}, [telephones?.data, feedback.telephoneNotRequired]);
const previousSelectedTelephone = useRef<Telephone | undefined>(telephoneList?.[0]);
const getDefaultPhoneNumber = useMemo(() => {
if (ameyoQueryParams?.phoneNumber) {
return telephoneList?.find(t => t.value === ameyoQueryParams?.phoneNumber);
}
if (feedback.telephone) {
return telephoneList?.find(t => t.value === feedback.telephone) || telephoneList?.[0];
}
return telephoneList?.[0];
const currentSelectedTelephone = previousSelectedTelephone.current
? previousSelectedTelephone.current
: telephoneList?.[0];
!feedback.telephoneNotRequired &&
dispatchFeedback({
type: FeedbackFormKind.UPDATE_TELEPHONES,
payload: { telephone: currentSelectedTelephone?.value as string }
});
return previousSelectedTelephone.current
? previousSelectedTelephone.current
: telephoneList?.[0];
}, [telephoneList, ameyoQueryParams?.phoneNumber, feedback.telephone]);
const handleTelephoneChange = useCallback((option: SelectPickerOptionProps) => {
dispatchFeedback({
type: FeedbackFormKind.UPDATE_TELEPHONES,
payload: { telephone: option.value as string }
});
addClickstreamEvent(CLICKSTREAM_EVENT_NAMES.LH_Feedback_PhoneNumberDropdown, {
phone: option?.value,
source: option?.source
});
dispatch(setIsFeedbackFormDirty(true));
}, []);
const handleTelephoneChange = useCallback(
(option: SelectPickerOptionProps) => {
if (option.value !== '') {
previousSelectedTelephone.current = telephoneList?.find(t => t.value === option.value);
}
dispatchFeedback({
type: FeedbackFormKind.UPDATE_TELEPHONES,
payload: { telephone: option.value as string }
});
addClickstreamEvent(CLICKSTREAM_EVENT_NAMES.LH_Feedback_PhoneNumberDropdown, {
phone: option?.value,
source: option?.source
});
dispatch(setIsFeedbackFormDirty(true));
},
[telephoneList]
);
const getSelectedSourceLabels = () => {
const selectedSourceLabels = telephones?.data
?.filter(t => {
return feedback.telephone?.includes(t.number as string);
})
?.map(t => t.sources);
return selectedSourceLabels?.[0]?.join(', ');
if (feedback.telephoneNotRequired) {
return '';
}
const selectedSourceLabels =
telephones?.data?.find(t => t.number === previousSelectedTelephone.current?.value)?.sources ||
telephones?.data?.[0]?.sources;
return selectedSourceLabels?.join(', ');
};
return (

View File

@@ -604,6 +604,10 @@ const FeedbackFrom = (props: FeedbackFromProps) => {
callingType: callingType.value
});
dispatch(setIsFeedbackFormDirty(true));
dispatchFeedback({
type: FeedbackFormKind.TELEPHONE_REQUIRED,
payload: { telephoneNotRequired: false }
});
}}
/>
))}