From 5d77721dd82931f5729f3b2d27beeacfcb8a71ff Mon Sep 17 00:00:00 2001 From: Varnit Goyal Date: Tue, 4 Feb 2025 16:53:26 +0530 Subject: [PATCH] NTP-34955 | optional chaining for case id (#1083) Co-authored-by: varnit goyal Co-authored-by: yashmantri --- src/action/authActions.ts | 6 +++--- src/components/form/components/PhoneNumberSelection.tsx | 4 ++-- src/screens/caseDetails/CollectionCaseDetail.tsx | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/action/authActions.ts b/src/action/authActions.ts index 932c0c29..ad898b10 100644 --- a/src/action/authActions.ts +++ b/src/action/authActions.ts @@ -85,12 +85,12 @@ export const generateOTP = .catch((err) => { // TODO: Fix status from BE if ( - err.response.status === API_STATUS_CODE.NOT_FOUND || - err.response.status === API_STATUS_CODE.BAD_REQUEST + err?.response?.status === API_STATUS_CODE.NOT_FOUND || + err?.response?.status === API_STATUS_CODE.BAD_REQUEST ) { dispatch(setOTPError('Enter a registered mobile number')); } else { - dispatch(setOTPError(err.response?.data?.message)); + dispatch(setOTPError(err?.response?.data?.message)); } }) .finally(() => dispatch(setFormLoading(false))); diff --git a/src/components/form/components/PhoneNumberSelection.tsx b/src/components/form/components/PhoneNumberSelection.tsx index ae1a7c03..92acde25 100644 --- a/src/components/form/components/PhoneNumberSelection.tsx +++ b/src/components/form/components/PhoneNumberSelection.tsx @@ -54,7 +54,7 @@ const PhoneNumberSelection: React.FC = (props) => { return ( - {question.text}{' '} + {question?.text || ' '} {isQuestionMandatory(question) && *} = (props) => { fallBack={ <> {[...Array(6).keys()].map(() => ( - + ))} } diff --git a/src/screens/caseDetails/CollectionCaseDetail.tsx b/src/screens/caseDetails/CollectionCaseDetail.tsx index 742187a0..c7686072 100644 --- a/src/screens/caseDetails/CollectionCaseDetail.tsx +++ b/src/screens/caseDetails/CollectionCaseDetail.tsx @@ -43,7 +43,7 @@ const CollectionCaseDetails: React.FC = (props) => { params: { caseId, notificationId }, }, } = props; - const caseDetail = useAppSelector((state: RootState) => state.allCases.caseDetails[caseId]) || {}; + const caseDetail = useAppSelector((state: RootState) => state.allCases.caseDetails?.[caseId]) || {}; const isCallActive = useAppSelector( (state: RootState) => state?.activeCall?.activeCallDetails?.callActive );