diff --git a/src/pages/settings/Profile/CustomStatus/VacationDelegatePage.tsx b/src/pages/settings/Profile/CustomStatus/VacationDelegatePage.tsx index 803f08ef3e264..ac36c8d0d733f 100644 --- a/src/pages/settings/Profile/CustomStatus/VacationDelegatePage.tsx +++ b/src/pages/settings/Profile/CustomStatus/VacationDelegatePage.tsx @@ -1,5 +1,6 @@ import React, {useCallback} from 'react'; import BaseVacationDelegateSelectionComponent from '@components/BaseVacationDelegateSelectionComponent'; +import FullPageOfflineBlockingView from '@components/BlockingViews/FullPageOfflineBlockingView'; import {ModalActions} from '@components/Modal/Global/ModalContext'; import ScreenWrapper from '@components/ScreenWrapper'; import useConfirmModal from '@hooks/useConfirmModal'; @@ -21,6 +22,20 @@ function VacationDelegatePage() { const [vacationDelegate] = useOnyx(ONYXKEYS.NVP_PRIVATE_VACATION_DELEGATE); + const showErrorModal = useCallback( + async (message?: string) => { + await showConfirmModal({ + title: translate('common.headsUp'), + prompt: message ?? translate('statusPage.vacationDelegateError'), + confirmText: translate('common.buttonConfirm'), + shouldShowCancelButton: false, + }); + + clearVacationDelegateError(vacationDelegate?.previousDelegate); + }, + [showConfirmModal, translate, vacationDelegate?.previousDelegate], + ); + const showWarningModal = useCallback( async (delegateLogin: string) => { const result = await showConfirmModal({ @@ -56,6 +71,11 @@ function VacationDelegatePage() { return; } + if (response.jsonCode === CONST.JSON_CODE.EXP_ERROR) { + showErrorModal(response.message); + return; + } + if (response.jsonCode === CONST.JSON_CODE.POLICY_DIFF_WARNING) { showWarningModal(option?.login ?? ''); return; @@ -64,7 +84,7 @@ function VacationDelegatePage() { Navigation.goBack(ROUTES.SETTINGS_STATUS); }); }, - [currentUserLogin, vacationDelegate, showWarningModal], + [currentUserLogin, vacationDelegate, showWarningModal, showErrorModal], ); return ( @@ -72,14 +92,16 @@ function VacationDelegatePage() { includeSafeAreaPaddingBottom={false} testID="VacationDelegatePage" > - Navigation.goBack(ROUTES.SETTINGS_STATUS)} - cannotSetDelegateMessage={translate('statusPage.cannotSetVacationDelegate')} - includeCurrentUser={false} - /> + + Navigation.goBack(ROUTES.SETTINGS_STATUS)} + cannotSetDelegateMessage={translate('statusPage.cannotSetVacationDelegate')} + includeCurrentUser={false} + /> + ); }