diff --git a/RN-UI-LIB b/RN-UI-LIB index 5bc9cecc..9b83ba94 160000 --- a/RN-UI-LIB +++ b/RN-UI-LIB @@ -1 +1 @@ -Subproject commit 5bc9ceccea141b4d8ebc6db6365c2ae0feb5d8c0 +Subproject commit 9b83ba94da83ae3ab77bb888e5f375420352d3a2 diff --git a/src/action/caseApiActions.ts b/src/action/caseApiActions.ts index 4de709d3..b6d7d1dc 100644 --- a/src/action/caseApiActions.ts +++ b/src/action/caseApiActions.ts @@ -18,6 +18,7 @@ import { } from '../reducer/repaymentsSlice'; import { AxiosResponse } from 'axios'; import { setAddresses, setAddressLoading } from '../reducer/addressSlice'; +import { IFeedback } from '../types/feedback.types'; // TODO: Need to add respective interfaces instead of any interface IUnifiedData { @@ -81,8 +82,9 @@ const setUnifiedData = ); } if (queryParams[UnifiedCaseDetailsTypes.FEEDBACKS]) { + // todo: data is coming as feedback.data dispatch( - setFeedbackHistory({ loanAccountNumber, feedbacks }), + setFeedbackHistory({ loanAccountNumber, feedbacks: feedbacks?.data as IFeedback[] }), ); } if (queryParams[UnifiedCaseDetailsTypes.REPAYMENTS]) { @@ -113,7 +115,7 @@ export const getCaseUnifiedData = const promise = axiosInstance.get(url); promisesList.push(promise); }); - Promise.allSettled(promisesList).then(res => { + Promise.allSettled?.(promisesList).then(res => { dispatch(setUnifiedData(queryParams, loanAccountNumbers, res)); }).finally(() => { dispatch(setEmiScheduleLoading({isLoading:false, loanAccountNumbers})); diff --git a/src/action/feedbackActions.ts b/src/action/feedbackActions.ts index 13317503..d58ea808 100644 --- a/src/action/feedbackActions.ts +++ b/src/action/feedbackActions.ts @@ -5,22 +5,22 @@ import axiosInstance, { import { logError } from '../components/utlis/errorUtils'; interface IPastFeedbacks { - account_number: string, - page_no: number, - page_size: number, - customerRecahble: boolean, + loan_account_number: string, + page_no: number, + page_size: number, + customerRecahble: boolean, } export const getPastFeedbacks = (queryParamsPayload: IPastFeedbacks) => { const url = getApiUrl(ApiKeys.PAST_FEEDBACK); return axiosInstance - .post(url, {}, { + .get(url, { params: queryParamsPayload }) .then(response => { - if (response?.data) { - return response.data; + if (response?.data?.data?.length) { + return response.data.data; } throw response; }) diff --git a/src/components/utlis/apiHelper.ts b/src/components/utlis/apiHelper.ts index 890e68a8..a11ddd47 100644 --- a/src/components/utlis/apiHelper.ts +++ b/src/components/utlis/apiHelper.ts @@ -46,8 +46,7 @@ API_URLS[ApiKeys.NEW_ADDRESS] = '/addresses'; API_URLS[ApiKeys.GET_SIGNED_URL] = '/cases/get-signed-urls'; API_URLS[ApiKeys.CASE_UNIFIED_DETAILS] = '/collection-cases/unified-details/{loanAccountNumber}'; API_URLS[ApiKeys.EMI_SCHEDULES] = '/collection-cases/emi-schedules'; - -API_URLS[ApiKeys.PAST_FEEDBACK] = '/field-app/feedbacks'; +API_URLS[ApiKeys.PAST_FEEDBACK] = '/feedback'; export const API_STATUS_CODE = { OK: 200, diff --git a/src/reducer/feedbackHistorySlice.ts b/src/reducer/feedbackHistorySlice.ts index 4256bbab..eeb6f082 100644 --- a/src/reducer/feedbackHistorySlice.ts +++ b/src/reducer/feedbackHistorySlice.ts @@ -1,8 +1,8 @@ import { createSlice, PayloadAction } from '@reduxjs/toolkit'; +import { IFeedback } from '../types/feedback.types'; interface IFeedbackHistoryState { - //TODO: update interface of FeedbackHistory instead of any - [loanAccountNumber: string] : {data : any, isLoading: boolean, timestamp: string }; + [loanAccountNumber: string] : { data : IFeedback[], isLoading: boolean, timestamp: string }; } const initialState: IFeedbackHistoryState = {}; diff --git a/src/screens/addressGeolocation/AddressContainer.tsx b/src/screens/addressGeolocation/AddressContainer.tsx index bd8b7acd..6d2450d9 100644 --- a/src/screens/addressGeolocation/AddressContainer.tsx +++ b/src/screens/addressGeolocation/AddressContainer.tsx @@ -33,7 +33,7 @@ const AddressContainer: React.FC = ({addressList}) => { { addressList.map((address: AddressL1Details) => ( - = props => { } = caseDetail; const feedbackList: IFeedback[] = useAppSelector( - (state: RootState) => - state.feedbackHistory?.data?.[loanAccountNumber as string], + (state: RootState) => state.feedbackHistory?.[loanAccountNumber as string]?.data, ); const [showCallingBottomSheet, setShowCallingBottomSheet] = @@ -416,7 +415,7 @@ const CollectionCaseDetails: React.FC = props => { GenericStyles.pb16, ]}> - + = props => { {feedbackList?.length ? ( - + handleRouting(PageRouteEnum.PAST_FEEDBACK_DETAIL)} style={GenericStyles.flex20}> { + switch (answer?.answerType) { + case AnswerType.OPTIONS: + return sanitizeString(answer.optionText); + case AnswerType.TEXT: + return sanitizeString(answer.inputText); + case AnswerType.DATE: + return sanitizeString(dateFormat(new Date(answer.inputDate as string), BUSINESS_DATE_FORMAT)) + case AnswerType.TIME: + return sanitizeString(dateFormat(new Date(answer.inputDate as string), BUSINESS_TIME_FORMAT)) + case AnswerType.AMOUNT: + return `₹ ${answer.inputAmount}`; + default: + return sanitizeString() + } +} + +interface IFeedbackDetailAnswerContainer { + answerList: IAnswerView[] +} + +const FeedbackDetailAnswerContainer: React.FC = ({ answerList }) => { + const imageAnswerList = answerList.filter(answer => answer.questionTag === OPTION_TAG.IMAGE_UPLOAD); -export default function FeedbackDetailAnswerContainer() { return ( - FeedbackDetailAnswerContainer + + { + imageAnswerList.map(image => ( + + )) + } + { + answerList.filter(answer => answer.questionTag !== OPTION_TAG.IMAGE_UPLOAD).map((answerItem) => ( + + { + (answerItem.questionKey ? answerItem.questionName : answerItem.questionText) || '--'} + {getAnswerText(answerItem)} + + )) + } + + ) } + +const styles = StyleSheet.create({ + container: { + padding: 16, + backgroundColor: COLORS.TEXT.GREY_LIGHT, + }, + textContainer: { + fontSize: 12, + lineHeight: 18, + fontWeight: '400', + }, + questionText: { + color: COLORS.TEXT.LIGHT + }, + answerText: { + color: COLORS.TEXT.DARK + }, + br8:{ + borderRadius: 8 + }, + image: { + width: '100%', + height: 350, + resizeMode: 'contain', + }, +}); + +export default FeedbackDetailAnswerContainer; \ No newline at end of file diff --git a/src/screens/caseDetails/feedback/FeedbackDetailContainer.tsx b/src/screens/caseDetails/feedback/FeedbackDetailContainer.tsx index 73912ce0..638b34e1 100644 --- a/src/screens/caseDetails/feedback/FeedbackDetailContainer.tsx +++ b/src/screens/caseDetails/feedback/FeedbackDetailContainer.tsx @@ -1,6 +1,7 @@ import React, { useEffect, useState } from 'react' -import { ScrollView, StyleSheet, View } from 'react-native'; +import { Dimensions, ScrollView, StyleSheet, View } from 'react-native'; import Accordion from '../../../../RN-UI-LIB/src/components/accordian/Accordian'; +import FullScreenLoader from '../../../../RN-UI-LIB/src/components/FullScreenLoader'; import NavigationHeader from '../../../../RN-UI-LIB/src/components/NavigationHeader'; import Text from '../../../../RN-UI-LIB/src/components/Text'; import { GenericStyles, getShadowStyle } from '../../../../RN-UI-LIB/src/styles'; @@ -17,7 +18,7 @@ import FeedbackDetailAnswerContainer from './FeedbackDetailAnswerContainer'; import FeedbackDetailItem from './FeedbackDetailItem'; const PAGE_TITLE = 'All feedbacks'; -const SCROLL_LAYOUT_OFFSET = -10; +const SCROLL_LAYOUT_OFFSET = 10; interface IFeedbackDetailContainer { route: { @@ -35,28 +36,33 @@ const FeedbackDetailContainer: React.FC = ({ route: ro const isOnline = useIsOnline(); - const [feedbackList, setFeedbackList] = useState([]); - const feedbackListFromCache = useAppSelector( - (state: RootState) => state.feedbackHistory?.data?.[loanAccountNumber], + (state: RootState) => state.feedbackHistory?.[loanAccountNumber as string]?.data, ) + const [feedbackList, setFeedbackList] = useState([]); + const [loading, setLoading] = useState(false); + useEffect(() => { if(isOnline) { + setLoading(true); getPastFeedbacks({ - account_number: loanAccountNumber, + loan_account_number: loanAccountNumber, page_no: 0, page_size: 100, customerRecahble: false, }).then((res: IFeedback[]) => { - if (res) { - setFeedbackList(res); + if (res?.length) { + return setFeedbackList(res); } throw res; }) .catch(err => { - logError(err); setFeedbackList(feedbackListFromCache); + logError(err); + }) + .finally(() => { + setLoading(false); }) } else { setFeedbackList(feedbackListFromCache); @@ -79,45 +85,43 @@ const FeedbackDetailContainer: React.FC = ({ route: ro return ( + - setRef(x)}> - - { - feedbackList.map((feedback: IFeedback, index) => ( - { - const layout = event.nativeEvent.layout; - if (!dataSourceCord && feedback.referenceId === activeFeedbackReferenceId) { - setDataSourceCord(layout.y + SCROLL_LAYOUT_OFFSET) - } - }}> - } - customExpandUi={{ whenCollapsed: View more, whenExpanded: View less }} - > - - - - - - )) - } - - + setRef(x)}> + { + feedbackList.map((feedback: IFeedback, index) => ( + { + const layout = event.nativeEvent.layout; + if (!dataSourceCord && feedback.referenceId === activeFeedbackReferenceId) { + setDataSourceCord(layout.y + SCROLL_LAYOUT_OFFSET) + } + }}> + } + customExpandUi={{ whenCollapsed: View more, whenExpanded: View less }} + > + + + + )) + } + ) } const styles = StyleSheet.create({ container: { - paddingVertical: 20, + paddingTop: 20, paddingHorizontal: 16, backgroundColor: COLORS.BACKGROUND.PRIMARY, + height: (Dimensions.get('window').height - 56) }, accordionExpandBtn: { fontSize: 13, diff --git a/src/screens/caseDetails/feedback/FeedbackDetailItem.tsx b/src/screens/caseDetails/feedback/FeedbackDetailItem.tsx index bb4eaec5..5d592b2d 100644 --- a/src/screens/caseDetails/feedback/FeedbackDetailItem.tsx +++ b/src/screens/caseDetails/feedback/FeedbackDetailItem.tsx @@ -29,9 +29,9 @@ const FeedbackDetailItem = ({ feedbackItem }: IFeedbackDetailItem) => { const getBottomSheetHeight = getDynamicBottomSheetHeightPercentageFn(); return ( - + - {sanitizeString(InteractionStatuses[feedbackItem.interactionStatus])} + {sanitizeString(feedbackItem.interactionStatus)} {sanitizeString(dateFormat(new Date(feedbackItem.createdAt), BUSINESS_DATE_FORMAT))} diff --git a/src/screens/caseDetails/feedback/FeedbackListContainer.tsx b/src/screens/caseDetails/feedback/FeedbackListContainer.tsx index 141a7aea..bc70a1cf 100644 --- a/src/screens/caseDetails/feedback/FeedbackListContainer.tsx +++ b/src/screens/caseDetails/feedback/FeedbackListContainer.tsx @@ -77,7 +77,7 @@ const FeedbackListContainer: React.FC = ({ loanAccountNu const isOnline = useIsOnline(); const feedbackList: IFeedback[] = useAppSelector( - (state: RootState) => state.feedbackHistory?.data?.[loanAccountNumber], + (state: RootState) => state.feedbackHistory?.[loanAccountNumber as string]?.data, ); const handleRetryEvent = () => { diff --git a/src/screens/caseDetails/feedback/FeedbackListItem.tsx b/src/screens/caseDetails/feedback/FeedbackListItem.tsx index a3f0e378..da6452c9 100644 --- a/src/screens/caseDetails/feedback/FeedbackListItem.tsx +++ b/src/screens/caseDetails/feedback/FeedbackListItem.tsx @@ -40,7 +40,7 @@ const FeedbackListItem: React.FC = ({ feedbackItem, loanAccou - {sanitizeString(InteractionStatuses[feedbackItem.interactionStatus])} + {sanitizeString(feedbackItem.interactionStatus)} diff --git a/src/types/feedback.types.ts b/src/types/feedback.types.ts index 48386763..a57c2f10 100644 --- a/src/types/feedback.types.ts +++ b/src/types/feedback.types.ts @@ -11,18 +11,25 @@ export enum AnswerType { REMINDER = 'REMINDER', } +export enum OPTION_TAG { + COMMENTS = 'COMMENTS', + IMAGE_UPLOAD = 'IMAGE_UPLOAD', +} + export interface IAnswerView { interactionId?: number; referenceId?: string; questionReferenceId?: string; questionName?: string; questionText?: string; + questionKey?: string; answerType?: AnswerType; optionReferenceId?: string; optionText?: string; inputAmount?: number; inputDate?: string; inputText?: string; + questionTag?: OPTION_TAG; } export enum FEEDBACK_TYPE {