NTP-14132| added toast on submit post operative hour

This commit is contained in:
aishwarya.srivastava
2024-11-28 00:24:28 +05:30
parent e27b78206e
commit dc624767ec
3 changed files with 26 additions and 22 deletions

View File

@@ -41,7 +41,7 @@ import NavigationHeader, { Icon } from '../../../RN-UI-LIB/src/components/Naviga
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 { useBackHandler } from '@hooks/useBackHandler';
import { CALLING_NUDGE } from '@screens/caseDetails/CallingFlow/constants';
import { isFunction } from '@components/utlis/commonFunctions';
import { handlePostOperativeHourActivity } from '@screens/caseDetails/utils/postOperationalHourActions';
@@ -101,8 +101,10 @@ const Widget: React.FC<IWidget> = (props) => {
}
setIsJourneyFirstScreen(isFirst);
}, [templateData, name]);
const addingNewFeedbackDisabled = useAppSelector((state) => state.postOperationalHourRestrictionsSlice.postOperationalHourRestrictions);
const addingNewFeedbackDisabled = useAppSelector(
(state) => state.postOperationalHourRestrictionsSlice.postOperationalHourRestrictions
);
const [isSubmitButtonDiabled, setIsSubmitButtonDiabled] = useState(false);
useEffect(() => {
@@ -114,7 +116,7 @@ const Widget: React.FC<IWidget> = (props) => {
}, []);
const handleBackPress = useCallback(() => {
if (isSubmitting && ! addingNewFeedbackDisabled) {
if (isSubmitting) {
toast({
type: 'info',
text1: ToastMessages.FEEDBACK_SUBMISSION_UNDER_PROCESS,
@@ -126,13 +128,6 @@ const Widget: React.FC<IWidget> = (props) => {
}, [isSubmitting]);
useBackHandler(handleBackPress);
const handleDisabledButtonClick = () => {
setIsSubmitButtonDiabled(true);
toast({
type: 'error',
text1: 'Submission failed! You can add feedback only during work hours (8 AM to 7 PM)',
})
};
const {
control,
@@ -218,7 +213,7 @@ const Widget: React.FC<IWidget> = (props) => {
journey: journey,
caseId,
handleCloseRouting,
from
from,
});
};
@@ -278,11 +273,13 @@ const Widget: React.FC<IWidget> = (props) => {
widgetId: name,
}
);
fetchLocation().then((location) => {
fetchLocation()
.then((location) => {
if (location) {
return handleSubmitJourney(data, location);
}
}).catch((err) => {
})
.catch((err) => {
setIsSubmitting(false);
});
};
@@ -300,6 +297,13 @@ const Widget: React.FC<IWidget> = (props) => {
suspiciousFeedbackMessage: errObj?.errorCode,
});
}
if (errObj?.statusCode === API_STATUS_CODE.POST_OPERATIVE_HOURS_ACTIVITY) {
toast({
type: 'error',
text1: ToastMessages.POST_OPERATIVE_HOURS_ACTIVITY,
});
if (!addingNewFeedbackDisabled) setIsSubmitButtonDiabled(true);
}
};
const handleSubmitJourney = async (data: any, coords: Geolocation.GeoCoordinates) => {
@@ -328,12 +332,12 @@ const Widget: React.FC<IWidget> = (props) => {
unSyncedCase,
nudgeBottomSheetDetails?.showNudgeBottomSheet
);
if(!transformedPayload?.data?.answers) {
if (!transformedPayload?.data?.answers) {
toast({
type: 'error',
text1: ToastMessages.FEEDBACK_IMAGE_NOT_FOUND,
});
onErrorSubmit({}, transformedPayload)
onErrorSubmit({}, transformedPayload);
return;
}
dispatch(
@@ -387,7 +391,7 @@ const Widget: React.FC<IWidget> = (props) => {
}, []);
const handleCloseIconPress = () => {
if (isSubmitting && !addingNewFeedbackDisabled) {
if (isSubmitting) {
toast({
type: 'info',
text1: ToastMessages.FEEDBACK_SUBMISSION_UNDER_PROCESS,
@@ -485,13 +489,11 @@ const Widget: React.FC<IWidget> = (props) => {
<Button
style={[styles.autoFlex, styles.mH16]}
title={isLeaf ? 'Submit' : 'Next'}
showLoader={isLeaf && isSubmitting && !addingNewFeedbackDisabled}
showLoader={isLeaf && isSubmitting}
disabled={(isLeaf && isSubmitting) || isSubmitButtonDiabled}
onPress={
isLeaf
? (addingNewFeedbackDisabled
? handleDisabledButtonClick
: handleSubmit(submitJourneyWithGeoLocation, onError))
? handleSubmit(submitJourneyWithGeoLocation, onError)
: handleSubmit(onSubmit, onError)
}
rightIcon={
@@ -502,7 +504,7 @@ const Widget: React.FC<IWidget> = (props) => {
</View>
<NudgeSuspiciousFeedbackBottomSheet
caseId={caseId}
successBtnLoader={isSubmitting && !addingNewFeedbackDisabled}
successBtnLoader={isSubmitting}
nudgeBottomSheetDetails={nudgeBottomSheetDetails}
setNudgeBottomSheetDetails={setNudgeBottomSheetDetails}
successCallbackFn={handleSubmit(

View File

@@ -227,6 +227,7 @@ export const API_STATUS_CODE = {
INTERNAL_SERVER_ERROR: 500,
TOO_MANY_REQUESTS: 429,
GONE: 410,
POST_OPERATIVE_HOURS_ACTIVITY: 451
};
const API_TIMEOUT_INTERVAL = 2e4; // 20s

View File

@@ -95,6 +95,7 @@ export const ToastMessages = {
WHATSAPP_SHARE_SUCCESS: 'Document shared successfully via WhatsApp',
WHATSAPP_SHARE_FAILURE: 'Document sharing failed via WhatsApp',
ERROR_FETCHING_MULTILINGUAL_DOC : 'Error fetching multilingual document',
POST_OPERATIVE_HOURS_ACTIVITY: 'You can contact customer only during work hours (8 AM to 7 PM)'
};
export enum BOTTOM_TAB_ROUTES {