TP-85043 | addresses firestore deprecation (#945)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { TouchableOpacity, View } from 'react-native';
|
||||
import React from 'react';
|
||||
import React, { useMemo } from 'react';
|
||||
import { useAppDispatch, useAppSelector } from '../../../hooks';
|
||||
import { CaseAllocationType } from '../../../screens/allCases/interface';
|
||||
import { validateInput } from '../services/validation.service';
|
||||
@@ -47,21 +47,35 @@ export const AddressSourceMap: Record<GeolocationSource, string> = {
|
||||
|
||||
const AddressSelection: React.FC<IAddressSelection> = (props) => {
|
||||
const { caseId, questionId, error, widgetId, sectionId, control, questionType } = props;
|
||||
const { currentCase, addressGeolocation, isLoading, loanAccountNumber } = useAppSelector(
|
||||
(state) => {
|
||||
const currentCase = state.allCases.caseDetails[caseId];
|
||||
const loanAccountNumber = currentCase?.loanAccountNumber;
|
||||
const addresses = state.address?.[loanAccountNumber];
|
||||
return {
|
||||
currentCase,
|
||||
loanAccountNumber,
|
||||
addressGeolocation: addresses?.addressesAndGeoLocations || {},
|
||||
isLoading: addresses?.isLoading || false,
|
||||
};
|
||||
}
|
||||
const loanAccountNumber = useAppSelector(
|
||||
(state) => state.allCases.caseDetails[caseId]?.loanAccountNumber
|
||||
);
|
||||
const addressesAndGeolocations = useAppSelector(
|
||||
(state: RootState) => state.address?.[loanAccountNumber]
|
||||
);
|
||||
const { isLoading, addressesAndGeoLocations: groupedAddressesAndGeolocations } =
|
||||
addressesAndGeolocations || {};
|
||||
const { groupedAddresses = [], geoLocations = [] } = groupedAddressesAndGeolocations || {};
|
||||
const ungroupedAddresses = useAppSelector(
|
||||
(state: RootState) => state.ungroupedAddresses[loanAccountNumber]?.ungroupedAddresses || []
|
||||
);
|
||||
|
||||
const groupedAndUngroupedAddresses = useMemo(() => {
|
||||
let addressesList = [];
|
||||
groupedAddresses.forEach((groupedAddress) => {
|
||||
if (groupedAddress?.metaAddress) {
|
||||
addressesList.push(groupedAddress.metaAddress);
|
||||
}
|
||||
if (groupedAddress?.similarAddresses?.length) {
|
||||
addressesList = [...addressesList, ...groupedAddress.similarAddresses];
|
||||
}
|
||||
});
|
||||
return [...addressesList, ...ungroupedAddresses];
|
||||
}, [groupedAddresses, ungroupedAddresses]);
|
||||
|
||||
const template = useAppSelector(
|
||||
(state) => state.case.templateData[CaseAllocationType.COLLECTION_CASE]
|
||||
);
|
||||
const caseType = currentCase?.caseType || CaseAllocationType.ADDRESS_VERIFICATION_CASE;
|
||||
const template = useAppSelector((state) => state.case.templateData[caseType]);
|
||||
const question = template?.questions?.[questionId];
|
||||
|
||||
const dispatch = useAppDispatch();
|
||||
@@ -84,8 +98,7 @@ const AddressSelection: React.FC<IAddressSelection> = (props) => {
|
||||
|
||||
const isGeolocation = question?.tag === VisitTypeSelection.GEOLOCATION_SELECTION;
|
||||
|
||||
const addresses =
|
||||
(isGeolocation ? addressGeolocation?.geoLocations : currentCase?.addresses) || [];
|
||||
const addresses = (isGeolocation ? geoLocations : groupedAndUngroupedAddresses) || [];
|
||||
|
||||
const controllerName = `widgetContext.${widgetId}.sectionContext.${sectionId}.questionContext.${questionId}`;
|
||||
|
||||
@@ -174,12 +187,8 @@ const AddressSelection: React.FC<IAddressSelection> = (props) => {
|
||||
: getAddressString(address as Address);
|
||||
return (
|
||||
<RNRadioButton
|
||||
key={
|
||||
isGeolocation ? (address as IGeolocation).id : (address as Address).referenceId
|
||||
}
|
||||
id={
|
||||
isGeolocation ? (address as IGeolocation).id : (address as Address).referenceId
|
||||
}
|
||||
key={address?.id}
|
||||
id={address?.id}
|
||||
value={addressLabel}
|
||||
customOptionTemplate={
|
||||
isGeolocation && (
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React from 'react';
|
||||
import React, { useMemo } from 'react';
|
||||
import { getAddressString, memoize } from '../../utlis/commonFunctions';
|
||||
import { useAppSelector } from '../../../hooks';
|
||||
import { VisitTypeSelection } from './AddressSelection';
|
||||
@@ -23,18 +23,35 @@ const GeolocationAddressAnswer: React.FC<IGeolocationAddressAnswer> = ({
|
||||
addressGeolocation: state.address?.[loanAccountNumber]?.addressesAndGeoLocations || {},
|
||||
isLoading: state.address?.[loanAccountNumber]?.isLoading || false,
|
||||
}));
|
||||
const { groupedAddresses = [], geoLocations = [] } = addressGeolocation || {};
|
||||
const ungroupedAddresses = useAppSelector(
|
||||
(state: RootState) => state.ungroupedAddresses[loanAccountNumber]?.ungroupedAddresses || []
|
||||
);
|
||||
|
||||
const groupedAndUngroupedAddresses = useMemo(() => {
|
||||
let addressesList = [];
|
||||
groupedAddresses.forEach((groupedAddress) => {
|
||||
if (groupedAddress?.metaAddress) {
|
||||
addressesList.push(groupedAddress.metaAddress);
|
||||
}
|
||||
if (groupedAddress?.similarAddresses?.length) {
|
||||
addressesList = [...addressesList, ...groupedAddress.similarAddresses];
|
||||
}
|
||||
});
|
||||
return [...addressesList, ...ungroupedAddresses];
|
||||
}, [groupedAddresses, ungroupedAddresses]);
|
||||
|
||||
const isGeolocation = metadata?.type === VisitTypeSelection.GEOLOCATION_SELECTION;
|
||||
|
||||
const getAddressFromId = memoize((id: string) => {
|
||||
return getAddressString(currentCase?.addresses?.find((a) => a.referenceId === id));
|
||||
return getAddressString(groupedAndUngroupedAddresses?.find((address) => address.id === id));
|
||||
});
|
||||
|
||||
if (isGeolocation) {
|
||||
const geolocations = addressGeolocation?.geoLocations;
|
||||
if (geolocations?.length) {
|
||||
const index = geolocations?.findIndex((a) => a.id === addressId);
|
||||
if (geoLocations?.length) {
|
||||
const index = geoLocations?.findIndex((a) => a.id === addressId);
|
||||
if (index !== -1) {
|
||||
const address = geolocations?.[index];
|
||||
const address = geoLocations?.[index];
|
||||
return <GeolocationAddress address={address} showOpenMap isFeedbackView />;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -201,9 +201,8 @@ export function getAddressString(address?: Address): string {
|
||||
const addressFirstLine = [address.pinCode, address.city].filter(Boolean).join(', ');
|
||||
const presentationAddressList = [
|
||||
addressFirstLine,
|
||||
address.lineOne,
|
||||
address.lineTwo,
|
||||
toTileCase(address.source),
|
||||
address.addressText,
|
||||
toTileCase(address.primarySource),
|
||||
];
|
||||
return presentationAddressList.filter(Boolean).join(' \n ');
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ import {
|
||||
IAddAddressPayload,
|
||||
IAddressGeolocationPayload,
|
||||
} from '../../types/addressGeolocation.types';
|
||||
import { addAddress, getPinCodeDetails } from '../../action/addressGeolocationAction';
|
||||
import { addAddress, getPinCodeDetails, getUngroupedAddress } from '../../action/addressGeolocationAction';
|
||||
import { useSelector } from 'react-redux';
|
||||
import { RootState } from '../../store/store';
|
||||
import { addClickstreamEvent } from '../../services/clickstreamEventService';
|
||||
@@ -29,6 +29,7 @@ import {
|
||||
verifyPinCodeForNewAddressContainer
|
||||
} from "@screens/addressGeolocation/utils/utils";
|
||||
import LoadingIcon from "@rn-ui-lib/icons/LoadingIcon";
|
||||
import { getCaseUnifiedData, UnifiedCaseDetailsTypes } from '@actions/caseApiActions';
|
||||
|
||||
const PAGE_TITLE = 'Add new address';
|
||||
|
||||
@@ -149,6 +150,8 @@ const NewAddressContainer: React.FC<INewAddressContainer> = ({ route: routeParam
|
||||
type: 'info',
|
||||
text1: 'Address Added Successfully!',
|
||||
});
|
||||
dispatch(getCaseUnifiedData([loanAccountNumber], [UnifiedCaseDetailsTypes.ADDRESS_AND_GEOLOCATIONS]));
|
||||
dispatch(getUngroupedAddress(loanAccountNumber));
|
||||
navigateToScreen(CaseDetailStackEnum.COLLECTION_CASE_DETAIL, { caseId });
|
||||
addClickstreamEvent(CLICKSTREAM_EVENT_NAMES.FA_ADD_NEW_ADDRESS_SUBMIT_SUCCESS, {
|
||||
loanAccountNumber,
|
||||
|
||||
@@ -24,6 +24,7 @@ import { syncActiveCallDetails } from '@actions/callRecordingActions';
|
||||
import { getCustomerDocuments } from '@screens/allCases/utils';
|
||||
import { logError } from '@components/utlis/errorUtils';
|
||||
import { GenericObject, GenericType } from '@common/GenericTypes';
|
||||
import { getUngroupedAddress } from '@actions/addressGeolocationAction';
|
||||
|
||||
interface ICaseDetails {
|
||||
route: {
|
||||
@@ -41,7 +42,9 @@ const CollectionCaseDetails: React.FC<ICaseDetails> = (props) => {
|
||||
},
|
||||
} = props;
|
||||
const caseDetail = useAppSelector((state: RootState) => state.allCases.caseDetails[caseId]) || {};
|
||||
const isCallActive = useAppSelector((state: RootState) => state?.activeCall?.activeCallDetails?.callActive);
|
||||
const isCallActive = useAppSelector(
|
||||
(state: RootState) => state?.activeCall?.activeCallDetails?.callActive
|
||||
);
|
||||
|
||||
const { loanAccountNumber } = caseDetail;
|
||||
const opacityAnimation = useRef(new Animated.Value(0.8)).current;
|
||||
@@ -72,6 +75,7 @@ const CollectionCaseDetails: React.FC<ICaseDetails> = (props) => {
|
||||
[UnifiedCaseDetailsTypes.FEEDBACKS, UnifiedCaseDetailsTypes.ADDRESS_AND_GEOLOCATIONS]
|
||||
)
|
||||
);
|
||||
dispatch(getUngroupedAddress(loanAccountNumber));
|
||||
}
|
||||
}, [caseDetail]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user