TP-36903 | PR comments Resolved
This commit is contained in:
@@ -1,52 +1,122 @@
|
||||
import axiosInstance, { ApiKeys, API_STATUS_CODE, getApiUrl } from '../components/utlis/apiHelper';
|
||||
import { logError } from '../components/utlis/errorUtils';
|
||||
import {
|
||||
setCashCollectedData,
|
||||
setIsloading,
|
||||
setPerformanceData,
|
||||
} from '../reducer/agentPerformanceSlice';
|
||||
import { setIsExternalAgent } from '../reducer/userSlice';
|
||||
import {
|
||||
CashCollectedData,
|
||||
CashCollectedSplitPayload,
|
||||
PaginationDetails,
|
||||
} from '../screens/Dashboard/interface';
|
||||
import { getCashCollectedData, getFiltersCount } from '../screens/Dashboard/utils';
|
||||
import { AppDispatch } from '../store/store';
|
||||
|
||||
export const getAgentDetail = () => {
|
||||
export const getAgentDetail = (callbackFn: () => void) => (dispatch: AppDispatch) => {
|
||||
const url = getApiUrl(ApiKeys.GET_AGENT_DETAIL);
|
||||
return axiosInstance
|
||||
.get(url)
|
||||
.then((response) => {
|
||||
if (response.status === API_STATUS_CODE.OK) {
|
||||
return response.data;
|
||||
dispatch(setIsExternalAgent(response?.data?.isExternalAgent));
|
||||
}
|
||||
throw response;
|
||||
})
|
||||
.catch((err) => {
|
||||
logError(err);
|
||||
throw new Error(err);
|
||||
});
|
||||
})
|
||||
.finally(() => callbackFn());
|
||||
};
|
||||
|
||||
export const getPerformanceMetrics = () => {
|
||||
const url = getApiUrl(ApiKeys.GET_PERFORMANCE_METRICS);
|
||||
return axiosInstance
|
||||
.get(url)
|
||||
.then((response) => {
|
||||
if (response.status === API_STATUS_CODE.OK) {
|
||||
return response.data;
|
||||
}
|
||||
throw response;
|
||||
})
|
||||
.catch((err) => {
|
||||
logError(err);
|
||||
throw new Error(err);
|
||||
});
|
||||
};
|
||||
export const getPerformanceMetrics =
|
||||
(
|
||||
caseDetailsIds: Array<string>,
|
||||
setIsLoading: (isLoading: boolean) => void,
|
||||
callbackFn?: () => void
|
||||
) =>
|
||||
(dispatch: AppDispatch) => {
|
||||
const url = getApiUrl(ApiKeys.GET_PERFORMANCE_METRICS);
|
||||
return axiosInstance
|
||||
.get(url)
|
||||
.then((response) => {
|
||||
if (response.status === API_STATUS_CODE.OK) {
|
||||
const {
|
||||
visitedCases,
|
||||
contactableCases,
|
||||
ptpCases,
|
||||
convertedPtpCases,
|
||||
atLeastOneEmiCollectedCases,
|
||||
} = response?.data?.casesSplit;
|
||||
const { totalLevel, currentLevel } = response?.data?.performanceLevel;
|
||||
const { unVisitedCount, nonContactableCount, nonPtpCount, brokenPtpCount } =
|
||||
getFiltersCount(caseDetailsIds, response?.data?.casesSplit);
|
||||
|
||||
export const getCashCollectedSplit = (payload: any) => {
|
||||
const url = getApiUrl(ApiKeys.GET_CASH_COLLECTED);
|
||||
return axiosInstance
|
||||
.get(url, {
|
||||
params: payload,
|
||||
})
|
||||
.then((response) => {
|
||||
if (response.status === API_STATUS_CODE.OK) {
|
||||
return response.data;
|
||||
}
|
||||
throw response;
|
||||
})
|
||||
.catch((err) => {
|
||||
logError(err);
|
||||
throw new Error(err);
|
||||
});
|
||||
};
|
||||
dispatch(
|
||||
setPerformanceData({
|
||||
cases: {
|
||||
visitedCases,
|
||||
unvisitedCases: unVisitedCount,
|
||||
contactableCases,
|
||||
nonContactableCases: nonContactableCount,
|
||||
totalPtp: ptpCases,
|
||||
nonPtp: nonPtpCount,
|
||||
convertedPtp: convertedPtpCases,
|
||||
brokenPtp: brokenPtpCount,
|
||||
totalEmi: response?.data?.allCases,
|
||||
atleastOneEmiCollected: atLeastOneEmiCollectedCases,
|
||||
},
|
||||
performanceLevel: {
|
||||
totalLevel,
|
||||
currentLevel,
|
||||
},
|
||||
totalCashCollected: response?.data?.totalCashCollected,
|
||||
lastUpdatedAt: response?.data?.lastUpdatedAt,
|
||||
})
|
||||
);
|
||||
}
|
||||
return;
|
||||
})
|
||||
.catch((err) => {
|
||||
logError(err);
|
||||
})
|
||||
.finally(() => {
|
||||
callbackFn && callbackFn();
|
||||
setIsLoading(false);
|
||||
});
|
||||
};
|
||||
|
||||
export const getCashCollectedSplit =
|
||||
(
|
||||
payload: CashCollectedSplitPayload,
|
||||
caseDetailsIds: Array<string>,
|
||||
cashCollectedData: CashCollectedData,
|
||||
setPaginationDetails: (data: PaginationDetails) => void,
|
||||
callbackFn?: () => void
|
||||
) =>
|
||||
(dispatch: AppDispatch) => {
|
||||
const url = getApiUrl(ApiKeys.GET_CASH_COLLECTED);
|
||||
return axiosInstance
|
||||
.get(url, {
|
||||
params: payload,
|
||||
})
|
||||
.then((response) => {
|
||||
if (response.status === API_STATUS_CODE.OK) {
|
||||
const cashData = response?.data?.data;
|
||||
setPaginationDetails(response?.data?.pages);
|
||||
const cashCollected = getCashCollectedData(cashData, caseDetailsIds);
|
||||
if (response?.data?.pages?.pageNo === 0) {
|
||||
dispatch(setCashCollectedData(cashCollected));
|
||||
return;
|
||||
}
|
||||
dispatch(setCashCollectedData([...cashCollectedData.data, ...cashCollected]));
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
logError(err);
|
||||
})
|
||||
.finally(() => {
|
||||
dispatch(setIsloading(false));
|
||||
callbackFn && callbackFn();
|
||||
});
|
||||
};
|
||||
|
||||
@@ -14,28 +14,27 @@ const DashboardHeader = () => {
|
||||
const performanceData = useAppSelector((state) => state.agentPerformance.performanceData);
|
||||
const { lastUpdatedAt } = performanceData;
|
||||
return (
|
||||
<Animated.View style={[styles.dashboardHeaderContainer]}>
|
||||
<View
|
||||
style={[
|
||||
GenericStyles.row,
|
||||
GenericStyles.alignCenter,
|
||||
GenericStyles.spaceBetween,
|
||||
GenericStyles.ph16,
|
||||
GenericStyles.pv10,
|
||||
]}
|
||||
>
|
||||
<View style={[GenericStyles.fill]}>
|
||||
<Heading type="h3" style={[styles.headerLabel]}>
|
||||
{PerfomanceHeaderTitle}
|
||||
</Heading>
|
||||
<Text style={[styles.subtitle]} small>
|
||||
Last updated at{' '}
|
||||
{sanitizeString(`${dateFormat(new Date(lastUpdatedAt ?? 0), BUSINESS_TIME_FORMAT)}`)}
|
||||
</Text>
|
||||
</View>
|
||||
<NotificationMenu />
|
||||
<View
|
||||
style={[
|
||||
styles.dashboardHeaderContainer,
|
||||
GenericStyles.row,
|
||||
GenericStyles.alignCenter,
|
||||
GenericStyles.spaceBetween,
|
||||
GenericStyles.ph16,
|
||||
GenericStyles.pv10,
|
||||
]}
|
||||
>
|
||||
<View style={[GenericStyles.fill]}>
|
||||
<Heading type="h3" style={[styles.headerLabel]}>
|
||||
{PerfomanceHeaderTitle}
|
||||
</Heading>
|
||||
<Text style={[styles.subtitle]} small>
|
||||
Last updated at{' '}
|
||||
{sanitizeString(`${dateFormat(new Date(lastUpdatedAt ?? 0), BUSINESS_TIME_FORMAT)}`)}
|
||||
</Text>
|
||||
</View>
|
||||
</Animated.View>
|
||||
<NotificationMenu />
|
||||
</View>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -10,7 +10,11 @@ import { useAppDispatch, useAppSelector } from '../../hooks';
|
||||
import { setFilteredListToast } from '../../reducer/allCasesSlice';
|
||||
import { setSelectedFilters } from '../../reducer/filtersSlice';
|
||||
import { BOTTOM_TAB_ROUTES } from '../allCases/constants';
|
||||
import { CurrentAllocationStatsFilterMap, CurrentAllocationStatsMap } from './interface';
|
||||
import {
|
||||
CurrentAllocationStatsFilterMap,
|
||||
CurrentAllocationStatsMap,
|
||||
PerformanceDetailsType,
|
||||
} from './interface';
|
||||
import { getPerformanceDetailFilter, getPerformanceDetails } from './utils';
|
||||
|
||||
const PerformanceCard = () => {
|
||||
@@ -23,30 +27,31 @@ const PerformanceCard = () => {
|
||||
|
||||
const dispatch = useAppDispatch();
|
||||
|
||||
const handlePress = (item: PerformanceDetailsType) => {
|
||||
dispatch(
|
||||
setSelectedFilters(
|
||||
getPerformanceDetailFilter(
|
||||
item.redirectionType,
|
||||
Object.keys(filters['COMMON']?.filters)?.includes(
|
||||
CurrentAllocationStatsFilterMap[item.redirectionType]
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
dispatch(
|
||||
setFilteredListToast({
|
||||
showToast: true,
|
||||
caseType: CurrentAllocationStatsMap[item.redirectionType],
|
||||
})
|
||||
);
|
||||
navigateToScreen(BOTTOM_TAB_ROUTES.Cases);
|
||||
};
|
||||
return (
|
||||
<View style={[GenericStyles.row, GenericStyles.plr16, GenericStyles.mb8, styles.container]}>
|
||||
{performanceDetails.map((item) => (
|
||||
<TouchableOpacity
|
||||
activeOpacity={1}
|
||||
onPress={() => {
|
||||
dispatch(
|
||||
setSelectedFilters(
|
||||
getPerformanceDetailFilter(
|
||||
item.redirectionType,
|
||||
Object.keys(filters['COMMON']?.filters)?.includes(
|
||||
CurrentAllocationStatsFilterMap[item.redirectionType]
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
dispatch(
|
||||
setFilteredListToast({
|
||||
showToast: true,
|
||||
caseType: CurrentAllocationStatsMap[item.redirectionType],
|
||||
})
|
||||
);
|
||||
navigateToScreen(BOTTOM_TAB_ROUTES.Cases);
|
||||
}}
|
||||
onPress={() => handlePress(item)}
|
||||
style={[
|
||||
getShadowStyle(2),
|
||||
GenericStyles.br6,
|
||||
|
||||
@@ -10,13 +10,10 @@ import {
|
||||
import { GenericStyles } from '../../../RN-UI-LIB/src/styles';
|
||||
import { COLORS } from '../../../RN-UI-LIB/src/styles/colors';
|
||||
import { getPerformanceMetrics } from '../../action/agentPerformanceAction';
|
||||
import { logError } from '../../components/utlis/errorUtils';
|
||||
import { useAppDispatch, useAppSelector } from '../../hooks';
|
||||
import { setPerformanceData } from '../../reducer/agentPerformanceSlice';
|
||||
import DashboardHeader from './DashboardHeader';
|
||||
import PerformanceCard from './PerformanceCard';
|
||||
import PerformanceOverview from './PerformanceOverview';
|
||||
import { getFiltersCount } from './utils';
|
||||
|
||||
const Dashboard = () => {
|
||||
const [refreshing, setRefreshing] = React.useState(false);
|
||||
@@ -27,49 +24,7 @@ const Dashboard = () => {
|
||||
|
||||
const fetchAgentPerformanceMetrics = (callbackFn?: () => void) => {
|
||||
setIsLoading(true);
|
||||
getPerformanceMetrics()
|
||||
.then((res) => {
|
||||
const {
|
||||
visitedCases,
|
||||
contactableCases,
|
||||
ptpCases,
|
||||
convertedPtpCases,
|
||||
atLeastOneEmiCollectedCases,
|
||||
} = res?.casesSplit;
|
||||
const { totalLevel, currentLevel } = res?.performanceLevel;
|
||||
const { unVisitedCount, nonContactableCount, nonPtpCount, brokenPtpCount } =
|
||||
getFiltersCount(caseDetailsIds, res?.casesSplit);
|
||||
|
||||
dispatch(
|
||||
setPerformanceData({
|
||||
cases: {
|
||||
visitedCases,
|
||||
unvisitedCases: unVisitedCount,
|
||||
contactableCases,
|
||||
nonContactableCases: nonContactableCount,
|
||||
totalPtp: ptpCases,
|
||||
nonPtp: nonPtpCount,
|
||||
convertedPtp: convertedPtpCases,
|
||||
brokenPtp: brokenPtpCount,
|
||||
totalEmi: res?.allCases,
|
||||
atleastOneEmiCollected: atLeastOneEmiCollectedCases,
|
||||
},
|
||||
performanceLevel: {
|
||||
totalLevel,
|
||||
currentLevel,
|
||||
},
|
||||
totalCashCollected: res?.totalCashCollected,
|
||||
lastUpdatedAt: res?.lastUpdatedAt,
|
||||
})
|
||||
);
|
||||
})
|
||||
.catch((err) => {
|
||||
logError(err);
|
||||
})
|
||||
.finally(() => {
|
||||
callbackFn && callbackFn();
|
||||
setIsLoading(false);
|
||||
});
|
||||
dispatch(getPerformanceMetrics(caseDetailsIds, setIsLoading, callbackFn));
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
@@ -79,3 +79,23 @@ export const CurrentAllocationStatsFilterMap = {
|
||||
[CurrentAllocationStats.NON_PTP]: CurrentAllocationStatsFilter.PTP_STATUS,
|
||||
[CurrentAllocationStats.BROKEN_PTP]: CurrentAllocationStatsFilter.PTP_BREAKAGE,
|
||||
};
|
||||
|
||||
export interface PerformanceDetailsType {
|
||||
totalConverted: number;
|
||||
convertedText: string;
|
||||
totalNotConverted: number;
|
||||
notConvertedText: string;
|
||||
redirectionType: CurrentAllocationStats;
|
||||
}
|
||||
|
||||
export interface PaginationDetails {
|
||||
pageNo: number;
|
||||
totalPages: number;
|
||||
pageSize: number;
|
||||
totalElements: number;
|
||||
}
|
||||
|
||||
export interface CashCollectedSplitPayload {
|
||||
pageNo: number;
|
||||
pageSize: number;
|
||||
}
|
||||
|
||||
@@ -34,7 +34,6 @@ import TodoList from '../todoList/TodoList';
|
||||
import UngroupedAddressContainer from '../addressGeolocation/UngroupedAddressContainer';
|
||||
import CashCollected from '../cashCollected';
|
||||
import { getAgentDetail } from '../../action/agentPerformanceAction';
|
||||
import { setIsExternalAgent } from '../../reducer/userSlice';
|
||||
import FullScreenLoader from '../../../RN-UI-LIB/src/components/FullScreenLoader';
|
||||
|
||||
const Stack = createNativeStackNavigator();
|
||||
@@ -115,14 +114,7 @@ const ProtectedRouter = () => {
|
||||
useEffect(() => {
|
||||
if (isOnline) {
|
||||
setIsLoading(true);
|
||||
getAgentDetail()
|
||||
.then((res) => {
|
||||
dispatch(setIsExternalAgent(res?.isExternalAgent));
|
||||
})
|
||||
.catch(() => {
|
||||
dispatch(setIsExternalAgent(false));
|
||||
})
|
||||
.finally(() => setIsLoading(false));
|
||||
dispatch(getAgentDetail(() => setIsLoading(false)));
|
||||
}
|
||||
}, [isOnline]);
|
||||
|
||||
|
||||
@@ -16,13 +16,11 @@ import { _map } from '../../../RN-UI-LIB/src/utlis/common';
|
||||
import { getCashCollectedSplit } from '../../action/agentPerformanceAction';
|
||||
import NoRepaymentsFoundIcon from '../../assets/icons/NoRepaymentsFoundIcon';
|
||||
import NotificationMenu from '../../components/notificationMenu';
|
||||
import { logError } from '../../components/utlis/errorUtils';
|
||||
import { goBack } from '../../components/utlis/navigationUtlis';
|
||||
import { useAppDispatch, useAppSelector } from '../../hooks';
|
||||
import { setCashCollectedData, setIsloading } from '../../reducer/agentPerformanceSlice';
|
||||
import { setIsloading } from '../../reducer/agentPerformanceSlice';
|
||||
import { RootState } from '../../store/store';
|
||||
import { NO_CASH_COLLECTED_FOUND } from '../Dashboard/constants';
|
||||
import { getCashCollectedData } from '../Dashboard/utils';
|
||||
import Layout from '../layout/Layout';
|
||||
import CashCollectedItem from './CashCollectedItem';
|
||||
|
||||
@@ -48,24 +46,15 @@ const CashCollected = () => {
|
||||
|
||||
const fetchCashCollectedData = (pageNo: number, callbackFn?: () => void) => {
|
||||
dispatch(setIsloading(true));
|
||||
getCashCollectedSplit({ pageNo, pageSize: 10 })
|
||||
.then((res) => {
|
||||
const cashData = res?.data;
|
||||
setPaginationDetails(res?.pages);
|
||||
const cashCollected = getCashCollectedData(cashData, caseDetailsIds);
|
||||
if (res?.pages?.pageNo === 0) {
|
||||
dispatch(setCashCollectedData(cashCollected));
|
||||
return;
|
||||
}
|
||||
dispatch(setCashCollectedData([...cashCollectedData.data, ...cashCollected]));
|
||||
})
|
||||
.catch((err) => {
|
||||
logError(err);
|
||||
})
|
||||
.finally(() => {
|
||||
dispatch(setIsloading(true));
|
||||
callbackFn && callbackFn();
|
||||
});
|
||||
dispatch(
|
||||
getCashCollectedSplit(
|
||||
{ pageNo, pageSize: 10 },
|
||||
caseDetailsIds,
|
||||
cashCollectedData,
|
||||
setPaginationDetails,
|
||||
callbackFn
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
const fetchMoreData = () => {
|
||||
|
||||
@@ -74,7 +74,7 @@ const persistConfig = {
|
||||
'profile',
|
||||
'foregroundService',
|
||||
],
|
||||
blackList: ['case', 'filters'],
|
||||
blackList: ['case', 'filters', 'agentPerformance'],
|
||||
};
|
||||
|
||||
const persistedReducer = persistReducer(persistConfig, rootReducer);
|
||||
|
||||
Reference in New Issue
Block a user