Skip to content

Commit

Permalink
Merge pull request #45603 from nyomanjyotisa/track-expense-and-submit…
Browse files Browse the repository at this point in the history
…-expense-deep-links

track-expense and submit-expense deep links
  • Loading branch information
marcochavezf authored Jul 29, 2024
2 parents 712ac8d + 40653d4 commit 7e1af70
Show file tree
Hide file tree
Showing 9 changed files with 162 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .well-known/apple-app-site-association
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,14 @@
{
"/": "/money2020/*",
"comment": "Money 2020"
},
{
"/": "/track-expense/*",
"comment": "Track Expense"
},
{
"/": "/submit-expense/*",
"comment": "Submit Expense"
}
]
}
Expand Down
4 changes: 4 additions & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@
<data android:scheme="https" android:host="new.expensify.com" android:pathPrefix="/send"/>
<data android:scheme="https" android:host="new.expensify.com" android:pathPrefix="/pay"/>
<data android:scheme="https" android:host="new.expensify.com" android:pathPrefix="/money2020"/>
<data android:scheme="https" android:host="new.expensify.com" android:pathPrefix="/track-expense"/>
<data android:scheme="https" android:host="new.expensify.com" android:pathPrefix="/submit-expense"/>

<!-- Staging URLs -->
<data android:scheme="https" android:host="staging.new.expensify.com" android:pathPrefix="/r"/>
Expand All @@ -94,6 +96,8 @@
<data android:scheme="https" android:host="staging.new.expensify.com" android:pathPrefix="/send"/>
<data android:scheme="https" android:host="staging.new.expensify.com" android:pathPrefix="/pay"/>
<data android:scheme="https" android:host="staging.new.expensify.com" android:pathPrefix="/money2020"/>
<data android:scheme="https" android:host="staging.new.expensify.com" android:pathPrefix="/track-expense"/>
<data android:scheme="https" android:host="staging.new.expensify.com" android:pathPrefix="/submit-expense"/>
</intent-filter>
</activity>

