From 65566bd1ac9b5d858f8d07b65822f2ec68daadbe Mon Sep 17 00:00:00 2001 From: Aman Chaturvedi Date: Fri, 15 Nov 2024 18:25:15 +0530 Subject: [PATCH] NTP-12177 | Seggregation of Unified API --- src/action/addressGeolocationAction.ts | 56 ++--- src/action/caseApiActions.ts | 217 +++++++----------- .../form/components/AddressSelection.tsx | 6 +- src/components/utlis/apiHelper.ts | 14 +- src/reducer/addressSlice.ts | 15 +- src/reducer/emiScheduleSlice.ts | 12 +- src/reducer/feedbackHistorySlice.ts | 12 +- src/reducer/repaymentsSlice.ts | 13 +- .../NewAddressContainer.tsx | 3 +- .../UngroupedAddressContainer.tsx | 2 +- src/screens/addressGeolocation/index.tsx | 16 +- .../caseDetails/CollectionCaseDetail.tsx | 18 +- .../feedback/FeedbackListContainer.tsx | 7 +- src/screens/emiSchedule/FeeWaiver.tsx | 4 +- src/screens/emiSchedule/index.tsx | 55 +++-- 15 files changed, 183 insertions(+), 267 deletions(-) diff --git a/src/action/addressGeolocationAction.ts b/src/action/addressGeolocationAction.ts index cd63bb1c..34e5a45c 100644 --- a/src/action/addressGeolocationAction.ts +++ b/src/action/addressGeolocationAction.ts @@ -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 }); diff --git a/src/action/caseApiActions.ts b/src/action/caseApiActions.ts index bbf95484..4f337d88 100644 --- a/src/action/caseApiActions.ts +++ b/src/action/caseApiActions.ts @@ -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, 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, - loanAccountNumbers: string[], - unifiedPromiseData: Array>> - ) => +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>> = []; - 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, interactionReferenceId: string) => (dispatch: AppDispatch) => { diff --git a/src/components/form/components/AddressSelection.tsx b/src/components/form/components/AddressSelection.tsx index ac6f300d..b4debdb4 100644 --- a/src/components/form/components/AddressSelection.tsx +++ b/src/components/form/components/AddressSelection.tsx @@ -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 = (props) => { const controllerName = `widgetContext.${widgetId}.sectionContext.${sectionId}.questionContext.${questionId}`; const reloadGeolocations = () => { - dispatch( - getCaseUnifiedData([loanAccountNumber], [UnifiedCaseDetailsTypes.ADDRESS_AND_GEOLOCATIONS]) - ); + dispatch(getAddressesAndGeolocations(loanAccountNumber)); }; if (isGeolocation) { diff --git a/src/components/utlis/apiHelper.ts b/src/components/utlis/apiHelper.ts index d9c43d37..d63a3358 100644 --- a/src/components/utlis/apiHelper.ts +++ b/src/components/utlis/apiHelper.ts @@ -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 = {} as Record; @@ -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 diff --git a/src/reducer/addressSlice.ts b/src/reducer/addressSlice.ts index e7bddf20..3fddc50f 100644 --- a/src/reducer/addressSlice.ts +++ b/src/reducer/addressSlice.ts @@ -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, + }; }, }, }); diff --git a/src/reducer/emiScheduleSlice.ts b/src/reducer/emiScheduleSlice.ts index 65078027..97cf767d 100644 --- a/src/reducer/emiScheduleSlice.ts +++ b/src/reducer/emiScheduleSlice.ts @@ -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, + }; }, }, }); diff --git a/src/reducer/feedbackHistorySlice.ts b/src/reducer/feedbackHistorySlice.ts index 6b223140..fd226893 100644 --- a/src/reducer/feedbackHistorySlice.ts +++ b/src/reducer/feedbackHistorySlice.ts @@ -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, + }; }, }, }); diff --git a/src/reducer/repaymentsSlice.ts b/src/reducer/repaymentsSlice.ts index aec07fbf..376b72c2 100644 --- a/src/reducer/repaymentsSlice.ts +++ b/src/reducer/repaymentsSlice.ts @@ -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, + }; }, }, }); diff --git a/src/screens/addressGeolocation/NewAddressContainer.tsx b/src/screens/addressGeolocation/NewAddressContainer.tsx index 36b6ef9a..8567022b 100644 --- a/src/screens/addressGeolocation/NewAddressContainer.tsx +++ b/src/screens/addressGeolocation/NewAddressContainer.tsx @@ -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'; diff --git a/src/screens/addressGeolocation/UngroupedAddressContainer.tsx b/src/screens/addressGeolocation/UngroupedAddressContainer.tsx index 9294d569..51ba5f23 100644 --- a/src/screens/addressGeolocation/UngroupedAddressContainer.tsx +++ b/src/screens/addressGeolocation/UngroupedAddressContainer.tsx @@ -61,7 +61,7 @@ const UngroupedAddressContainer: React.FC = ({ route: routePa const fetchUngroupedAddress = () => { // fetch ungrouped address - dispatch(getUngroupedAddress(loanAccountNumber)); + dispatch(getUngroupedAddress(loanAccountNumber, true)); }; if (!isOnline) { diff --git a/src/screens/addressGeolocation/index.tsx b/src/screens/addressGeolocation/index.tsx index d6779a84..d885335b 100644 --- a/src/screens/addressGeolocation/index.tsx +++ b/src/screens/addressGeolocation/index.tsx @@ -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 = ({ 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 = ({ route: routeParams useEffect(() => { addClickstreamEvent(CLICKSTREAM_EVENT_NAMES.FA_ALL_ADDRESSES_LANDED, commonParams); - dispatch(getUngroupedAddress(loanAccountNumber)); + dispatch(getUngroupedAddress(loanAccountNumber, true)); }, []); useEffect(() => { diff --git a/src/screens/caseDetails/CollectionCaseDetail.tsx b/src/screens/caseDetails/CollectionCaseDetail.tsx index 621361cd..8bc652c5 100644 --- a/src/screens/caseDetails/CollectionCaseDetail.tsx +++ b/src/screens/caseDetails/CollectionCaseDetail.tsx @@ -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 = (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 = (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 = (props) => { ]} > - {escalationData && totalEscalationsCount > 0 ? (): null} + {escalationData && totalEscalationsCount > 0 ? ( + + ) : null} diff --git a/src/screens/caseDetails/feedback/FeedbackListContainer.tsx b/src/screens/caseDetails/feedback/FeedbackListContainer.tsx index 62016f9e..90912b79 100644 --- a/src/screens/caseDetails/feedback/FeedbackListContainer.tsx +++ b/src/screens/caseDetails/feedback/FeedbackListContainer.tsx @@ -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 = ({ useEffect(() => { if (retryBtnCount && isOnline) { - dispatch(getCaseUnifiedData([loanAccountNumber], [UnifiedCaseDetailsTypes.FEEDBACKS])); + dispatch(getFeedbackHistory(loanAccountNumber)); } }, [retryBtnCount]); diff --git a/src/screens/emiSchedule/FeeWaiver.tsx b/src/screens/emiSchedule/FeeWaiver.tsx index 2dfd8cbd..cc832a82 100644 --- a/src/screens/emiSchedule/FeeWaiver.tsx +++ b/src/screens/emiSchedule/FeeWaiver.tsx @@ -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 = (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 }); diff --git a/src/screens/emiSchedule/index.tsx b/src/screens/emiSchedule/index.tsx index 315722d7..7ca9a2ed 100644 --- a/src/screens/emiSchedule/index.tsx +++ b/src/screens/emiSchedule/index.tsx @@ -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 = (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 = (props) => { - } - > - - - - }> + - + + + +