diff --git a/src/components/form/index.tsx b/src/components/form/index.tsx index 2b1a2759..d771a642 100644 --- a/src/components/form/index.tsx +++ b/src/components/form/index.tsx @@ -42,6 +42,8 @@ import { CaseDetailStackEnum } from '@screens/caseDetails/CaseDetailStack'; import { useNavigation, useRoute } from '@react-navigation/native'; import { NUDGE_BOTTOM_SHEET_DEFAULT_STATE } from './constants'; import {useBackHandler} from "@hooks/useBackHandler"; +import { CALLING_NUDGE } from '@screens/caseDetails/CallingFlow/constants'; +import { isFunction } from '@components/utlis/commonFunctions'; interface IWidget { route: { @@ -50,6 +52,7 @@ interface IWidget { caseId: string; journey: string; handleCloseRouting: GenericFunctionArgs; + from?: string; }; }; } @@ -66,7 +69,7 @@ const Widget: React.FC = (props) => { const isOnline = useIsOnline(); const [isSubmitting, setIsSubmitting] = useState(false); const { params } = props.route; - const { caseId, journey, handleCloseRouting } = params; + const { caseId, journey, handleCloseRouting, from } = params; const caseKey = useRef(''); const disableFormInteractionUpdate = useRef(false); @@ -192,6 +195,7 @@ const Widget: React.FC = (props) => { journey: journey, caseId, handleCloseRouting, + from }); }; @@ -211,10 +215,15 @@ const Widget: React.FC = (props) => { const onSuccessfulSubmit = (data: any, interactionId: string, nextActions?: any) => { setIsSubmitting(false); setNudgeBottomSheetDetails(NUDGE_BOTTOM_SHEET_DEFAULT_STATE); - navigateToScreen(CaseDetailStackEnum.COLLECTION_CASE_DETAIL, { - journey: journey, - caseId, - }); + + if (from === CALLING_NUDGE && isFunction(handleCloseRouting)) { + handleCloseRouting(); + } else { + navigateToScreen(CaseDetailStackEnum.COLLECTION_CASE_DETAIL, { + journey: journey, + caseId, + }); + } dispatch( deleteJourney({ caseId, @@ -247,12 +256,12 @@ const Widget: React.FC = (props) => { } ); fetchLocation().then((location) => { - if (location) { - return handleSubmitJourney(data, location); - } + if (location) { + return handleSubmitJourney(data, location); + } }).catch((err) => { - setIsSubmitting(false); - }); + setIsSubmitting(false); + }); }; const onErrorSubmit = (errObj: GenericType, data?: GenericType, interactionId?: string) => { diff --git a/src/screens/caseDetails/CallingFlow/BottomSheets/CallingFeedbackNudgeBottomSheet.tsx b/src/screens/caseDetails/CallingFlow/BottomSheets/CallingFeedbackNudgeBottomSheet.tsx index 997c3f2a..f90d9fff 100644 --- a/src/screens/caseDetails/CallingFlow/BottomSheets/CallingFeedbackNudgeBottomSheet.tsx +++ b/src/screens/caseDetails/CallingFlow/BottomSheets/CallingFeedbackNudgeBottomSheet.tsx @@ -23,6 +23,7 @@ import { PageRouteEnum } from '@screens/auth/ProtectedRouter'; import { updatePreDefinedCaseFormJourney } from '@reducers/caseReducer'; import { syncFeedbackNudgeDetails } from '@actions/callRecordingActions'; import useMobileNumbers from '@hooks/useMobileNumbers'; +import { CALLING_NUDGE } from '../constants'; const CallingFeedbackNudgeBottomSheet = () => { const showCallingFeedbackNudgeBottomSheet = @@ -92,6 +93,7 @@ const CallingFeedbackNudgeBottomSheet = () => { caseId, journey: TaskTitleUIMapping.COLLECTION_FEEDBACK, handleCloseRouting: () => navigateToScreen(currentScreenName, params), + from: CALLING_NUDGE }, }); } diff --git a/src/screens/caseDetails/CallingFlow/constants.ts b/src/screens/caseDetails/CallingFlow/constants.ts index fec1f961..e66872ea 100644 --- a/src/screens/caseDetails/CallingFlow/constants.ts +++ b/src/screens/caseDetails/CallingFlow/constants.ts @@ -10,3 +10,5 @@ export const CALL_CUSTOMER_TABS = [ label: 'Call history', }, ]; + +export const CALLING_NUDGE = 'CALLING_NUDGE';