Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TS migration] Migrate 'ConnectBankAccountButton.js' component to TypeScript #35412

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 0 additions & 57 deletions src/components/ConnectBankAccountButton.js

This file was deleted.

44 changes: 44 additions & 0 deletions src/components/ConnectBankAccountButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
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: string;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add comments (you can reuse the ones that were there before)

style: StyleProp<ViewStyle>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it can be optional

Suggested change
style: StyleProp<ViewStyle>;
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]}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
iconStyles={[styles.buttonCTAIcon]}
iconStyles={styles.buttonCTAIcon}

shouldShowRightIcon
large
success
/>
);
}

ConnectBankAccountButton.displayName = 'ConnectBankAccountButton';

export default ConnectBankAccountButton;
Loading