NTP-12177 | Seggregation of Unified API
This commit is contained in:
@@ -7,7 +7,6 @@ import axiosInstance, { ApiKeys, API_STATUS_CODE, getApiUrl } from '../component
|
||||
import { AppDispatch } from '../store/store';
|
||||
import { logError } from '../components/utlis/errorUtils';
|
||||
import { IAddAddressPayload, IAddressGeolocationPayload } from '../types/addressGeolocation.types';
|
||||
import { UnifiedCaseDetailsTypes } from './caseApiActions';
|
||||
import { addClickstreamEvent } from '@services/clickstreamEventService';
|
||||
import { CLICKSTREAM_EVENT_NAMES } from '@common/Constants';
|
||||
import {
|
||||
@@ -63,37 +62,32 @@ export const addAddress =
|
||||
});
|
||||
};
|
||||
|
||||
export const getUngroupedAddress = (loanAccountNumber: string) => (dispatch: AppDispatch) => {
|
||||
const queryParams = {
|
||||
[UnifiedCaseDetailsTypes.UNGROUPED_ADDRESSES]: true,
|
||||
[UnifiedCaseDetailsTypes.INCLUDE_ADDRESS_FEEDBACK]: true,
|
||||
export const getUngroupedAddress =
|
||||
(loanAccountNumber: string, includeFeedbacks = false) =>
|
||||
(dispatch: AppDispatch) => {
|
||||
dispatch(setUngroupedAddressesLoading({ loanAccountNumber, isLoading: true }));
|
||||
const url = getApiUrl(
|
||||
ApiKeys.GET_UNGROUPED_ADDRESSES,
|
||||
{ loanAccountNumber },
|
||||
{ includeFeedbacks }
|
||||
);
|
||||
axiosInstance
|
||||
.get(url)
|
||||
.then((response) => {
|
||||
if (response.status === API_STATUS_CODE.OK) {
|
||||
const ungroupedAddressesWithFeedbacks = {
|
||||
ungroupedAddresses: response?.data?.ungroupedAddresses || [],
|
||||
ungroupedAddressFeedbacks: response?.data?.addressFeedbacks || [],
|
||||
loanAccountNumber,
|
||||
};
|
||||
dispatch(setUngroupedAddresses(ungroupedAddressesWithFeedbacks));
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
logError(err);
|
||||
dispatch(setUngroupedAddressesLoading({ loanAccountNumber, isLoading: false }));
|
||||
});
|
||||
};
|
||||
addClickstreamEvent(CLICKSTREAM_EVENT_NAMES.FA_UNIFIED_ENTITY_REQUESTED, {
|
||||
lan: loanAccountNumber || '',
|
||||
requestedEntities: JSON.stringify([
|
||||
UnifiedCaseDetailsTypes.UNGROUPED_ADDRESSES,
|
||||
UnifiedCaseDetailsTypes.INCLUDE_ADDRESS_FEEDBACK,
|
||||
]),
|
||||
});
|
||||
dispatch(setUngroupedAddressesLoading({ loanAccountNumber, isLoading: true }));
|
||||
const url = getApiUrl(ApiKeys.CASE_UNIFIED_DETAILS_V4, { loanAccountNumber }, queryParams);
|
||||
axiosInstance
|
||||
.get(url)
|
||||
.then((response) => {
|
||||
if (response.status === API_STATUS_CODE.OK) {
|
||||
const ungroupedAddressesWithFeedbacks = {
|
||||
ungroupedAddresses: response?.data?.ungroupedAddresses || [],
|
||||
ungroupedAddressFeedbacks: response?.data?.addressFeedbacks || [],
|
||||
loanAccountNumber,
|
||||
};
|
||||
dispatch(setUngroupedAddresses(ungroupedAddressesWithFeedbacks));
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
logError(err);
|
||||
dispatch(setUngroupedAddressesLoading({ loanAccountNumber, isLoading: false }));
|
||||
});
|
||||
};
|
||||
|
||||
export const getSimilarGeolocationTimestamps = (clusterId: string) => {
|
||||
const url = getApiUrl(ApiKeys.SIMILAR_GEOLOCATION_TIMESTAMPS, { clusterId });
|
||||
|
||||
@@ -1,162 +1,99 @@
|
||||
import { type AxiosResponse } from 'axios';
|
||||
import axiosInstance, { ApiKeys, getApiUrl } from '../components/utlis/apiHelper';
|
||||
import { type AppDispatch } from '../store/store';
|
||||
import { type IGroupedGeolocationAddressItem } from '../types/addressGeolocation.types';
|
||||
import { setEmiSchedule, setEmiScheduleLoading } from '../reducer/emiScheduleSlice';
|
||||
import { setFeedbackHistory, setFeedbackHistoryLoading } from '../reducer/feedbackHistorySlice';
|
||||
import { setRepayments, setRepaymentsLoading } from '../reducer/repaymentsSlice';
|
||||
import { IAddressFeedback, setAddresses, setAddressLoading } from '../reducer/addressSlice';
|
||||
import { type IFeedback } from '../types/feedback.types';
|
||||
import { allSettled } from '../components/utlis/commonFunctions';
|
||||
import { type GenericType } from '../common/GenericTypes';
|
||||
import { addClickstreamEvent } from '../services/clickstreamEventService';
|
||||
import { CLICKSTREAM_EVENT_NAMES } from '../common/Constants';
|
||||
import { setAddresses, setAddressLoading } from '../reducer/addressSlice';
|
||||
import { MILLISECONDS_IN_A_MINUTE, _map } from '../../RN-UI-LIB/src/utlis/common';
|
||||
import { logError } from '../components/utlis/errorUtils';
|
||||
import { type IDocument, removeDocumentByQuestionKey } from '../reducer/feedbackImagesSlice';
|
||||
import { CaseDetailStackEnum } from '@screens/caseDetails/CaseDetailStack';
|
||||
|
||||
// TODO: Need to add respective interfaces instead of any
|
||||
interface IUnifiedData {
|
||||
groupedAddressesAndGeoLocations?: IGroupedGeolocationAddressItem;
|
||||
feedbacks: any[];
|
||||
emiSchedule: any[];
|
||||
repayments: any[];
|
||||
addressFeedbacks?: IAddressFeedback[];
|
||||
}
|
||||
|
||||
export interface IUploadImagePayload {
|
||||
interactionId: string;
|
||||
questionKey: string;
|
||||
originalImageDocumentReferenceId: string;
|
||||
}
|
||||
|
||||
export enum UnifiedCaseDetailsTypes {
|
||||
ADDRESS_AND_GEOLOCATIONS = 'includeGroupedAddressesAndGeoLocations',
|
||||
FEEDBACKS = 'includeFeedbacks',
|
||||
EMI_SCHEDULE = 'includeEmiSchedule',
|
||||
REPAYMENTS = 'includeRepayments',
|
||||
INCLUDE_ADDRESS_FEEDBACK = 'includeAddressFeedback',
|
||||
UNGROUPED_ADDRESSES = 'includeUngroupedAddresses',
|
||||
}
|
||||
|
||||
export const initialUrlParams = {
|
||||
[UnifiedCaseDetailsTypes.ADDRESS_AND_GEOLOCATIONS]: false,
|
||||
[UnifiedCaseDetailsTypes.FEEDBACKS]: false,
|
||||
[UnifiedCaseDetailsTypes.EMI_SCHEDULE]: false,
|
||||
[UnifiedCaseDetailsTypes.REPAYMENTS]: false,
|
||||
[UnifiedCaseDetailsTypes.INCLUDE_ADDRESS_FEEDBACK]: false,
|
||||
[UnifiedCaseDetailsTypes.UNGROUPED_ADDRESSES]: false,
|
||||
export const getRepaymentsData = (loanAccountNumber: string) => (dispatch: AppDispatch) => {
|
||||
dispatch(setRepaymentsLoading({ loanAccountNumber, isLoading: true }));
|
||||
const url = getApiUrl(ApiKeys.GET_REPAYMENTS, { loanAccountNumber });
|
||||
axiosInstance
|
||||
.get(url)
|
||||
.then((res) => {
|
||||
dispatch(setRepayments({ loanAccountNumber, repayments: res.data }));
|
||||
})
|
||||
.catch((err) => {
|
||||
logError(err as Error, 'Error fetching repayments data');
|
||||
})
|
||||
.finally(() => {
|
||||
dispatch(setRepaymentsLoading({ loanAccountNumber, isLoading: false }));
|
||||
});
|
||||
};
|
||||
|
||||
const setUnifiedDataLoading =
|
||||
(queryParams: Record<UnifiedCaseDetailsTypes, boolean>, loanAccountNumbers: string[], isLoading: boolean) =>
|
||||
(dispatch: AppDispatch) => {
|
||||
if (queryParams[UnifiedCaseDetailsTypes.EMI_SCHEDULE]) {
|
||||
dispatch(setEmiScheduleLoading({ loanAccountNumbers, isLoading: isLoading }));
|
||||
}
|
||||
if (queryParams[UnifiedCaseDetailsTypes.FEEDBACKS]) {
|
||||
dispatch(setFeedbackHistoryLoading({ loanAccountNumbers, isLoading: isLoading }));
|
||||
}
|
||||
if (queryParams[UnifiedCaseDetailsTypes.REPAYMENTS]) {
|
||||
dispatch(setRepaymentsLoading({ loanAccountNumbers, isLoading: isLoading }));
|
||||
}
|
||||
if (queryParams[UnifiedCaseDetailsTypes.ADDRESS_AND_GEOLOCATIONS]) {
|
||||
dispatch(setAddressLoading({ loanAccountNumbers, isLoading: isLoading }));
|
||||
}
|
||||
};
|
||||
export const getEmiScheduleData = (loanAccountNumber: string) => (dispatch: AppDispatch) => {
|
||||
dispatch(setEmiScheduleLoading({ loanAccountNumber, isLoading: true }));
|
||||
const url = getApiUrl(ApiKeys.GET_EMI_SCHEDULE, { loanAccountNumber });
|
||||
axiosInstance
|
||||
.get(url)
|
||||
.then((res) => {
|
||||
dispatch(setEmiSchedule({ loanAccountNumber, emiSchedule: res.data }));
|
||||
})
|
||||
.catch((err) => {
|
||||
logError(err as Error, 'Error fetching emi schedule data');
|
||||
})
|
||||
.finally(() => {
|
||||
dispatch(setEmiScheduleLoading({ loanAccountNumber, isLoading: false }));
|
||||
});
|
||||
};
|
||||
|
||||
const setUnifiedData =
|
||||
(
|
||||
queryParams: Record<UnifiedCaseDetailsTypes, boolean>,
|
||||
loanAccountNumbers: string[],
|
||||
unifiedPromiseData: Array<PromiseSettledResult<AxiosResponse<IUnifiedData>>>
|
||||
) =>
|
||||
export const getAddressesAndGeolocations =
|
||||
(loanAccountNumber: string, includeFeedbacks: boolean = false) =>
|
||||
(dispatch: AppDispatch) => {
|
||||
unifiedPromiseData.forEach((promiseResult, index) => {
|
||||
const { status } = promiseResult;
|
||||
if (status === 'fulfilled' && promiseResult.value) {
|
||||
const {
|
||||
groupedAddressesAndGeoLocations,
|
||||
feedbacks,
|
||||
emiSchedule,
|
||||
repayments,
|
||||
addressFeedbacks,
|
||||
} = promiseResult.value.data;
|
||||
const loanAccountNumber = loanAccountNumbers[index];
|
||||
if (queryParams[UnifiedCaseDetailsTypes.EMI_SCHEDULE]) {
|
||||
dispatch(setEmiSchedule({ loanAccountNumber, emiSchedule }));
|
||||
}
|
||||
if (queryParams[UnifiedCaseDetailsTypes.FEEDBACKS]) {
|
||||
// todo: data is coming as feedback.data
|
||||
dispatch(
|
||||
setFeedbackHistory({
|
||||
loanAccountNumber,
|
||||
feedbacks: feedbacks?.data as IFeedback[],
|
||||
totalPages: feedbacks?.pages?.totalPages as number,
|
||||
})
|
||||
);
|
||||
}
|
||||
if (queryParams[UnifiedCaseDetailsTypes.REPAYMENTS]) {
|
||||
dispatch(setRepayments({ loanAccountNumber, repayments }));
|
||||
}
|
||||
if (queryParams[UnifiedCaseDetailsTypes.ADDRESS_AND_GEOLOCATIONS]) {
|
||||
dispatch(setAddresses({ loanAccountNumber, groupedAddressesAndGeoLocations }));
|
||||
}
|
||||
if (queryParams[UnifiedCaseDetailsTypes.INCLUDE_ADDRESS_FEEDBACK]) {
|
||||
dispatch(
|
||||
setAddresses({ loanAccountNumber, addressFeedbacks, groupedAddressesAndGeoLocations })
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const getCaseUnifiedData =
|
||||
(loanAccountNumbers: string[], infoToGet: UnifiedCaseDetailsTypes[]) =>
|
||||
(dispatch: AppDispatch) => {
|
||||
const queryParams = { ...initialUrlParams };
|
||||
for (const key of infoToGet) {
|
||||
queryParams[key] = true;
|
||||
}
|
||||
addClickstreamEvent(CLICKSTREAM_EVENT_NAMES.FA_UNIFIED_ENTITY_REQUESTED, {
|
||||
lans: JSON.stringify(loanAccountNumbers || []),
|
||||
requestedEntities: JSON.stringify(infoToGet || []),
|
||||
});
|
||||
dispatch(setUnifiedDataLoading(queryParams, loanAccountNumbers, true));
|
||||
const promisesList: Array<Promise<AxiosResponse<any, any>>> = [];
|
||||
loanAccountNumbers.forEach((loanAccountNumber) => {
|
||||
const url = getApiUrl(ApiKeys.CASE_UNIFIED_DETAILS_V4, { loanAccountNumber }, queryParams);
|
||||
const promise = axiosInstance.get(url, {
|
||||
headers: {
|
||||
showInSpecificComponents: [
|
||||
CaseDetailStackEnum.COLLECTION_CASE_DETAIL,
|
||||
CaseDetailStackEnum.EMI_SCHEDULE,
|
||||
CaseDetailStackEnum.ADDRESS_GEO,
|
||||
],
|
||||
},
|
||||
});
|
||||
promisesList.push(promise);
|
||||
});
|
||||
allSettled?.(promisesList)
|
||||
.then((res: GenericType) => {
|
||||
addClickstreamEvent(CLICKSTREAM_EVENT_NAMES.FA_UNIFIED_ENTITY_REQUEST_SUCCESS, {
|
||||
lans: JSON.stringify(loanAccountNumbers || []),
|
||||
requestedEntities: JSON.stringify(infoToGet || []),
|
||||
});
|
||||
dispatch(setUnifiedData(queryParams, loanAccountNumbers, res));
|
||||
dispatch(setAddressLoading({ loanAccountNumber, isLoading: true }));
|
||||
const url = getApiUrl(
|
||||
ApiKeys.GET_GROUPED_ADDRESSES_AND_GEOLOCATIONS,
|
||||
{ loanAccountNumber },
|
||||
{ includeFeedbacks }
|
||||
);
|
||||
axiosInstance
|
||||
.get(url)
|
||||
.then((res) => {
|
||||
dispatch(setAddresses({ loanAccountNumber, groupedAddressesAndGeoLocations: res.data }));
|
||||
})
|
||||
.catch((e) => {
|
||||
addClickstreamEvent(CLICKSTREAM_EVENT_NAMES.FA_UNIFIED_ENTITY_REQUEST_FAILED, {
|
||||
lans: JSON.stringify(loanAccountNumbers || []),
|
||||
requestedEntities: JSON.stringify(infoToGet || []),
|
||||
});
|
||||
.catch((err) => {
|
||||
logError(err as Error, 'Error fetching addresses and geolocations data');
|
||||
})
|
||||
.finally(() => {
|
||||
dispatch(setUnifiedDataLoading(queryParams, loanAccountNumbers, false));
|
||||
dispatch(setAddressLoading({ loanAccountNumber, isLoading: false }));
|
||||
});
|
||||
};
|
||||
|
||||
export const getFeedbackHistory = (loanAccountNumber: string) => (dispatch: AppDispatch) => {
|
||||
dispatch(setFeedbackHistoryLoading({ loanAccountNumber, isLoading: true }));
|
||||
const url = getApiUrl(
|
||||
ApiKeys.GET_FEEDBACK_HISTORY,
|
||||
{},
|
||||
{
|
||||
loan_account_number: loanAccountNumber,
|
||||
page_no: 0,
|
||||
page_size: 5,
|
||||
}
|
||||
);
|
||||
axiosInstance
|
||||
.post(url, {
|
||||
filters: [],
|
||||
})
|
||||
.then((res) => {
|
||||
dispatch(
|
||||
setFeedbackHistory({
|
||||
loanAccountNumber,
|
||||
feedbacks: res.data?.data || [],
|
||||
totalPages: res.data?.pages?.totalPages || 0,
|
||||
})
|
||||
);
|
||||
})
|
||||
.catch((err) => {
|
||||
logError(err as Error, 'Error fetching feedback history data');
|
||||
})
|
||||
.finally(() => {
|
||||
dispatch(setFeedbackHistoryLoading({ loanAccountNumber, isLoading: false }));
|
||||
});
|
||||
};
|
||||
|
||||
export const uploadImages =
|
||||
(caseKey: string, documents: Record<string, IDocument>, interactionReferenceId: string) =>
|
||||
(dispatch: AppDispatch) => {
|
||||
|
||||
@@ -18,7 +18,7 @@ import { RootState } from '@store';
|
||||
import NoLocationsIcon from '@rn-ui-lib/icons/NoLocationIcon';
|
||||
import Text from '@rn-ui-lib/components/Text';
|
||||
import LineLoader from '@rn-ui-lib/components/suspense_loader/LineLoader';
|
||||
import { UnifiedCaseDetailsTypes, getCaseUnifiedData } from '@actions/caseApiActions';
|
||||
import { getAddressesAndGeolocations } from '@actions/caseApiActions';
|
||||
import LoadingIcon from '@rn-ui-lib/icons/LoadingIcon';
|
||||
import { COLORS } from '@rn-ui-lib/colors';
|
||||
|
||||
@@ -103,9 +103,7 @@ const AddressSelection: React.FC<IAddressSelection> = (props) => {
|
||||
const controllerName = `widgetContext.${widgetId}.sectionContext.${sectionId}.questionContext.${questionId}`;
|
||||
|
||||
const reloadGeolocations = () => {
|
||||
dispatch(
|
||||
getCaseUnifiedData([loanAccountNumber], [UnifiedCaseDetailsTypes.ADDRESS_AND_GEOLOCATIONS])
|
||||
);
|
||||
dispatch(getAddressesAndGeolocations(loanAccountNumber));
|
||||
};
|
||||
|
||||
if (isGeolocation) {
|
||||
|
||||
@@ -106,6 +106,11 @@ export enum ApiKeys {
|
||||
GET_SIGNED_URL_V2 = 'GET_SIGNED_URL_V2',
|
||||
GET_SIGNED_URL_FOR_REPORTEE_V2 = 'GET_SIGNED_URL_FOR_REPORTEE_V2',
|
||||
ALL_ESCALATIONS = 'ALL_ESCALATIONS',
|
||||
GET_UNGROUPED_ADDRESSES = 'GET_UNGROUPED_ADDRESSES',
|
||||
GET_GROUPED_ADDRESSES_AND_GEOLOCATIONS = 'GET_GROUPED_ADDRESSES',
|
||||
GET_EMI_SCHEDULE = 'GET_EMI_SCHEDULE',
|
||||
GET_REPAYMENTS = 'GET_REPAYMENTS',
|
||||
GET_FEEDBACK_HISTORY = 'GET_FEEDBACK_HISTORY',
|
||||
}
|
||||
|
||||
export const API_URLS: Record<ApiKeys, string> = {} as Record<ApiKeys, string>;
|
||||
@@ -203,6 +208,13 @@ API_URLS[ApiKeys.SEND_COMMUNICATION_NAVI_ACCOUNT] = '/navi-communications/{loanA
|
||||
API_URLS[ApiKeys.GENERATE_DYNAMIC_DOCUMENT] = '/documents/generate/{loanAccountNumber}';
|
||||
API_URLS[ApiKeys.ALL_ESCALATIONS] = '/customer-escalation';
|
||||
API_URLS[ApiKeys.DOWNLOAD_LATEST_APP] = 'https://longhorn.navi.com/api/app/download';
|
||||
API_URLS[ApiKeys.GET_UNGROUPED_ADDRESSES] =
|
||||
'/collection-cases/{loanAccountNumber}/ungrouped/addresses';
|
||||
API_URLS[ApiKeys.GET_GROUPED_ADDRESSES_AND_GEOLOCATIONS] =
|
||||
'/collection-cases/{loanAccountNumber}/grouped/addresses-geo-locations';
|
||||
API_URLS[ApiKeys.GET_EMI_SCHEDULE] = '/collection-cases/{loanAccountNumber}/emiSchedule';
|
||||
API_URLS[ApiKeys.GET_REPAYMENTS] = '/collection-cases/{loanAccountNumber}/repayments';
|
||||
API_URLS[ApiKeys.GET_FEEDBACK_HISTORY] = '/feedback/filters';
|
||||
|
||||
export const API_STATUS_CODE = {
|
||||
OK: 200,
|
||||
@@ -262,7 +274,7 @@ axiosInstance.interceptors.request.use((request) => {
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
request.retry = request?.retry < 4 ? request.retry : 3;
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
request.delay = request?.delay > 2000 ? request.delay : 2000;
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
|
||||
@@ -26,7 +26,8 @@ const AddressSlice = createSlice({
|
||||
initialState,
|
||||
reducers: {
|
||||
setAddresses: (state, action) => {
|
||||
const { loanAccountNumber, groupedAddressesAndGeoLocations, addressFeedbacks } = action.payload;
|
||||
const { loanAccountNumber, groupedAddressesAndGeoLocations, addressFeedbacks } =
|
||||
action.payload;
|
||||
state[loanAccountNumber] = {
|
||||
addressesAndGeoLocations: groupedAddressesAndGeoLocations || [],
|
||||
addressFeedbacks: addressFeedbacks || [],
|
||||
@@ -36,15 +37,13 @@ const AddressSlice = createSlice({
|
||||
},
|
||||
setAddressLoading: (
|
||||
state,
|
||||
action: PayloadAction<{ loanAccountNumbers: string[]; isLoading: boolean }>
|
||||
action: PayloadAction<{ loanAccountNumber: string; isLoading: boolean }>
|
||||
) => {
|
||||
const payloadData = action.payload;
|
||||
payloadData.loanAccountNumbers.forEach((loanAccNumber) => {
|
||||
state[loanAccNumber] = {
|
||||
...(state?.[loanAccNumber] || {}),
|
||||
isLoading: payloadData.isLoading,
|
||||
};
|
||||
});
|
||||
state[payloadData.loanAccountNumber] = {
|
||||
...(state[payloadData.loanAccountNumber] || {}),
|
||||
isLoading: payloadData.isLoading,
|
||||
};
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -23,15 +23,13 @@ const EmiScheduleSlice = createSlice({
|
||||
},
|
||||
setEmiScheduleLoading: (
|
||||
state,
|
||||
action: PayloadAction<{ loanAccountNumbers: string[]; isLoading: boolean }>
|
||||
action: PayloadAction<{ loanAccountNumber: string; isLoading: boolean }>
|
||||
) => {
|
||||
const payloadData = action.payload;
|
||||
payloadData.loanAccountNumbers.forEach((loanAccNumber) => {
|
||||
state[loanAccNumber] = {
|
||||
...(state?.[loanAccNumber] || []),
|
||||
isLoading: payloadData.isLoading,
|
||||
};
|
||||
});
|
||||
state[payloadData.loanAccountNumber] = {
|
||||
...(state?.[payloadData.loanAccountNumber] || {}),
|
||||
isLoading: payloadData.isLoading,
|
||||
};
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -29,15 +29,13 @@ const FeedbackHistorySlice = createSlice({
|
||||
},
|
||||
setFeedbackHistoryLoading: (
|
||||
state,
|
||||
action: PayloadAction<{ loanAccountNumbers: string[]; isLoading: boolean }>
|
||||
action: PayloadAction<{ loanAccountNumber: string; isLoading: boolean }>
|
||||
) => {
|
||||
const payloadData = action.payload;
|
||||
payloadData.loanAccountNumbers.forEach((loanAccNumber) => {
|
||||
state[loanAccNumber] = {
|
||||
...(state?.[loanAccNumber] || {}),
|
||||
isLoading: payloadData.isLoading,
|
||||
};
|
||||
});
|
||||
state[payloadData.loanAccountNumber] = {
|
||||
...(state[payloadData.loanAccountNumber] || {}),
|
||||
isLoading: payloadData.isLoading,
|
||||
};
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -2,7 +2,6 @@ import { createSlice, PayloadAction } from '@reduxjs/toolkit';
|
||||
import { IRepaymentsRecord } from '../types/repayments.types';
|
||||
|
||||
interface IRepaymentsState {
|
||||
//TODO: update interface of Repayments instead of any
|
||||
[loanAccountNumber: string]: { data: IRepaymentsRecord[]; isLoading: boolean; timestamp: string };
|
||||
}
|
||||
|
||||
@@ -22,15 +21,13 @@ const RepaymentsSlice = createSlice({
|
||||
},
|
||||
setRepaymentsLoading: (
|
||||
state,
|
||||
action: PayloadAction<{ loanAccountNumbers: string[]; isLoading: boolean }>
|
||||
action: PayloadAction<{ loanAccountNumber: string; isLoading: boolean }>
|
||||
) => {
|
||||
const payloadData = action.payload;
|
||||
payloadData.loanAccountNumbers.forEach((loanAccNumber) => {
|
||||
state[loanAccNumber] = {
|
||||
...(state?.[loanAccNumber] || []),
|
||||
isLoading: payloadData.isLoading,
|
||||
};
|
||||
});
|
||||
state[payloadData.loanAccountNumber] = {
|
||||
...(state?.[payloadData.loanAccountNumber] || {}),
|
||||
isLoading: payloadData.isLoading,
|
||||
};
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -14,7 +14,7 @@ import {
|
||||
IAddAddressPayload,
|
||||
IAddressGeolocationPayload,
|
||||
} from '../../types/addressGeolocation.types';
|
||||
import { addAddress, getPinCodeDetails, getUngroupedAddress } from '../../action/addressGeolocationAction';
|
||||
import { addAddress, getPinCodeDetails } from '../../action/addressGeolocationAction';
|
||||
import { useSelector } from 'react-redux';
|
||||
import { RootState } from '../../store/store';
|
||||
import { addClickstreamEvent } from '../../services/clickstreamEventService';
|
||||
@@ -29,7 +29,6 @@ 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';
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ const UngroupedAddressContainer: React.FC<IUngroupedAddress> = ({ route: routePa
|
||||
|
||||
const fetchUngroupedAddress = () => {
|
||||
// fetch ungrouped address
|
||||
dispatch(getUngroupedAddress(loanAccountNumber));
|
||||
dispatch(getUngroupedAddress(loanAccountNumber, true));
|
||||
};
|
||||
|
||||
if (!isOnline) {
|
||||
|
||||
@@ -19,11 +19,10 @@ import Button from '../../../RN-UI-LIB/src/components/Button';
|
||||
import PlusIcon from '../../../RN-UI-LIB/src/Icons/PlusIcon';
|
||||
import useIsOnline from '../../hooks/useIsOnline';
|
||||
import OfflineScreen from '../../common/OfflineScreen';
|
||||
import { getCaseUnifiedData, UnifiedCaseDetailsTypes } from '../../action/caseApiActions';
|
||||
import { getAddressesAndGeolocations } from '../../action/caseApiActions';
|
||||
import { CLICKSTREAM_EVENT_NAMES, HIT_SLOP } from '../../common/Constants';
|
||||
import { addClickstreamEvent } from '../../services/clickstreamEventService';
|
||||
import HomeIconSmall from '../../assets/icons/HomeIconSmall';
|
||||
import { setAddressLoading } from '../../reducer/addressSlice';
|
||||
import SuspenseLoader from '../../../RN-UI-LIB/src/components/suspense_loader/SuspenseLoader';
|
||||
import LineLoader from '../../../RN-UI-LIB/src/components/suspense_loader/LineLoader';
|
||||
import Layout from '../layout/Layout';
|
||||
@@ -72,16 +71,7 @@ const AddressGeolocation: React.FC<IAddressGeolocation> = ({ route: routeParams
|
||||
};
|
||||
|
||||
const getGroupedAddresses = () => {
|
||||
dispatch(setAddressLoading({ loanAccountNumbers: [loanAccountNumber], isLoading: true }));
|
||||
dispatch(
|
||||
getCaseUnifiedData(
|
||||
[loanAccountNumber],
|
||||
[
|
||||
UnifiedCaseDetailsTypes.ADDRESS_AND_GEOLOCATIONS,
|
||||
UnifiedCaseDetailsTypes.INCLUDE_ADDRESS_FEEDBACK,
|
||||
]
|
||||
)
|
||||
);
|
||||
dispatch(getAddressesAndGeolocations(loanAccountNumber, true));
|
||||
dispatch(sendCurrentGeolocationAndBuffer(AppState.currentState));
|
||||
};
|
||||
|
||||
@@ -93,7 +83,7 @@ const AddressGeolocation: React.FC<IAddressGeolocation> = ({ route: routeParams
|
||||
|
||||
useEffect(() => {
|
||||
addClickstreamEvent(CLICKSTREAM_EVENT_NAMES.FA_ALL_ADDRESSES_LANDED, commonParams);
|
||||
dispatch(getUngroupedAddress(loanAccountNumber));
|
||||
dispatch(getUngroupedAddress(loanAccountNumber, true));
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
@@ -7,7 +7,7 @@ import UserDetailsSection from './UserDetailsSection';
|
||||
import Layout from '../layout/Layout';
|
||||
import { _map } from '../../../RN-UI-LIB/src/utlis/common';
|
||||
import { RootState } from '../../store/store';
|
||||
import { getCaseUnifiedData, UnifiedCaseDetailsTypes } from '../../action/caseApiActions';
|
||||
import { getAddressesAndGeolocations, getFeedbackHistory } from '../../action/caseApiActions';
|
||||
import { CLICKSTREAM_EVENT_NAMES } from '../../common/Constants';
|
||||
import { addClickstreamEvent } from '../../services/clickstreamEventService';
|
||||
import ScreenshotBlocker from '../../components/utlis/ScreenshotBlocker';
|
||||
@@ -52,7 +52,7 @@ const CollectionCaseDetails: React.FC<ICaseDetails> = (props) => {
|
||||
|
||||
const [isDocumentsLoading, setIsDocumentsLoading] = React.useState(false);
|
||||
|
||||
const {escalationData} = caseDetail || {};
|
||||
const { escalationData } = caseDetail || {};
|
||||
const activeEscalationCount = Number(escalationData?.activeEscalationCount);
|
||||
const pastEscalationCount = Number(escalationData?.pastEscalationCount);
|
||||
const totalEscalationsCount = activeEscalationCount + pastEscalationCount;
|
||||
@@ -67,13 +67,9 @@ const CollectionCaseDetails: React.FC<ICaseDetails> = (props) => {
|
||||
|
||||
useFocusEffect(
|
||||
React.useCallback(() => {
|
||||
if(loanAccountNumber) {
|
||||
dispatch(
|
||||
getCaseUnifiedData(
|
||||
[loanAccountNumber],
|
||||
[UnifiedCaseDetailsTypes.FEEDBACKS, UnifiedCaseDetailsTypes.ADDRESS_AND_GEOLOCATIONS]
|
||||
)
|
||||
);
|
||||
if (loanAccountNumber) {
|
||||
dispatch(getAddressesAndGeolocations(loanAccountNumber));
|
||||
dispatch(getFeedbackHistory(loanAccountNumber));
|
||||
dispatch(getUngroupedAddress(loanAccountNumber));
|
||||
}
|
||||
}, [loanAccountNumber])
|
||||
@@ -129,7 +125,9 @@ const CollectionCaseDetails: React.FC<ICaseDetails> = (props) => {
|
||||
]}
|
||||
>
|
||||
<ViewAddressSection caseId={caseId} />
|
||||
{escalationData && totalEscalationsCount > 0 ? (<EscalationsSection caseId={caseId} />): null}
|
||||
{escalationData && totalEscalationsCount > 0 ? (
|
||||
<EscalationsSection caseId={caseId} />
|
||||
) : null}
|
||||
<EmiDetailsSection caseId={caseId} />
|
||||
<CollectMoneySection caseId={caseId} />
|
||||
<FeedbackDetailsSection caseId={caseId} />
|
||||
|
||||
@@ -8,12 +8,11 @@ import { GenericFunctionArgs } from '../../../common/GenericTypes';
|
||||
import Heading from '../../../../RN-UI-LIB/src/components/Heading';
|
||||
import LoadingIcon from '../../../../RN-UI-LIB/src/Icons/LoadingIcon';
|
||||
import FeedbackListItem from './FeedbackListItem';
|
||||
import { useAppDispatch, useAppSelector } from '../../../hooks';
|
||||
import { useAppDispatch } from '../../../hooks';
|
||||
import useIsOnline from '../../../hooks/useIsOnline';
|
||||
import NoFeedbackIcon from '../../../assets/icons/NoFeedbackIcon';
|
||||
import { RootState } from '../../../store/store';
|
||||
import OfflineIcon from '../../../../RN-UI-LIB/src/Icons/OfflineIcon';
|
||||
import { getCaseUnifiedData, UnifiedCaseDetailsTypes } from '../../../action/caseApiActions';
|
||||
import { getFeedbackHistory } from '../../../action/caseApiActions';
|
||||
|
||||
interface IFeedbackListContainer {
|
||||
loanAccountNumber: string;
|
||||
@@ -80,7 +79,7 @@ const FeedbackListContainer: React.FC<IFeedbackListContainer> = ({
|
||||
|
||||
useEffect(() => {
|
||||
if (retryBtnCount && isOnline) {
|
||||
dispatch(getCaseUnifiedData([loanAccountNumber], [UnifiedCaseDetailsTypes.FEEDBACKS]));
|
||||
dispatch(getFeedbackHistory(loanAccountNumber));
|
||||
}
|
||||
}, [retryBtnCount]);
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ import { addClickstreamEvent } from '@services/clickstreamEventService';
|
||||
import { CLICKSTREAM_EVENT_NAMES } from '@common/Constants';
|
||||
import { postFeeWaiver } from '@actions/emiActions';
|
||||
import { useAppDispatch } from '@hooks';
|
||||
import { UnifiedCaseDetailsTypes, getCaseUnifiedData } from '@actions/caseApiActions';
|
||||
import { getEmiScheduleData } from '@actions/caseApiActions';
|
||||
import FullScreenLoader from '@rn-ui-lib/components/FullScreenLoader';
|
||||
import { feeWaiveTransformedEmiData, getFeeWaiveBtnLabel } from './utils';
|
||||
import { EmiFeeActionLabelMap } from './constants';
|
||||
@@ -77,7 +77,7 @@ const FeeWaiver: React.FC<IFeeWaiver> = (props) => {
|
||||
Number(waivedValue) >= totalDueAmountUnpaid ? 'waived' : 'held'
|
||||
} for EMI ${emiNumber}`,
|
||||
});
|
||||
dispatch(getCaseUnifiedData([loanAccountNumber], [UnifiedCaseDetailsTypes.EMI_SCHEDULE]));
|
||||
dispatch(getEmiScheduleData(loanAccountNumber));
|
||||
setIsSubmitting(false);
|
||||
} catch (err) {
|
||||
toast({ type: 'error', text1: err as string });
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { RefreshControl, SafeAreaView, ScrollView, StyleSheet, View } from 'react-native';
|
||||
import { RefreshControl, ScrollView, View } from 'react-native';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import Layout from '../layout/Layout';
|
||||
import { GenericStyles } from '../../../RN-UI-LIB/src/styles';
|
||||
@@ -10,7 +10,7 @@ import OfflineScreen from '../../common/OfflineScreen';
|
||||
import useRefresh from '../../hooks/useRefresh';
|
||||
import { useAppDispatch, useAppSelector } from '../../hooks';
|
||||
import { RootState } from '../../store/store';
|
||||
import { getCaseUnifiedData, UnifiedCaseDetailsTypes } from '../../action/caseApiActions';
|
||||
import { getRepaymentsData, getEmiScheduleData } from '../../action/caseApiActions';
|
||||
import RepaymentsTab from './repayments/RepaymentsTab';
|
||||
import { toast } from '../../../RN-UI-LIB/src/components/toast';
|
||||
import { ToastMessages } from '../allCases/constants';
|
||||
@@ -68,18 +68,17 @@ const EmiSchedule: React.FC<IEmiSchedule> = (props) => {
|
||||
}, [notificationId]);
|
||||
|
||||
const { refreshing, onRefresh } = useRefresh(() => {
|
||||
isOnline
|
||||
? dispatch(
|
||||
getCaseUnifiedData(
|
||||
[loanAccountNumber],
|
||||
[UnifiedCaseDetailsTypes.EMI_SCHEDULE, UnifiedCaseDetailsTypes.REPAYMENTS]
|
||||
)
|
||||
)
|
||||
: toast({
|
||||
type: 'info',
|
||||
text1: ToastMessages.OFFLINE_MESSAGE,
|
||||
});
|
||||
if (isOnline) {
|
||||
dispatch(getRepaymentsData(loanAccountNumber));
|
||||
dispatch(getEmiScheduleData(loanAccountNumber));
|
||||
} else {
|
||||
toast({
|
||||
type: 'info',
|
||||
text1: ToastMessages.OFFLINE_MESSAGE,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
const backHandler = () => {
|
||||
popToScreen(1);
|
||||
};
|
||||
@@ -110,23 +109,21 @@ const EmiSchedule: React.FC<IEmiSchedule> = (props) => {
|
||||
<Layout>
|
||||
<View style={[GenericStyles.fill, GenericStyles.whiteBackground]}>
|
||||
<View>
|
||||
<ScrollView
|
||||
refreshControl={<RefreshControl refreshing={false} onRefresh={onRefresh} />}
|
||||
>
|
||||
<NavigationHeader
|
||||
onBack={backHandler}
|
||||
title={PAGE_TITLE}
|
||||
subTitle={`For ${customerName}`}
|
||||
/>
|
||||
<LoanDetails caseId={caseId} />
|
||||
<View style={GenericStyles.ph16}>
|
||||
<CustomTabs
|
||||
tabs={TABS}
|
||||
currentTab={currentTab}
|
||||
onTabChange={onTabChange}
|
||||
containerStyle={[GenericStyles.ml4, GenericStyles.pt16]}
|
||||
<ScrollView refreshControl={<RefreshControl refreshing={false} onRefresh={onRefresh} />}>
|
||||
<NavigationHeader
|
||||
onBack={backHandler}
|
||||
title={PAGE_TITLE}
|
||||
subTitle={`For ${customerName}`}
|
||||
/>
|
||||
</View>
|
||||
<LoanDetails caseId={caseId} />
|
||||
<View style={GenericStyles.ph16}>
|
||||
<CustomTabs
|
||||
tabs={TABS}
|
||||
currentTab={currentTab}
|
||||
onTabChange={onTabChange}
|
||||
containerStyle={[GenericStyles.ml4, GenericStyles.pt16]}
|
||||
/>
|
||||
</View>
|
||||
</ScrollView>
|
||||
</View>
|
||||
<View style={[GenericStyles.fill, GenericStyles.pt24]}>
|
||||
|
||||
Reference in New Issue
Block a user