diff --git a/src/common/TrackingComponent.tsx b/src/common/TrackingComponent.tsx index b089e0d5..e5249798 100644 --- a/src/common/TrackingComponent.tsx +++ b/src/common/TrackingComponent.tsx @@ -80,19 +80,13 @@ const TrackingComponent: React.FC = ({ children }) => { const isOnline = useIsOnline(); const dispatch = useAppDispatch(); const appState = useRef(AppState.currentState); - const { - isTeamLead, - caseSyncLock, - referenceId, - pendingList = [], - pinnedList = [], - } = useAppSelector((state) => ({ - isTeamLead: state.user.isTeamLead, - caseSyncLock: state?.user?.caseSyncLock, - referenceId: state.user.user?.referenceId!, - pendingList: state.allCases.pendingList, - pinnedList: state.allCases.pinnedList, - })); + + const isTeamLead = useAppSelector((state) => state.user.isTeamLead); + const caseSyncLock = useAppSelector((state) => state?.user?.caseSyncLock); + const referenceId = useAppSelector((state) => state.user.user?.referenceId!); + const pendingList = useAppSelector((state) => state.allCases.pendingList); + const pinnedList = useAppSelector((state) => state.allCases.pinnedList); + const handleTimeSync = async () => { try { diff --git a/src/hooks/useFirestoreUpdates.ts b/src/hooks/useFirestoreUpdates.ts index 6703ffab..a6eb9d7f 100644 --- a/src/hooks/useFirestoreUpdates.ts +++ b/src/hooks/useFirestoreUpdates.ts @@ -35,14 +35,19 @@ export const loggedOutCurrentUser = async () => { const isUserSignedIn = () => !!auth().currentUser; const useFirestoreUpdates = () => { - const { - user: { user, isLoggedIn, sessionDetails, lock, selectedAgent = MY_CASE_ITEM, isExternalAgent }, - allCases: { caseDetails, casesList }, - } = useAppSelector((state: RootState) => ({ - user: state.user || {}, - allCases: state.allCases, - })); const isTeamLead = useAppSelector((state) => state.user.isTeamLead); + const caseDetails = useAppSelector((state) => state.allCases.caseDetails); + const casesList = useAppSelector((state) => state.allCases.casesList); + + const userData = useAppSelector((state) => state.user); + const { + user, + isLoggedIn, + sessionDetails, + lock, + selectedAgent = MY_CASE_ITEM, + isExternalAgent, + } = userData || {}; const lockRef = useRef(null); useEffect(() => { @@ -260,7 +265,7 @@ const useFirestoreUpdates = () => { }; const subscribeToCsaFilters = () => { - const collectionPath = "global-filters/v1"; + const collectionPath = 'global-filters/v1'; return subscribeToDoc(handleCsaFilters, collectionPath); }; diff --git a/src/hooks/useScreenshotTracking.ts b/src/hooks/useScreenshotTracking.ts index 057061e7..063fa049 100644 --- a/src/hooks/useScreenshotTracking.ts +++ b/src/hooks/useScreenshotTracking.ts @@ -7,10 +7,8 @@ import ScreenshotBlocker from '../components/utlis/ScreenshotBlocker'; import { addClickstreamEvent } from '../services/clickstreamEventService'; const useScreenshotTracking = () => { - const { user, allCases } = useAppSelector((state) => ({ - user: state.user, - allCases: state.allCases, - })); + const user = useAppSelector((state) => state.user); + const selectedCaseId = useAppSelector((state) => state.allCases.selectedCaseId); const screenshotEventEmitter = useMemo(() => new NativeEventEmitter(ScreenshotBlocker), []); @@ -25,7 +23,7 @@ const useScreenshotTracking = () => { if (event?.isScreenshotDetected) { addClickstreamEvent(CLICKSTREAM_EVENT_NAMES.FA_SCREENSHOT_TAKEN, { userId: user?.user?.referenceId ?? '', - caseId: allCases.selectedCaseId ?? '', + caseId: selectedCaseId ?? '', page: getCurrentScreen()?.name, }); return; @@ -36,7 +34,7 @@ const useScreenshotTracking = () => { return () => { if (screenshotTakenSubscription) screenshotTakenSubscription.remove(); }; - }, [allCases?.selectedCaseId, user?.user?.referenceId]); + }, [selectedCaseId, user?.user?.referenceId]); }; export default useScreenshotTracking; diff --git a/src/screens/allCases/CasesActionButtons.tsx b/src/screens/allCases/CasesActionButtons.tsx index da0b0a7a..959b840f 100644 --- a/src/screens/allCases/CasesActionButtons.tsx +++ b/src/screens/allCases/CasesActionButtons.tsx @@ -23,21 +23,17 @@ import { VisitPlanStatus } from '../../reducer/userSlice'; export const CasesActionButtons: React.FC = () => { const dispatch = useAppDispatch(); - const { - allCases: { - newlyPinnedCases, - selectedTodoListCount, - selectedTodoListMap, - casesList, - caseDetails, - visitPlansUpdating, - pinnedList, - }, - isLockedVisitPlanStatus, - } = useAppSelector((state: RootState) => ({ - allCases: state.allCases, - isLockedVisitPlanStatus: state.user?.lock?.visitPlanStatus === VisitPlanStatus.LOCKED, - })); + const isLockedVisitPlanStatus = useAppSelector( + (state: RootState) => state.user?.lock?.visitPlanStatus === VisitPlanStatus.LOCKED + ); + const newlyPinnedCases = useAppSelector((state) => state.allCases.newlyPinnedCases); + const pinnedList = useAppSelector((state) => state.allCases.pinnedList); + const selectedTodoListCount = useAppSelector((state) => state.allCases.selectedTodoListCount); + const selectedTodoListMap = useAppSelector((state) => state.allCases.selectedTodoListMap); + const casesList = useAppSelector((state) => state.allCases.casesList); + const caseDetails = useAppSelector((state) => state.allCases.caseDetails); + const visitPlansUpdating = useAppSelector((state) => state.allCases.visitPlansUpdating); + const isOnline = useIsOnline(); const currentRoute = useCurrentRoute(); diff --git a/src/screens/caseDetails/interactionsHandler.tsx b/src/screens/caseDetails/interactionsHandler.tsx index 74262a27..1b271868 100644 --- a/src/screens/caseDetails/interactionsHandler.tsx +++ b/src/screens/caseDetails/interactionsHandler.tsx @@ -23,13 +23,12 @@ export const getUnSyncedCase = (updatedCaseDetail: CaseDetail | undefined): any const interactionsHandler = () => { const dispatch = useAppDispatch(); const isOnline = useIsOnline(); - const { allCasesDetails, docsToBeUploaded } = useAppSelector((state) => ({ - allCasesDetails: state.allCases.caseDetails, - docsToBeUploaded: state.feedbackImages.docsToBeUploaded, - })); - const { templateId } = useAppSelector( - (state) => state.case.templateData[CaseAllocationType.ADDRESS_VERIFICATION_CASE] || {} + const allCasesDetails = useAppSelector((state) => state.allCases.caseDetails); + const docsToBeUploaded = useAppSelector((state) => state.feedbackImages.docsToBeUploaded); + const templateData = useAppSelector( + (state) => state.case.templateData[CaseAllocationType.ADDRESS_VERIFICATION_CASE] ); + const { templateId } = templateData || {}; useEffect(() => { addClickstreamEvent(CLICKSTREAM_EVENT_NAMES.AV_NETWORK_STATUS_CHANGE, { isOnline }); diff --git a/src/screens/dailyCommitment/DailyCommitmentBottomSheet.tsx b/src/screens/dailyCommitment/DailyCommitmentBottomSheet.tsx index 9a0d3277..bff53d9b 100644 --- a/src/screens/dailyCommitment/DailyCommitmentBottomSheet.tsx +++ b/src/screens/dailyCommitment/DailyCommitmentBottomSheet.tsx @@ -1,4 +1,4 @@ -import { Keyboard, SafeAreaView, View, StyleSheet, TouchableOpacity } from 'react-native'; +import { Keyboard, SafeAreaView, View, StyleSheet } from 'react-native'; import React, { useEffect, useState } from 'react'; import Text from '../../../RN-UI-LIB/src/components/Text'; import TextInput, { TextInputMaskType } from '../../../RN-UI-LIB/src/components/TextInput'; diff --git a/src/screens/filteredCases/index.tsx b/src/screens/filteredCases/index.tsx index e95de544..b32ad01a 100644 --- a/src/screens/filteredCases/index.tsx +++ b/src/screens/filteredCases/index.tsx @@ -7,7 +7,9 @@ import { useAppDispatch, useAppSelector } from '../../hooks'; import CasesList from '../allCases/CasesList'; const FilteredCases = () => { - const { pendingList, pinnedList, completedList } = useAppSelector((state) => state.allCases); + const pendingList = useAppSelector((state) => state.allCases.pendingList); + const pinnedList = useAppSelector((state) => state.allCases.pinnedList); + const completedList = useAppSelector((state) => state.allCases.completedList); const caseType = useAppSelector((state) => state.agentPerformance?.filteredListToast?.caseType); const dispatch = useAppDispatch();