-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35412 from JKobrynski/migrateConnectBankAccountBu…
…ttonToTypeScript [TS migration] Migrate 'ConnectBankAccountButton.js' component to TypeScript
- Loading branch information
Showing
2 changed files
with
47 additions
and
57 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |