Skip to content

Commit

Permalink
fix import and show loading screen
Browse files Browse the repository at this point in the history
  • Loading branch information
NikkiWines committed Dec 21, 2024
1 parent 4ce67c8 commit 9dc8399
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
14 changes: 8 additions & 6 deletions src/pages/signin/SAMLSignInPage/index.native.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import useLocalize from '@hooks/useLocalize';
import getPlatform from '@libs/getPlatform';
import getUAForWebView from '@libs/getUAForWebView';
import Log from '@libs/Log';
import {handleSAMLLoginError, postSAMLLogin} from '@libs/LoginUtils';
import * as LoginUtils from '@libs/LoginUtils';
import Navigation from '@libs/Navigation/Navigation';
import * as Session from '@userActions/Session';
import CONFIG from '@src/CONFIG';
Expand All @@ -28,7 +28,7 @@ function SAMLSignInPage() {
useEffect(() => {
// If we don't have a valid login to pass here, direct the user back to a clean sign in state to try again
if (!credentials?.login) {
handleSAMLLoginError(translate('common.error.email'), true);
LoginUtils.handleSAMLLoginError(translate('common.error.email'), true);
return;
}

Expand All @@ -41,16 +41,16 @@ function SAMLSignInPage() {
body.append('email', credentials.login);
body.append('referer', CONFIG.EXPENSIFY.EXPENSIFY_CASH_REFERER);
body.append('platform', getPlatform());
postSAMLLogin(body)
LoginUtils.postSAMLLogin(body)
.then((response) => {
if (!response || !response.url) {
handleSAMLLoginError(translate('common.error.login'), false);
LoginUtils.handleSAMLLoginError(translate('common.error.login'), false);
return;
}
setSAMLUrl(response.url);
})
.catch((error: Error) => {
handleSAMLLoginError(error.message ?? translate('common.error.login'), false);
LoginUtils.handleSAMLLoginError(error.message ?? translate('common.error.login'), false);
});
}, [credentials?.login, SAMLUrl, translate]);

Expand Down Expand Up @@ -104,7 +104,7 @@ function SAMLSignInPage() {
/>
)}
<FullPageOfflineBlockingView>
{!!SAMLUrl && (
{!!SAMLUrl ? (

Check failure on line 107 in src/pages/signin/SAMLSignInPage/index.native.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Redundant double negation
<WebView
ref={webViewRef}
originWhitelist={['https://*']}
Expand All @@ -115,6 +115,8 @@ function SAMLSignInPage() {
renderLoading={() => <SAMLLoadingIndicator />}
onNavigationStateChange={handleNavigationStateChange}
/>
) : (
<SAMLLoadingIndicator />
)}
</FullPageOfflineBlockingView>
</ScreenWrapper>
Expand Down
10 changes: 5 additions & 5 deletions src/pages/signin/SAMLSignInPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, {useEffect} from 'react';
import {useOnyx} from 'react-native-onyx';
import SAMLLoadingIndicator from '@components/SAMLLoadingIndicator';
import useLocalize from '@hooks/useLocalize';
import {handleSAMLLoginError, postSAMLLogin} from '@libs/LoginUtils';
import * as LoginUtils from '@libs/LoginUtils';
import CONFIG from '@src/CONFIG';
import ONYXKEYS from '@src/ONYXKEYS';

Expand All @@ -13,24 +13,24 @@ function SAMLSignInPage() {
useEffect(() => {
// If we don't have a valid login to pass here, direct the user back to a clean sign in state to try again
if (!credentials?.login) {
handleSAMLLoginError(translate('common.error.email'), true);
LoginUtils.handleSAMLLoginError(translate('common.error.email'), true);
return;
}

const body = new FormData();
body.append('email', credentials.login);
body.append('referer', CONFIG.EXPENSIFY.EXPENSIFY_CASH_REFERER);

postSAMLLogin(body)
LoginUtils.postSAMLLogin(body)
.then((response) => {
if (!response || !response.url) {
handleSAMLLoginError(translate('common.error.login'), false);
LoginUtils.handleSAMLLoginError(translate('common.error.login'), false);
return;
}
window.location.replace(response.url);
})
.catch((error: Error) => {
handleSAMLLoginError(error.message ?? translate('common.error.login'), false);
LoginUtils.handleSAMLLoginError(error.message ?? translate('common.error.login'), false);
});
}, [credentials?.login, translate]);

Expand Down

0 comments on commit 9dc8399

Please sign in to comment.