Skip to content

Commit

Permalink
Merge pull request Expensify#49224 from Nodebrute/onyxmigration
Browse files Browse the repository at this point in the history
[NO QA]: migrate DeeplinkRedirectLoadingIndicator to useOnyx
  • Loading branch information
roryabraham authored Oct 3, 2024
2 parents 238f978 + c22556d commit 0ff950f
Showing 1 changed file with 6 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from 'react';
import {View} from 'react-native';
import type {OnyxEntry} from 'react-native-onyx';
import {withOnyx} from 'react-native-onyx';
import {useOnyx} from 'react-native-onyx';
import Icon from '@components/Icon';
import * as Expensicons from '@components/Icon/Expensicons';
import * as Illustrations from '@components/Icon/Illustrations';
Expand All @@ -12,23 +11,17 @@ import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import Navigation from '@libs/Navigation/Navigation';
import ONYXKEYS from '@src/ONYXKEYS';
import type * as OnyxTypes from '@src/types/onyx';

type DeeplinkRedirectLoadingIndicatorOnyxProps = {
/** Current user session */
session: OnyxEntry<OnyxTypes.Session>;
};

type DeeplinkRedirectLoadingIndicatorProps = DeeplinkRedirectLoadingIndicatorOnyxProps & {
type DeeplinkRedirectLoadingIndicatorProps = {
/** Opens the link in the browser */
openLinkInBrowser: (value: boolean) => void;
};

function DeeplinkRedirectLoadingIndicator({openLinkInBrowser, session}: DeeplinkRedirectLoadingIndicatorProps) {
function DeeplinkRedirectLoadingIndicator({openLinkInBrowser}: DeeplinkRedirectLoadingIndicatorProps) {
const {translate} = useLocalize();
const theme = useTheme();
const styles = useThemeStyles();

const [currentUserLogin] = useOnyx(ONYXKEYS.SESSION, {selector: (session) => session?.email});
return (
<View style={styles.deeplinkWrapperContainer}>
<View style={styles.deeplinkWrapperMessage}>
Expand All @@ -41,7 +34,7 @@ function DeeplinkRedirectLoadingIndicator({openLinkInBrowser, session}: Deeplink
</View>
<Text style={[styles.textHeadline, styles.textXXLarge]}>{translate('deeplinkWrapper.launching')}</Text>
<View style={[styles.mt2, styles.textAlignCenter]}>
<Text>{translate('deeplinkWrapper.loggedInAs', {email: session?.email ?? ''})}</Text>
<Text>{translate('deeplinkWrapper.loggedInAs', {email: currentUserLogin ?? ''})}</Text>
<Text style={[styles.textAlignCenter]}>
{translate('deeplinkWrapper.doNotSeePrompt')} <TextLink onPress={() => openLinkInBrowser(true)}>{translate('deeplinkWrapper.tryAgain')}</TextLink>
{translate('deeplinkWrapper.or')} <TextLink onPress={() => Navigation.goBack()}>{translate('deeplinkWrapper.continueInWeb')}</TextLink>.
Expand All @@ -62,8 +55,4 @@ function DeeplinkRedirectLoadingIndicator({openLinkInBrowser, session}: Deeplink

DeeplinkRedirectLoadingIndicator.displayName = 'DeeplinkRedirectLoadingIndicator';

export default withOnyx<DeeplinkRedirectLoadingIndicatorProps, DeeplinkRedirectLoadingIndicatorOnyxProps>({
session: {
key: ONYXKEYS.SESSION,
},
})(DeeplinkRedirectLoadingIndicator);
export default DeeplinkRedirectLoadingIndicator;

0 comments on commit 0ff950f

Please sign in to comment.