Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

30714 Error and block submit when you can't hold request #37477

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ export default {
acceptTerms: 'You must accept the Terms of Service to continue',
phoneNumber: `Please enter a valid phone number, with the country code (e.g. ${CONST.EXAMPLE_PHONE_NUMBER})`,
fieldRequired: 'This field is required.',
transactionModified: 'This transaction has been modified',
characterLimit: ({limit}: CharacterLimitParams) => `Exceeds the maximum length of ${limit} characters`,
characterLimitExceedCounter: ({length, limit}) => `Character limit exceeded (${length}/${limit})`,
dateInvalid: 'Please select a valid date',
Expand Down
15 changes: 13 additions & 2 deletions src/pages/iou/HoldReasonPage.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type {RouteProp} from '@react-navigation/native';
import React, {useCallback} from 'react';
import React, {useCallback, useEffect} from 'react';
import {View} from 'react-native';
import FormProvider from '@components/Form/FormProvider';
import InputWrapper from '@components/Form/InputWrapper';
Expand All @@ -11,9 +11,11 @@ import TextInput from '@components/TextInput';
import useLocalize from '@hooks/useLocalize';
import useThemeStyles from '@hooks/useThemeStyles';
import Navigation from '@libs/Navigation/Navigation';
import * as ReportUtils from '@libs/ReportUtils';
import * as ValidationUtils from '@libs/ValidationUtils';
import * as FormActions from '@userActions/FormActions';
import * as IOU from '@userActions/IOU';
import type ONYXKEYS from '@src/ONYXKEYS';
import ONYXKEYS from '@src/ONYXKEYS';
import type {Route} from '@src/ROUTES';
import INPUT_IDS from '@src/types/form/MoneyRequestHoldReasonForm';

Expand Down Expand Up @@ -44,6 +46,10 @@ function HoldReasonPage({route}: HoldReasonPageProps) {
};

const onSubmit = (values: FormOnyxValues<typeof ONYXKEYS.FORMS.MONEY_REQUEST_HOLD_FORM>) => {
if (!ReportUtils.isReportApproved(reportID) && !ReportUtils.isSettled(reportID)) {
FormActions.setErrors(ONYXKEYS.FORMS.MONEY_REQUEST_HOLD_FORM, {reportModified: translate('common.error.transactionModified')});
return;
}
IOU.putOnHold(transactionID, values.comment, reportID);
navigateBack();
};
Expand All @@ -58,6 +64,11 @@ function HoldReasonPage({route}: HoldReasonPageProps) {
return errors;
}, []);

useEffect(() => {
FormActions.clearErrors(ONYXKEYS.FORMS.MONEY_REQUEST_HOLD_FORM);
FormActions.clearErrorFields(ONYXKEYS.FORMS.MONEY_REQUEST_HOLD_FORM);
}, []);

return (
<ScreenWrapper
includeSafeAreaPaddingBottom={false}
Expand Down
Loading