Skip to content

Commit

Permalink
Merge pull request #43087 from tienifr/fix/42925
Browse files Browse the repository at this point in the history
fix User is able to add new tax rate using deep link
  • Loading branch information
puneetlath authored Jun 5, 2024
2 parents 47d5f5f + 6607dd8 commit 359ca01
Showing 1 changed file with 44 additions and 40 deletions.
84 changes: 44 additions & 40 deletions src/pages/workspace/taxes/WorkspaceCreateTaxPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type {StackScreenProps} from '@react-navigation/stack';
import React, {useCallback} from 'react';
import {View} from 'react-native';
import AmountPicker from '@components/AmountPicker';
import FullPageNotFoundView from '@components/BlockingViews/FullPageNotFoundView';
import FormProvider from '@components/Form/FormProvider';
import InputWrapper from '@components/Form/InputWrapper';
import type {FormInputErrors, FormOnyxValues} from '@components/Form/types';
Expand All @@ -14,6 +15,7 @@ import useThemeStyles from '@hooks/useThemeStyles';
import {createPolicyTax, getNextTaxCode, getTaxValueWithPercentage, validateTaxName, validateTaxValue} from '@libs/actions/TaxRate';
import Navigation from '@libs/Navigation/Navigation';
import type {SettingsNavigatorParamList} from '@libs/Navigation/types';
import * as PolicyUtils from '@libs/PolicyUtils';
import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper';
import type {WithPolicyAndFullscreenLoadingProps} from '@pages/workspace/withPolicyAndFullscreenLoading';
import withPolicyAndFullscreenLoading from '@pages/workspace/withPolicyAndFullscreenLoading';
Expand Down Expand Up @@ -71,46 +73,48 @@ function WorkspaceCreateTaxPage({
includeSafeAreaPaddingBottom={false}
style={[styles.defaultModalContainer]}
>
<View style={[styles.h100, styles.flex1, styles.justifyContentBetween]}>
<HeaderWithBackButton title={translate('workspace.taxes.addRate')} />
<FormProvider
style={[styles.flexGrow1, styles.mh5]}
formID={ONYXKEYS.FORMS.WORKSPACE_NEW_TAX_FORM}
onSubmit={submitForm}
validate={validateForm}
submitButtonText={translate('common.save')}
enabledWhenOffline
shouldValidateOnBlur={false}
disablePressOnEnter={false}
>
<View style={styles.mhn5}>
<InputWrapper
InputComponent={TextPicker}
inputID={INPUT_IDS.NAME}
label={translate('common.name')}
description={translate('common.name')}
rightLabel={translate('common.required')}
accessibilityLabel={translate('workspace.editor.nameInputLabel')}
maxLength={CONST.TAX_RATES.NAME_MAX_LENGTH}
multiline={false}
role={CONST.ROLE.PRESENTATION}
/>
<InputWrapper
InputComponent={AmountPicker}
inputID={INPUT_IDS.VALUE}
title={(v) => (v ? getTaxValueWithPercentage(v) : '')}
description={translate('workspace.taxes.value')}
rightLabel={translate('common.required')}
hideCurrencySymbol
// The default currency uses 2 decimal places, so we substract it
extraDecimals={CONST.MAX_TAX_RATE_DECIMAL_PLACES - 2}
// We increase the amount max length to support the extra decimals.
amountMaxLength={CONST.MAX_TAX_RATE_DECIMAL_PLACES + CONST.MAX_TAX_RATE_INTEGER_PLACES}
extraSymbol={<Text style={styles.iouAmountText}>%</Text>}
/>
</View>
</FormProvider>
</View>
<FullPageNotFoundView shouldShow={PolicyUtils.hasAccountingConnections(policy)}>
<View style={[styles.h100, styles.flex1, styles.justifyContentBetween]}>
<HeaderWithBackButton title={translate('workspace.taxes.addRate')} />
<FormProvider
style={[styles.flexGrow1, styles.mh5]}
formID={ONYXKEYS.FORMS.WORKSPACE_NEW_TAX_FORM}
onSubmit={submitForm}
validate={validateForm}
submitButtonText={translate('common.save')}
enabledWhenOffline
shouldValidateOnBlur={false}
disablePressOnEnter={false}
>
<View style={styles.mhn5}>
<InputWrapper
InputComponent={TextPicker}
inputID={INPUT_IDS.NAME}
label={translate('common.name')}
description={translate('common.name')}
rightLabel={translate('common.required')}
accessibilityLabel={translate('workspace.editor.nameInputLabel')}
maxLength={CONST.TAX_RATES.NAME_MAX_LENGTH}
multiline={false}
role={CONST.ROLE.PRESENTATION}
/>
<InputWrapper
InputComponent={AmountPicker}
inputID={INPUT_IDS.VALUE}
title={(v) => (v ? getTaxValueWithPercentage(v) : '')}
description={translate('workspace.taxes.value')}
rightLabel={translate('common.required')}
hideCurrencySymbol
// The default currency uses 2 decimal places, so we substract it
extraDecimals={CONST.MAX_TAX_RATE_DECIMAL_PLACES - 2}
// We increase the amount max length to support the extra decimals.
amountMaxLength={CONST.MAX_TAX_RATE_DECIMAL_PLACES + CONST.MAX_TAX_RATE_INTEGER_PLACES}
extraSymbol={<Text style={styles.iouAmountText}>%</Text>}
/>
</View>
</FormProvider>
</View>
</FullPageNotFoundView>
</ScreenWrapper>
</AccessOrNotFoundWrapper>
);
Expand Down

0 comments on commit 359ca01

Please sign in to comment.