Expand Down
2 changes: 2 additions & 0 deletions src/ROUTES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ const ROUTES = {

// This is a utility route used to go to the user's concierge chat, or the sign-in page if the user's not authenticated
CONCIERGE: 'concierge',
TRACK_EXPENSE: 'track-expense',
SUBMIT_EXPENSE: 'submit-expense',
FLAG_COMMENT: {
route: 'flag/:reportID/:reportActionID',
getRoute: (reportID: string, reportActionID: string) => `flag/${reportID}/${reportActionID}` as const,
Expand Down
2 changes: 2 additions & 0 deletions src/SCREENS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ const PROTECTED_SCREENS = {
HOME: 'Home',
CONCIERGE: 'Concierge',
ATTACHMENTS: 'Attachments',
TRACK_EXPENSE: 'TrackExpense',
SUBMIT_EXPENSE: 'SubmitExpense',
} as const;

const SCREENS = {
Expand Down
12 changes: 12 additions & 0 deletions src/libs/Navigation/AppNavigator/AuthScreens.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ const loadReportAttachments = () => require<ReactComponentModule>('../../../page
const loadValidateLoginPage = () => require<ReactComponentModule>('../../../pages/ValidateLoginPage').default;
const loadLogOutPreviousUserPage = () => require<ReactComponentModule>('../../../pages/LogOutPreviousUserPage').default;
const loadConciergePage = () => require<ReactComponentModule>('../../../pages/ConciergePage').default;
const loadTrackExpensePage = () => require<ReactComponentModule>('../../../pages/TrackExpensePage').default;
const loadSubmitExpensePage = () => require<ReactComponentModule>('../../../pages/SubmitExpensePage').default;
const loadProfileAvatar = () => require<ReactComponentModule>('../../../pages/settings/Profile/ProfileAvatar').default;
const loadWorkspaceAvatar = () => require<ReactComponentModule>('../../../pages/workspace/WorkspaceAvatar').default;
const loadReportAvatar = () => require<ReactComponentModule>('../../../pages/ReportAvatar').default;
Expand Down Expand Up @@ -377,6 +379,16 @@ function AuthScreens({session, lastOpenedPublicRoomID, initialLastUpdateIDApplie
options={defaultScreenOptions}
getComponent={loadConciergePage}
/>
<RootStack.Screen
name={SCREENS.TRACK_EXPENSE}
options={defaultScreenOptions}
getComponent={loadTrackExpensePage}
/>
<RootStack.Screen
name={SCREENS.SUBMIT_EXPENSE}
options={defaultScreenOptions}
getComponent={loadSubmitExpensePage}
/>
<RootStack.Screen
name={SCREENS.ATTACHMENTS}
options={{
Expand Down
2 changes: 2 additions & 0 deletions src/libs/Navigation/linkingConfig/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ const config: LinkingOptions<RootStackParamList>['config'] = {
[SCREENS.TRANSITION_BETWEEN_APPS]: ROUTES.TRANSITION_BETWEEN_APPS,
[SCREENS.CONNECTION_COMPLETE]: ROUTES.CONNECTION_COMPLETE,
[SCREENS.CONCIERGE]: ROUTES.CONCIERGE,
[SCREENS.TRACK_EXPENSE]: ROUTES.TRACK_EXPENSE,
[SCREENS.SUBMIT_EXPENSE]: ROUTES.SUBMIT_EXPENSE,
[SCREENS.SIGN_IN_WITH_APPLE_DESKTOP]: ROUTES.APPLE_SIGN_IN,
[SCREENS.SIGN_IN_WITH_GOOGLE_DESKTOP]: ROUTES.GOOGLE_SIGN_IN,
[SCREENS.SAML_SIGN_IN]: ROUTES.SAML_SIGN_IN,
Expand Down
2 changes: 2 additions & 0 deletions src/libs/Navigation/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1240,6 +1240,8 @@ type PublicScreensParamList = SharedScreensParamList & {
type AuthScreensParamList = CentralPaneScreensParamList &
SharedScreensParamList & {
[SCREENS.CONCIERGE]: undefined;
[SCREENS.TRACK_EXPENSE]: undefined;
[SCREENS.SUBMIT_EXPENSE]: undefined;
[SCREENS.ATTACHMENTS]: {
reportID: string;
source: string;
Expand Down
56 changes: 56 additions & 0 deletions src/pages/SubmitExpensePage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import {useFocusEffect} from '@react-navigation/native';
import React, {useEffect, useRef} from 'react';
import {View} from 'react-native';
import ReportActionsSkeletonView from '@components/ReportActionsSkeletonView';
import ReportHeaderSkeletonView from '@components/ReportHeaderSkeletonView';
import ScreenWrapper from '@components/ScreenWrapper';
import useThemeStyles from '@hooks/useThemeStyles';
import interceptAnonymousUser from '@libs/interceptAnonymousUser';
import Navigation from '@libs/Navigation/Navigation';
import * as ReportUtils from '@libs/ReportUtils';
import * as App from '@userActions/App';
import * as IOU from '@userActions/IOU';
import CONST from '@src/CONST';

/*
* This is a "utility page", that does this:
* - If the user is authenticated, start Submit Expense
* - Else re-route to the login page
*/
function SubmitExpensePage() {
const styles = useThemeStyles();
const isUnmounted = useRef(false);

useFocusEffect(() => {
interceptAnonymousUser(() => {
App.confirmReadyToOpenApp();
Navigation.isNavigationReady().then(() => {
if (isUnmounted.current) {
return;
}
Navigation.goBack();
IOU.startMoneyRequest(CONST.IOU.TYPE.SUBMIT, ReportUtils.generateReportID());
});
});
});

useEffect(
() => () => {
isUnmounted.current = true;
},
[],
);

return (
<ScreenWrapper testID={SubmitExpensePage.displayName}>
<View style={[styles.borderBottom]}>
<ReportHeaderSkeletonView onBackButtonPress={Navigation.goBack} />
</View>
<ReportActionsSkeletonView />
</ScreenWrapper>
);
}

SubmitExpensePage.displayName = 'SubmitExpensePage';

export default SubmitExpensePage;
74 changes: 74 additions & 0 deletions src/pages/TrackExpensePage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import {useFocusEffect} from '@react-navigation/native';
import React, {useEffect, useRef} from 'react';
import {View} from 'react-native';
import {useOnyx} from 'react-native-onyx';
import ReportActionsSkeletonView from '@components/ReportActionsSkeletonView';
import ReportHeaderSkeletonView from '@components/ReportHeaderSkeletonView';
import ScreenWrapper from '@components/ScreenWrapper';
import useNetwork from '@hooks/useNetwork';
import useThemeStyles from '@hooks/useThemeStyles';
import interceptAnonymousUser from '@libs/interceptAnonymousUser';
import Navigation from '@libs/Navigation/Navigation';
import * as ReportUtils from '@libs/ReportUtils';
import * as App from '@userActions/App';
import * as IOU from '@userActions/IOU';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import isLoadingOnyxValue from '@src/types/utils/isLoadingOnyxValue';

/*
* This is a "utility page", that does this:
* - If the user is authenticated, find their self DM and and start a Track Expense
* - Else re-route to the login page
*/
function TrackExpensePage() {
const styles = useThemeStyles();
const isUnmounted = useRef(false);
const {isOffline} = useNetwork();
const [hasSeenTrackTraining, hasSeenTrackTrainingResult] = useOnyx(ONYXKEYS.NVP_HAS_SEEN_TRACK_TRAINING);
const isLoadingHasSeenTrackTraining = isLoadingOnyxValue(hasSeenTrackTrainingResult);

useFocusEffect(() => {
interceptAnonymousUser(() => {
App.confirmReadyToOpenApp();
Navigation.isNavigationReady().then(() => {
if (isUnmounted.current || isLoadingHasSeenTrackTraining) {
return;
}
Navigation.goBack();
IOU.startMoneyRequest(
CONST.IOU.TYPE.TRACK,
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
ReportUtils.findSelfDMReportID() || ReportUtils.generateReportID(),
);

if (!hasSeenTrackTraining && !isOffline) {
setTimeout(() => {
Navigation.navigate(ROUTES.TRACK_TRAINING_MODAL);
}, CONST.ANIMATED_TRANSITION);
}
});
});
});

useEffect(
() => () => {
isUnmounted.current = true;
},
[],
);

return (
<ScreenWrapper testID={TrackExpensePage.displayName}>
<View style={[styles.borderBottom]}>
<ReportHeaderSkeletonView onBackButtonPress={Navigation.goBack} />
</View>
<ReportActionsSkeletonView />
</ScreenWrapper>
);
}

TrackExpensePage.displayName = 'TrackExpensePage';

export default TrackExpensePage;

0 comments on commit 7e1af70

Please sign in to comment.