Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
10 changes: 9 additions & 1 deletion src/libs/Navigation/AppNavigator/AuthScreens.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import useOnboardingFlowRouter from '@hooks/useOnboardingFlow';
import {ReportIDsContextProvider} from '@hooks/useReportIDs';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
import useTheme from '@hooks/useTheme';
import {connect} from '@libs/actions/Delegate';
import setFullscreenVisibility from '@libs/actions/setFullscreenVisibility';
import {READ_COMMANDS} from '@libs/API/types';
import HttpUtils from '@libs/HttpUtils';
Expand Down Expand Up @@ -276,11 +277,14 @@ function AuthScreens({session, lastOpenedPublicRoomID, initialLastUpdateIDApplie
PusherConnectionManager.init();
initializePusher();

const url = new URL(currentUrl);
const delegatorEmail = url.searchParams.get('delegatorEmail') ?? '';

// In Hybrid App we decide to call one of those method when booting ND and we don't want to duplicate calls
if (!CONFIG.IS_HYBRID_APP) {
// If we are on this screen then we are "logged in", but the user might not have "just logged in". They could be reopening the app
// or returning from background. If so, we'll assume they have some app data already and we can call reconnectApp() instead of openApp().
if (SessionUtils.didUserLogInDuringSession()) {
if (SessionUtils.didUserLogInDuringSession() || delegatorEmail) {
App.openApp();
} else {
Log.info('[AuthScreens] Sending ReconnectApp');
Expand All @@ -292,6 +296,10 @@ function AuthScreens({session, lastOpenedPublicRoomID, initialLastUpdateIDApplie

App.setUpPoliciesAndNavigate(session);

if (delegatorEmail) {
connect(delegatorEmail, true);
}

App.redirectThirdPartyDesktopSignIn();

if (lastOpenedPublicRoomID) {
Expand Down
1 change: 1 addition & 0 deletions src/libs/Navigation/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1787,6 +1787,7 @@ type SharedScreensParamList = {
exitTo?: Routes | HybridAppRoute;
shouldForceLogin: string;
domain?: Routes;
delegatorEmail?: string;
};
[SCREENS.VALIDATE_LOGIN]: {
accountID: string;
Expand Down
8 changes: 4 additions & 4 deletions src/libs/actions/Delegate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ const KEYS_TO_PRESERVE_DELEGATE_ACCESS = [
ONYXKEYS.IS_SIDEBAR_LOADED,
];

function connect(email: string) {
if (!delegatedAccess?.delegators) {
function connect(email: string, isFromOldDot = false) {
if (!delegatedAccess?.delegators && !isFromOldDot) {
return;
}

Expand Down Expand Up @@ -142,7 +142,7 @@ function connect(email: string) {
Onyx.update(failureData);
return;
}
if (!activePolicyID) {
if (!activePolicyID && CONFIG.IS_HYBRID_APP) {
Log.alert('[Delegate] Unable to access activePolicyID');
Onyx.update(failureData);
return;
Expand All @@ -159,7 +159,7 @@ function connect(email: string) {
NetworkStore.setAuthToken(response?.restrictedToken ?? null);
confirmReadyToOpenApp();
openApp().then(() => {
if (!CONFIG.IS_HYBRID_APP) {
if (!CONFIG.IS_HYBRID_APP || !policyID) {
return;
}
HybridAppModule.switchAccount({
Expand Down
107 changes: 52 additions & 55 deletions src/pages/settings/ExitSurvey/ExitSurveyBookCall.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from 'react';
import {View} from 'react-native';
import Button from '@components/Button';
import DelegateNoAccessWrapper from '@components/DelegateNoAccessWrapper';
import FixedFooter from '@components/FixedFooter';
import HeaderWithBackButton from '@components/HeaderWithBackButton';
import ScreenWrapper from '@components/ScreenWrapper';
Expand All @@ -10,7 +9,7 @@ import useLocalize from '@hooks/useLocalize';
import useNetwork from '@hooks/useNetwork';
import useThemeStyles from '@hooks/useThemeStyles';
import Navigation from '@navigation/Navigation';
import * as Link from '@userActions/Link';
import {openExternalLink} from '@userActions/Link';
import * as Expensicons from '@src/components/Icon/Expensicons';
import CONST from '@src/CONST';
import ROUTES from '@src/ROUTES';
Expand All @@ -23,60 +22,58 @@ function ExitSurveyBookCallPage() {

return (
<ScreenWrapper testID={ExitSurveyBookCallPage.displayName}>
<DelegateNoAccessWrapper accessDeniedVariants={[CONST.DELEGATE.DENIED_ACCESS_VARIANTS.DELEGATE]}>
<HeaderWithBackButton
title={translate('exitSurvey.header')}
onBackButtonPress={() => Navigation.goBack()}
<HeaderWithBackButton
title={translate('exitSurvey.header')}
onBackButtonPress={() => Navigation.goBack()}
/>
<View style={[styles.flex1, styles.mh5]}>
{isOffline && <ExitSurveyOffline />}
{!isOffline && (
<>
<Text style={[styles.headerAnonymousFooter, styles.mt3]}>{translate('exitSurvey.bookACallTitle')}</Text>
<Text style={[styles.mt2]}>{translate('exitSurvey.bookACallTextTop')}</Text>
<View style={styles.mv4}>
{Object.values(CONST.EXIT_SURVEY.BENEFIT).map((value) => {
return (
<View
key={value}
style={[styles.flexRow]}
>
<View style={styles.liDot} />
<Text>{translate(`exitSurvey.benefits.${value}`)}</Text>
</View>
);
})}
</View>
<Text>{translate('exitSurvey.bookACallTextBottom')}</Text>
</>
)}
</View>
<FixedFooter>
<Button
style={styles.mb3}
large
text={translate('exitSurvey.noThanks')}
onPress={() => {
Navigation.navigate(ROUTES.SETTINGS_EXIT_SURVEY_REASON.getRoute(ROUTES.SETTINGS_EXIT_SURVERY_BOOK_CALL.route));
}}
isDisabled={isOffline}
/>
<View style={[styles.flex1, styles.mh5]}>
{isOffline && <ExitSurveyOffline />}
{!isOffline && (
<>
<Text style={[styles.headerAnonymousFooter, styles.mt3]}>{translate('exitSurvey.bookACallTitle')}</Text>
<Text style={[styles.mt2]}>{translate('exitSurvey.bookACallTextTop')}</Text>
<View style={styles.mv4}>
{Object.values(CONST.EXIT_SURVEY.BENEFIT).map((value) => {
return (
<View
key={value}
style={[styles.flexRow]}
>
<View style={styles.liDot} />
<Text>{translate(`exitSurvey.benefits.${value}`)}</Text>
</View>
);
})}
</View>
<Text>{translate('exitSurvey.bookACallTextBottom')}</Text>
</>
)}
</View>
<FixedFooter>
<Button
style={styles.mb3}
large
text={translate('exitSurvey.noThanks')}
onPress={() => {
Navigation.navigate(ROUTES.SETTINGS_EXIT_SURVEY_REASON.getRoute(ROUTES.SETTINGS_EXIT_SURVERY_BOOK_CALL.route));
}}
isDisabled={isOffline}
/>
<Button
success
large
iconRight={Expensicons.NewWindow}
shouldShowRightIcon
isContentCentered
text={translate('exitSurvey.bookACall')}
pressOnEnter
onPress={() => {
Navigation.dismissModal();
Link.openExternalLink(CONST.EXIT_SURVEY.BOOK_MEETING_LINK);
}}
isDisabled={isOffline}
/>
</FixedFooter>
</DelegateNoAccessWrapper>
<Button
success
large
iconRight={Expensicons.NewWindow}
shouldShowRightIcon
isContentCentered
text={translate('exitSurvey.bookACall')}
pressOnEnter
onPress={() => {
Navigation.dismissModal();
openExternalLink(CONST.EXIT_SURVEY.BOOK_MEETING_LINK);
}}
isDisabled={isOffline}
/>
</FixedFooter>
</ScreenWrapper>
);
}
Expand Down
73 changes: 35 additions & 38 deletions src/pages/settings/ExitSurvey/ExitSurveyConfirmPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {useOnyx} from 'react-native-onyx';
import type {OnyxEntry} from 'react-native-onyx';
import Icon from '@components//Icon';
import Button from '@components/Button';
import DelegateNoAccessWrapper from '@components/DelegateNoAccessWrapper';
import FixedFooter from '@components/FixedFooter';
import HeaderWithBackButton from '@components/HeaderWithBackButton';
import {MushroomTopHat} from '@components/Icon/Illustrations';
Expand All @@ -17,8 +16,8 @@ import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavig
import Navigation from '@navigation/Navigation';
import type {SettingsNavigatorParamList} from '@navigation/types';
import variables from '@styles/variables';
import * as ExitSurvey from '@userActions/ExitSurvey';
import * as Link from '@userActions/Link';
import {switchToOldDot} from '@userActions/ExitSurvey';
import {openOldDotLink} from '@userActions/Link';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
Expand Down Expand Up @@ -61,42 +60,40 @@ function ExitSurveyConfirmPage({route, navigation}: ExitSurveyConfirmPageProps)

return (
<ScreenWrapper testID={ExitSurveyConfirmPage.displayName}>
<DelegateNoAccessWrapper accessDeniedVariants={[CONST.DELEGATE.DENIED_ACCESS_VARIANTS.DELEGATE]}>
<HeaderWithBackButton
title={translate(shouldShowQuickTips ? 'exitSurvey.goToExpensifyClassic' : 'exitSurvey.header')}
onBackButtonPress={() => Navigation.goBack()}
<HeaderWithBackButton
title={translate(shouldShowQuickTips ? 'exitSurvey.goToExpensifyClassic' : 'exitSurvey.header')}
onBackButtonPress={() => Navigation.goBack()}
/>
<View style={[styles.flex1, styles.justifyContentCenter, styles.alignItemsCenter, styles.mh5]}>
{isOffline && <ExitSurveyOffline />}
{!isOffline && (
<>
<Icon
src={MushroomTopHat}
width={variables.mushroomTopHatWidth}
height={variables.mushroomTopHatHeight}
/>
<Text style={[styles.headerAnonymousFooter, styles.mt5, styles.textAlignCenter]}>
{translate(shouldShowQuickTips ? 'exitSurvey.quickTip' : 'exitSurvey.thankYou')}
</Text>
<Text style={[styles.mt2, styles.textAlignCenter]}>{translate(shouldShowQuickTips ? 'exitSurvey.quickTipSubTitle' : 'exitSurvey.thankYouSubtitle')}</Text>
</>
)}
</View>
<FixedFooter>
<Button
success
large
text={translate(shouldShowQuickTips ? 'exitSurvey.takeMeToExpensifyClassic' : 'exitSurvey.goToExpensifyClassic')}
pressOnEnter
onPress={() => {
switchToOldDot();
Navigation.dismissModal();
openOldDotLink(CONST.OLDDOT_URLS.INBOX, true);
}}
isDisabled={isOffline}
/>
<View style={[styles.flex1, styles.justifyContentCenter, styles.alignItemsCenter, styles.mh5]}>
{isOffline && <ExitSurveyOffline />}
{!isOffline && (
<>
<Icon
src={MushroomTopHat}
width={variables.mushroomTopHatWidth}
height={variables.mushroomTopHatHeight}
/>
<Text style={[styles.headerAnonymousFooter, styles.mt5, styles.textAlignCenter]}>
{translate(shouldShowQuickTips ? 'exitSurvey.quickTip' : 'exitSurvey.thankYou')}
</Text>
<Text style={[styles.mt2, styles.textAlignCenter]}>{translate(shouldShowQuickTips ? 'exitSurvey.quickTipSubTitle' : 'exitSurvey.thankYouSubtitle')}</Text>
</>
)}
</View>
<FixedFooter>
<Button
success
large
text={translate(shouldShowQuickTips ? 'exitSurvey.takeMeToExpensifyClassic' : 'exitSurvey.goToExpensifyClassic')}
pressOnEnter
onPress={() => {
ExitSurvey.switchToOldDot();
Navigation.dismissModal();
Link.openOldDotLink(CONST.OLDDOT_URLS.INBOX, true);
}}
isDisabled={isOffline}
/>
</FixedFooter>
</DelegateNoAccessWrapper>
</FixedFooter>
</ScreenWrapper>
);
}
Expand Down
Loading