From 4356c192f19e4809974ad7423ea02abc131f9e3d Mon Sep 17 00:00:00 2001 From: yashmantri Date: Fri, 6 Sep 2024 16:03:51 +0530 Subject: [PATCH] TP-71465 | JS Crash fixes --- src/components/form/components/DateInput.tsx | 5 +-- src/components/form/components/TimeInput.tsx | 5 +-- .../GeolocationContainer.tsx | 32 +++++++++---------- 3 files changed, 18 insertions(+), 24 deletions(-) diff --git a/src/components/form/components/DateInput.tsx b/src/components/form/components/DateInput.tsx index 3e5be722..81095d96 100644 --- a/src/components/form/components/DateInput.tsx +++ b/src/components/form/components/DateInput.tsx @@ -41,10 +41,7 @@ export enum DateValue { const DateInput: React.FC = (props) => { const { questionId, error, sectionId, widgetId, caseId, questionType } = props; - const caseType = useAppSelector( - (state) => - state.allCases.caseDetails[caseId]?.caseType || CaseAllocationType.ADDRESS_VERIFICATION_CASE - ); + const caseType = CaseAllocationType.COLLECTION_CASE; const template = useAppSelector((state) => state.case.templateData[caseType]); const question = template.questions[questionId as keyof typeof template.questions]; diff --git a/src/components/form/components/TimeInput.tsx b/src/components/form/components/TimeInput.tsx index 9838ed4e..c4255c21 100644 --- a/src/components/form/components/TimeInput.tsx +++ b/src/components/form/components/TimeInput.tsx @@ -33,10 +33,7 @@ const DEFAULT_TIME = '09:00'; const TimeInput: React.FC = (props) => { const { questionId, error, sectionId, widgetId, caseId, questionType } = props; - const caseType = useAppSelector( - (state) => - state.allCases.caseDetails[caseId]?.caseType || CaseAllocationType.ADDRESS_VERIFICATION_CASE - ); + const caseType = CaseAllocationType.COLLECTION_CASE; const template = useAppSelector((state) => state.case.templateData[caseType]); const question = template.questions[questionId as keyof typeof template.questions]; diff --git a/src/screens/addressGeolocation/GeolocationContainer.tsx b/src/screens/addressGeolocation/GeolocationContainer.tsx index 1a42baf5..4d7176f8 100644 --- a/src/screens/addressGeolocation/GeolocationContainer.tsx +++ b/src/screens/addressGeolocation/GeolocationContainer.tsx @@ -41,25 +41,10 @@ const GeolocationContainer: React.FC = ({ }); }, []); - if (!geolocationList?.length) { - return ( - - - No geo location found - - ); - } - const { nearbyLocations, farAwayLocations } = useMemo(() => { const nearbyLocations: IGeolocation[] = []; const farAwayLocations: IGeolocation[] = []; - geolocationList.forEach((geolocation: IGeolocation) => { + geolocationList?.forEach((geolocation: IGeolocation) => { const distance = getDistanceFromLatLonInKm(currentGeolocationCoordinates, { latitude: geolocation?.latitude, longitude: geolocation?.longitude, @@ -89,6 +74,21 @@ const GeolocationContainer: React.FC = ({ }); }; + if (!geolocationList?.length) { + return ( + + + No geo location found + + ); + } + return ( {nearbyLocations?.length ? (