Skip to content

Commit

Permalink
adress review
Browse files Browse the repository at this point in the history
  • Loading branch information
kosmydel committed Mar 15, 2024
1 parent 46da5b0 commit 5d6fb5e
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 47 deletions.
4 changes: 2 additions & 2 deletions src/ROUTES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -598,11 +598,11 @@ const ROUTES = {
getRoute: (policyID: string, accountID: number, backTo?: string) => getUrlWithBackToParam(`settings/workspaces/${policyID}/members/${accountID}/role-selection`, backTo),
},
WORKSPACE_TAXES_NEW: {
route: 'workspace/:policyID/taxes/new',
route: 'settings/workspaces/:policyID/taxes/new',
getRoute: (policyID: string) => `workspace/${policyID}/taxes/new` as const,
},
WORKSPACE_DISTANCE_RATES: {
route: 'workspace/:policyID/distance-rates',
route: 'settings/workspaces/:policyID/distance-rates',
getRoute: (policyID: string) => `workspace/${policyID}/distance-rates` as const,
},
// Referral program promotion
Expand Down
82 changes: 44 additions & 38 deletions src/pages/workspace/taxes/WorkspaceNewTaxPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import {createWorkspaceTax, getNextTaxID, getTaxValueWithPercentage} from '@libs
import Navigation from '@libs/Navigation/Navigation';
import type {SettingsNavigatorParamList} from '@libs/Navigation/types';
import * as ValidationUtils from '@libs/ValidationUtils';
import AdminPolicyAccessOrNotFoundWrapper from '@pages/workspace/AdminPolicyAccessOrNotFoundWrapper';
import PaidPolicyAccessOrNotFoundWrapper from '@pages/workspace/PaidPolicyAccessOrNotFoundWrapper';
import type {WithPolicyAndFullscreenLoadingProps} from '@pages/workspace/withPolicyAndFullscreenLoading';
import withPolicyAndFullscreenLoading from '@pages/workspace/withPolicyAndFullscreenLoading';
import CONST from '@src/CONST';
Expand Down Expand Up @@ -67,45 +69,49 @@ function WorkspaceNewTaxPage({
);

return (
<ScreenWrapper testID={WorkspaceNewTaxPage.displayName}>
<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={validate}
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}
autoFocus
/>
<InputWrapper
InputComponent={AmountPicker}
inputID={INPUT_IDS.VALUE}
title={(v) => (v ? getTaxValueWithPercentage(v) : '')}
description={translate('workspace.taxes.value')}
rightLabel={translate('common.required')}
hideCurrencySymbol
extraSymbol={<Text style={styles.iouAmountText}>%</Text>}
/>
<AdminPolicyAccessOrNotFoundWrapper policyID={policyID}>
<PaidPolicyAccessOrNotFoundWrapper policyID={policyID}>
<ScreenWrapper testID={WorkspaceNewTaxPage.displayName}>
<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={validate}
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}
autoFocus
/>
<InputWrapper
InputComponent={AmountPicker}
inputID={INPUT_IDS.VALUE}
title={(v) => (v ? getTaxValueWithPercentage(v) : '')}
description={translate('workspace.taxes.value')}
rightLabel={translate('common.required')}
hideCurrencySymbol
extraSymbol={<Text style={styles.iouAmountText}>%</Text>}
/>
</View>
</FormProvider>
</View>
</FormProvider>
</View>
</ScreenWrapper>
</ScreenWrapper>
</PaidPolicyAccessOrNotFoundWrapper>
</AdminPolicyAccessOrNotFoundWrapper>
);
}

Expand Down
4 changes: 2 additions & 2 deletions src/pages/workspace/taxes/WorkspaceTaxesPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ function WorkspaceTaxesPage({policy, route}: WorkspaceTaxesPageProps) {
),
}))
.sort((a, b) => a.text.localeCompare(b.text)),
[policy?.taxRates?.taxes, textForDefault, selectedTaxesIDs, defaultExternalID, styles, translate, theme.icon],
[policy?.taxRates?.taxes, textForDefault, defaultExternalID, selectedTaxesIDs, styles, theme.icon, translate],
);

const isLoading = !isOffline && taxesList === undefined;
Expand Down Expand Up @@ -134,7 +134,7 @@ function WorkspaceTaxesPage({policy, route}: WorkspaceTaxesPageProps) {
<Button
medium
success
onPress={() => Navigation.navigate(ROUTES.WORKSPACE_TAXES_NEW.getRoute(policy?.id ?? ''))}
onPress={() => Navigation.navigate(ROUTES.WORKSPACE_TAXES_NEW.getRoute(route.params.policyID))}
icon={Expensicons.Plus}
text={translate('workspace.taxes.addRate')}
style={[styles.mr3, isSmallScreenWidth && styles.w50]}
Expand Down
7 changes: 2 additions & 5 deletions src/types/onyx/Policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type DisabledFields = {
reimbursable?: boolean;
};

type TaxRate = {
type TaxRate = OnyxCommon.OnyxValueWithOfflineFeedback<{
/** Name of the a tax rate. */
name: string;

Expand All @@ -48,12 +48,9 @@ type TaxRate = {
/** Indicates if the tax rate is disabled. */
isDisabled?: boolean;

/** The type of action that's pending */
pendingAction?: OnyxCommon.PendingAction;

/** An error message to display to the user */
errors?: OnyxCommon.Errors;
};
}>;

type TaxRates = Record<string, TaxRate>;

Expand Down

0 comments on commit 5d6fb5e

Please sign in to comment.