-
Notifications
You must be signed in to change notification settings - Fork 3k
/
Copy pathWorkspaceProfileCurrencyPage.tsx
53 lines (46 loc) · 2.41 KB
/
WorkspaceProfileCurrencyPage.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
import React from 'react';
import CurrencySelectionList from '@components/CurrencySelectionList';
import type {CurrencyListItem} from '@components/CurrencySelectionList/types';
import HeaderWithBackButton from '@components/HeaderWithBackButton';
import ScreenWrapper from '@components/ScreenWrapper';
import useLocalize from '@hooks/useLocalize';
import Navigation from '@libs/Navigation/Navigation';
import * as PolicyUtils from '@libs/PolicyUtils';
import * as Policy from '@userActions/Policy/Policy';
import CONST from '@src/CONST';
import {isEmptyObject} from '@src/types/utils/EmptyObject';
import AccessOrNotFoundWrapper from './AccessOrNotFoundWrapper';
import type {WithPolicyAndFullscreenLoadingProps} from './withPolicyAndFullscreenLoading';
import withPolicyAndFullscreenLoading from './withPolicyAndFullscreenLoading';
type WorkspaceProfileCurrencyPageProps = WithPolicyAndFullscreenLoadingProps;
function WorkspaceProfileCurrencyPage({policy}: WorkspaceProfileCurrencyPageProps) {
const {translate} = useLocalize();
const onSelectCurrency = (item: CurrencyListItem) => {
Policy.updateGeneralSettings(policy?.id ?? '-1', policy?.name ?? '', item.currencyCode);
Navigation.setNavigationActionToMicrotaskQueue(Navigation.goBack);
};
return (
<AccessOrNotFoundWrapper
policyID={policy?.id ?? '-1'}
accessVariants={[CONST.POLICY.ACCESS_VARIANTS.ADMIN]}
fullPageNotFoundViewProps={{onLinkPress: PolicyUtils.goBackFromInvalidPolicy, subtitleKey: isEmptyObject(policy) ? undefined : 'workspace.common.notAuthorized'}}
>
<ScreenWrapper
includeSafeAreaPaddingBottom={false}
testID={WorkspaceProfileCurrencyPage.displayName}
>
<HeaderWithBackButton
title={translate('workspace.editor.currencyInputLabel')}
onBackButtonPress={() => Navigation.goBack()}
/>
<CurrencySelectionList
searchInputLabel={translate('workspace.editor.currencyInputLabel')}
onSelect={onSelectCurrency}
initiallySelectedCurrencyCode={policy?.outputCurrency}
/>
</ScreenWrapper>
</AccessOrNotFoundWrapper>
);
}
WorkspaceProfileCurrencyPage.displayName = 'WorkspaceProfileCurrencyPage';
export default withPolicyAndFullscreenLoading(WorkspaceProfileCurrencyPage);