Files
address-verification-app/src/reducer/agentPerformanceSlice.ts
2023-10-27 15:48:45 +05:30

86 lines
2.1 KiB
TypeScript

import { createSlice } from '@reduxjs/toolkit';
import { CashCollectedData, PerformanceDataType } from '../screens/Dashboard/interface';
interface AgentPerformanceInterface {
performanceData: PerformanceDataType;
cashCollectedData: CashCollectedData;
isGraphExpanded: boolean;
}
const initialState: AgentPerformanceInterface = {
performanceData: {
cases: {
visitedCases: 0,
unvisitedCaseIds: [],
unvisitedCases: 0,
contactableCases: 0,
nonContactableCaseIds: [],
nonContactableCases: 0,
totalPtp: 0,
nonPtpCaseIds: [],
nonPtp: 0,
convertedPtp: 0,
brokenPtpCaseIds: [],
brokenPtp: 0,
totalEmi: 0,
atleastOneEmiCollected: 0,
},
totalCashCollected: 0,
totalCashCollectedCaseIds: [],
performanceLevel: {
currentLevel: 1,
totalLevel: 0,
},
cashCollectedTillDate: {
date: '',
self: 0,
aboveLevel: 0,
belowLevel: 0,
},
cashCollectedGraphData: [],
lastUpdatedAt: 0,
feedbackDetails: {
totalFeedbackCount: 0,
todaysFeedbackCount: 0,
todaysGenuineFeedbackCount: 0,
todaysSuspiciousFeedbackCount: 0,
totalSuspiciousFeedbackCount: 0,
totalGenuineFeedbackCount: 0,
},
},
cashCollectedData: {
data: [],
isLoading: false,
},
isGraphExpanded: false,
};
const agentPerformanceSlice = createSlice({
name: 'agentPerformance',
initialState,
reducers: {
setPerformanceData: (state, action) => {
state.performanceData = action.payload;
},
setCashCollectedData: (state, action) => {
state.cashCollectedData.data = action.payload;
},
setIsloading: (state, action) => {
state.cashCollectedData.isLoading = action.payload;
},
setIsGraphExpanded: (state, action) => {
state.isGraphExpanded = action.payload;
},
resetPerformanceData: () => initialState,
},
});
export const {
setPerformanceData,
setCashCollectedData,
setIsloading,
setIsGraphExpanded,
resetPerformanceData,
} = agentPerformanceSlice.actions;
export default agentPerformanceSlice.reducer;