-
Notifications
You must be signed in to change notification settings - Fork 3.1k
/
Copy pathEditRequestTaxAmountPage.tsx
66 lines (56 loc) · 2.34 KB
/
EditRequestTaxAmountPage.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import {useFocusEffect} from '@react-navigation/native';
import React, {useCallback, useRef} from 'react';
import HeaderWithBackButton from '@components/HeaderWithBackButton';
import ScreenWrapper from '@components/ScreenWrapper';
import useLocalize from '@hooks/useLocalize';
import * as DeviceCapabilities from '@libs/DeviceCapabilities';
import type {BaseTextInputRef} from '@src/components/TextInput/BaseTextInput/types';
import CONST from '@src/CONST';
import MoneyRequestAmountForm from './iou/steps/MoneyRequestAmountForm';
type EditRequestTaxAmountPageProps = {
/** Transaction default amount value */
defaultAmount: number;
/** Transaction default tax amount value */
defaultTaxAmount: number;
/** Transaction default currency value */
defaultCurrency: string;
/** Callback to fire when the Save button is pressed */
onSubmit: () => void;
};
function EditRequestTaxAmountPage({defaultAmount, defaultTaxAmount, defaultCurrency, onSubmit}: EditRequestTaxAmountPageProps) {
const {translate} = useLocalize();
const textInput = useRef<BaseTextInputRef>(null);
const focusTimeoutRef = useRef<NodeJS.Timeout | null>(null);
useFocusEffect(
useCallback(() => {
focusTimeoutRef.current = setTimeout(() => textInput.current && textInput.current.focus(), CONST.ANIMATED_TRANSITION);
return () => {
if (!focusTimeoutRef.current) {
return;
}
clearTimeout(focusTimeoutRef.current);
};
}, []),
);
return (
<ScreenWrapper
includeSafeAreaPaddingBottom={false}
shouldEnableKeyboardAvoidingView={false}
shouldEnableMinHeight={DeviceCapabilities.canUseTouchScreen()}
testID={EditRequestTaxAmountPage.displayName}
>
<HeaderWithBackButton title={translate('iou.taxAmount')} />
<MoneyRequestAmountForm
currency={defaultCurrency}
amount={defaultAmount}
taxAmount={defaultTaxAmount}
ref={textInput}
isCurrencyPressable={false}
onSubmitButtonPress={onSubmit}
isEditing
/>
</ScreenWrapper>
);
}
EditRequestTaxAmountPage.displayName = 'EditRequestTaxAmountPage';
export default EditRequestTaxAmountPage;