From 34603b7dcc0862b1c0130dd7c1bc46ce0fad1521 Mon Sep 17 00:00:00 2001 From: Aman Chaturvedi Date: Thu, 24 Aug 2023 17:26:34 +0530 Subject: [PATCH] TP-34976 | Geolocation feedback API integration --- src/action/feedbackActions.ts | 6 +- .../form/components/AddressSelection.tsx | 12 ++-- .../form/components/GeolocationAddress.tsx | 5 +- src/components/utlis/apiHelper.ts | 6 +- .../GeolocationOldFeedbacks.tsx | 7 ++- src/screens/allCases/interface.ts | 2 +- .../feedback/FeedbackDetailItem.tsx | 56 +++++++++++-------- src/screens/caseDetails/interface.ts | 1 + src/types/feedback.types.ts | 4 +- 9 files changed, 57 insertions(+), 42 deletions(-) diff --git a/src/action/feedbackActions.ts b/src/action/feedbackActions.ts index 33132307..d4316159 100644 --- a/src/action/feedbackActions.ts +++ b/src/action/feedbackActions.ts @@ -6,14 +6,14 @@ interface IPastFeedbacksPayload { page_no: number; page_size: number; customerRecahble: boolean; - addressReferenceIds?: string[]; // required to fetch past feedback on addresses + addressReferenceIds: string; // required to fetch past feedback on addresses } interface IPastFeedbacksOnAddressesPayload { loanAccountNumber: string; pageNo?: number; pageSize?: number; - addressReferenceIds: string[]; + addressReferenceIds: string; } export const getPastFeedbacks = (queryParamsPayload: IPastFeedbacksPayload) => { @@ -40,7 +40,7 @@ export const getPastFeedbacksOnAddresses = (pastFeedbackPayload: IPastFeedbacksP const url = getApiUrl(ApiKeys.PAST_FEEDBACK_ON_ADDRESSES); const payload: IPastFeedbacksOnAddressesPayload = { loanAccountNumber: pastFeedbackPayload.loan_account_number, - addressReferenceIds: pastFeedbackPayload.addressReferenceIds as string[], + addressReferenceIds: pastFeedbackPayload.addressReferenceIds, pageNo: pastFeedbackPayload?.page_no, pageSize: pastFeedbackPayload?.page_size, }; diff --git a/src/components/form/components/AddressSelection.tsx b/src/components/form/components/AddressSelection.tsx index 319f0b6d..a245fe69 100644 --- a/src/components/form/components/AddressSelection.tsx +++ b/src/components/form/components/AddressSelection.tsx @@ -60,10 +60,9 @@ const AddressSelection: React.FC = (props) => { }); }; - const addresses = - question?.tag === VisitTypeSelection.GEOLOCATION_SELECTION - ? currentCase?.geolocations - : currentCase?.addresses; + const isGeolocation = question?.tag === VisitTypeSelection.GEOLOCATION_SELECTION; + + const addresses = isGeolocation ? currentCase?.geolocations : currentCase?.addresses; return ( @@ -84,13 +83,14 @@ const AddressSelection: React.FC = (props) => { orientation="vertical" > {addresses?.map((address) => { - const isGeolocation = question?.tag === VisitTypeSelection.GEOLOCATION_SELECTION; const addressLabel = isGeolocation ? (address as IGeolocation)?.tag : getAddressString(address as Address); return ( diff --git a/src/components/form/components/GeolocationAddress.tsx b/src/components/form/components/GeolocationAddress.tsx index 10c8f434..fc61b531 100644 --- a/src/components/form/components/GeolocationAddress.tsx +++ b/src/components/form/components/GeolocationAddress.tsx @@ -55,9 +55,10 @@ const GeolocationAddress: React.FC = ({ const roundoffRelativeDistanceBwLatLong = !isNaN(relativeDistanceBwLatLong) ? relativeDistanceBwLatLong.toFixed(2) : ''; + const addressSource = AddressSourceMap[primarySource]; - const addressDate = dateFormat(new Date(createdAt), 'DD MMM YYYY'); - const addressTime = dateFormat(new Date(createdAt), 'hh:mm A'); + const addressDate = dateFormat(new Date(Number(createdAt)), 'DD MMM YYYY'); + const addressTime = dateFormat(new Date(Number(createdAt)), 'hh:mm A'); const handleCloseRouting = () => handlePageRouting?.(PageRouteEnum.ADDRESS_GEO); diff --git a/src/components/utlis/apiHelper.ts b/src/components/utlis/apiHelper.ts index 19422a6c..70da0273 100644 --- a/src/components/utlis/apiHelper.ts +++ b/src/components/utlis/apiHelper.ts @@ -70,7 +70,7 @@ API_URLS[ApiKeys.GENERATE_PAYMENT_LINK] = '/payments/send-payment-link'; API_URLS[ApiKeys.ADDRESSES_GEOLOCATION] = '/addresses-geolocations'; API_URLS[ApiKeys.NEW_ADDRESS] = '/addresses'; API_URLS[ApiKeys.GET_SIGNED_URL] = '/cases/get-signed-urls'; -API_URLS[ApiKeys.CASE_UNIFIED_DETAILS] = '/v2/collection-cases/unified-details/{loanAccountNumber}'; +API_URLS[ApiKeys.CASE_UNIFIED_DETAILS] = '/v3/collection-cases/unified-details/{loanAccountNumber}'; API_URLS[ApiKeys.UNGROUPED_ADDRESSES] = '/addresses/ungrouped/{loanAccountNumber}'; API_URLS[ApiKeys.PAST_FEEDBACK] = '/feedback'; API_URLS[ApiKeys.PAST_FEEDBACK_ON_ADDRESSES] = '/feedback/v2'; @@ -210,7 +210,7 @@ axiosInstance.interceptors.response.use( } const { config, response } = error; logError(error as Error, config?.baseURL + config?.url); - const start = response.config.headers['request-start-time']; + const start = response?.config?.headers['request-start-time']; const end = Date.now(); const milliseconds = end - Number(start); sendApiToClickstreamEvent(response, milliseconds, false); @@ -218,7 +218,7 @@ axiosInstance.interceptors.response.use( Number ); if ( - config.headers.donotHandleError || + config?.headers?.donotHandleError || donotHandleErrorOnStatusCode.includes(error.response.status) ) { return Promise.reject(error); diff --git a/src/screens/addressGeolocation/GeolocationOldFeedbacks.tsx b/src/screens/addressGeolocation/GeolocationOldFeedbacks.tsx index d757bbef..cdd207cc 100644 --- a/src/screens/addressGeolocation/GeolocationOldFeedbacks.tsx +++ b/src/screens/addressGeolocation/GeolocationOldFeedbacks.tsx @@ -32,7 +32,7 @@ interface IGeolocationOldFeedbacks { route: { params: { loanAccountNumber: string; - addressReferenceIds?: string[]; + addressReferenceIds: string[]; geolocation: IGeolocation; }; }; @@ -57,7 +57,7 @@ const GeolocationOldFeedbacks: React.FC = ({ route: ro page_no: currentPage - 1, page_size: FEEDBACK_PER_PAGE, customerRecahble: false, - addressReferenceIds, + addressReferenceIds: addressReferenceIds?.join(','), }) .then((res: { data: IFeedback[]; totalPage: number } | GenericType) => { if (res?.data?.length) { @@ -134,7 +134,7 @@ const GeolocationOldFeedbacks: React.FC = ({ route: ro Feedback for - + {feedbackList.map((feedback: IFeedback, index) => ( @@ -145,6 +145,7 @@ const GeolocationOldFeedbacks: React.FC = ({ route: ro key={feedback.referenceId} feedbackItem={feedback} isExpanded={isExpanded} + hideAddress /> } customExpandUi={{ diff --git a/src/screens/allCases/interface.ts b/src/screens/allCases/interface.ts index 77f9b8ea..19aedcb9 100644 --- a/src/screens/allCases/interface.ts +++ b/src/screens/allCases/interface.ts @@ -145,7 +145,7 @@ export interface Address { permanent: boolean; zipCode?: any; addressQualityStatus?: any; - visitType: VisitType; + sourceType: VisitType; } export interface Metadata { diff --git a/src/screens/caseDetails/feedback/FeedbackDetailItem.tsx b/src/screens/caseDetails/feedback/FeedbackDetailItem.tsx index 24d03338..6a9d969c 100644 --- a/src/screens/caseDetails/feedback/FeedbackDetailItem.tsx +++ b/src/screens/caseDetails/feedback/FeedbackDetailItem.tsx @@ -21,6 +21,7 @@ import GeolocationAddress from '../../../components/form/components/GeolocationA interface IFeedbackDetailItem { feedbackItem: IFeedback; isExpanded: boolean; + hideAddress?: boolean; } const feedbackTypeIcon: Record = { @@ -48,7 +49,8 @@ const openGeolocation = (latitude: string, longitude: string) => { return Linking.openURL(geolocationUrl); }; -const FeedbackDetailItem = ({ feedbackItem, isExpanded }: IFeedbackDetailItem) => { +const FeedbackDetailItem = ({ feedbackItem, isExpanded, hideAddress }: IFeedbackDetailItem) => { + const isGeolocation = feedbackItem?.source?.sourceType === VisitType.GEOLOCATION; return ( @@ -77,29 +79,39 @@ const FeedbackDetailItem = ({ feedbackItem, isExpanded }: IFeedbackDetailItem) =   ●   {sanitizeString(dateFormat(new Date(feedbackItem.createdAt), BUSINESS_TIME_FORMAT))} - - - {FIELD_FEEDBACKS.includes(feedbackItem.type) ? ( - feedbackItem.source.visitType === VisitType.GEOLOCATION ? ( + {isGeolocation ? ( + !hideAddress ? ( + - ) : ( - sanitizeString(getAddress(feedbackItem.source as IAddress)) - ) - ) : ( - sanitizeString( - [ - (feedbackItem.source as ICallingFeedback)?.recipientNumber, - feedbackItem.sourceText ? `(${feedbackItem.sourceText})` : '', - ].join(' ') - ) - )} - + + ) : null + ) : ( + + {FIELD_FEEDBACKS.includes(feedbackItem.type) + ? sanitizeString(getAddress(feedbackItem.source as IAddress)) + : sanitizeString( + [ + (feedbackItem.source as ICallingFeedback)?.recipientNumber, + feedbackItem.sourceText ? `(${feedbackItem.sourceText})` : '', + ].join(' ') + )} + + )} - {feedbackItem.metadata?.interactionLatitude && FIELD_FEEDBACKS.includes(feedbackItem.type) ? ( + {feedbackItem.metadata?.interactionLatitude && + FIELD_FEEDBACKS.includes(feedbackItem.type) && + !isGeolocation ? ( diff --git a/src/screens/caseDetails/interface.ts b/src/screens/caseDetails/interface.ts index 21d61b40..b59e32a2 100644 --- a/src/screens/caseDetails/interface.ts +++ b/src/screens/caseDetails/interface.ts @@ -188,6 +188,7 @@ export interface IGeolocation { metadata: string; id: string; visitType: VisitType; + sourceType: VisitType; } export interface CaseDetail { diff --git a/src/types/feedback.types.ts b/src/types/feedback.types.ts index 939dfaea..70a5d387 100644 --- a/src/types/feedback.types.ts +++ b/src/types/feedback.types.ts @@ -1,6 +1,6 @@ import { GenericType } from '../common/GenericTypes'; import { Address, InteractionStatuses } from '../screens/allCases/interface'; -import { IGeolocation, PhoneNumberSource } from '../screens/caseDetails/interface'; +import { IGeolocation, PhoneNumberSource, VisitType } from '../screens/caseDetails/interface'; export enum AnswerType { TEXT = 'TEXT', @@ -54,7 +54,7 @@ export interface FIELD_FEEDBACK_METADATA { export interface ICallingFeedback { recipientName: string; recipientNumber: string; - visitType: string; + sourceType: VisitType; } export interface IFeedback {