Skip to content

Commit

Permalink
Merge pull request #35412 from JKobrynski/migrateConnectBankAccountBu…
Browse files Browse the repository at this point in the history
…ttonToTypeScript

[TS migration] Migrate 'ConnectBankAccountButton.js' component to TypeScript
  • Loading branch information
cristipaval authored Feb 9, 2024
2 parents e6147ae + 766892f commit f491194
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 57 deletions.
57 changes: 0 additions & 57 deletions src/components/ConnectBankAccountButton.js

This file was deleted.

47 changes: 47 additions & 0 deletions src/components/ConnectBankAccountButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import React from 'react';
import type {StyleProp, ViewStyle} from 'react-native';
import {View} from 'react-native';
import useLocalize from '@hooks/useLocalize';
import useNetwork from '@hooks/useNetwork';
import useThemeStyles from '@hooks/useThemeStyles';
import Navigation from '@libs/Navigation/Navigation';
import * as ReimbursementAccount from '@userActions/ReimbursementAccount';
import Button from './Button';
import * as Expensicons from './Icon/Expensicons';
import Text from './Text';

type ConnectBankAccountButtonProps = {
/** PolicyID for navigating to bank account route of that policy */
policyID: string;

/** Button styles, also applied for offline message wrapper */
style?: StyleProp<ViewStyle>;
};

function ConnectBankAccountButton({style, policyID}: ConnectBankAccountButtonProps) {
const styles = useThemeStyles();
const {isOffline} = useNetwork();
const {translate} = useLocalize();
const activeRoute = Navigation.getActiveRouteWithoutParams();

return isOffline ? (
<View style={style}>
<Text>{`${translate('common.youAppearToBeOffline')} ${translate('common.thisFeatureRequiresInternet')}`}</Text>
</View>
) : (
<Button
text={translate('workspace.common.connectBankAccount')}
onPress={() => ReimbursementAccount.navigateToBankAccountRoute(policyID, activeRoute)}
icon={Expensicons.Bank}
style={style}
iconStyles={styles.buttonCTAIcon}
shouldShowRightIcon
large
success
/>
);
}

ConnectBankAccountButton.displayName = 'ConnectBankAccountButton';

export default ConnectBankAccountButton;

0 comments on commit f491194

Please sign in to comment.