Skip to content

Commit

Permalink
Fixed subrate page
Browse files Browse the repository at this point in the history
  • Loading branch information
shubham1206agra committed Jan 7, 2025
1 parent e3cde6d commit c3688b4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 2 additions & 0 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2303,6 +2303,8 @@ const CONST = {

IOU: {
MAX_RECENT_REPORTS_TO_SHOW: 5,
// This will guranatee that the quantity input will not exceed 9,007,199,254,740,991 (Number.MAX_SAFE_INTEGER).
QUANTITY_MAX_LENGTH: 12,
// This is the transactionID used when going through the create expense flow so that it mimics a real transaction (like the edit flow)
OPTIMISTIC_TRANSACTION_ID: '1',
// Note: These payment types are used when building IOU reportAction message values in the server and should
Expand Down
12 changes: 6 additions & 6 deletions src/pages/iou/request/step/IOURequestStepSubrate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,12 @@ function IOURequestStepSubrate({
const quantityValue = String(values[`quantity${pageIndex}`] ?? '');
const subrateValue = values[`subrate${pageIndex}`] ?? '';
const quantityInt = parseInt(quantityValue, 10);
if (quantityValue === '') {
ErrorUtils.addErrorMessage(errors, `quantity${pageIndex}`, translate('common.error.fieldRequired'));
}
if (subrateValue === '' || !validOptions.some(({value}) => value === subrateValue)) {
ErrorUtils.addErrorMessage(errors, `subrate${pageIndex}`, translate('common.error.fieldRequired'));
}
if (Number.isNaN(quantityInt)) {
if (quantityValue === '') {
ErrorUtils.addErrorMessage(errors, `quantity${pageIndex}`, translate('common.error.fieldRequired'));
} else if (Number.isNaN(quantityInt)) {
ErrorUtils.addErrorMessage(errors, `quantity${pageIndex}`, translate('iou.error.invalidQuantity'));
} else if (quantityInt <= 0) {
ErrorUtils.addErrorMessage(errors, `quantity${pageIndex}`, translate('iou.error.quantityGreaterThanZero'));
Expand Down Expand Up @@ -204,8 +203,8 @@ function IOURequestStepSubrate({
enabledWhenOffline
validate={validate}
onSubmit={submit}
shouldValidateOnChange={false}
shouldValidateOnBlur={false}
shouldValidateOnChange
shouldValidateOnBlur
submitButtonText={translate('common.save')}
>
<Text style={[styles.pv3]}>{translate('iou.subrateSelection')}</Text>
Expand All @@ -226,6 +225,7 @@ function IOURequestStepSubrate({
label={translate('iou.quantity')}
defaultValue={currentSubrate?.quantity ? String(currentSubrate.quantity) : undefined}
inputMode={CONST.INPUT_MODE.NUMERIC}
maxLength={CONST.IOU.QUANTITY_MAX_LENGTH}
/>
</FormProvider>
</FullPageNotFoundView>
Expand Down

0 comments on commit c3688b4

Please sign in to comment.