Skip to content

Commit

Permalink
Merge pull request #54824 from c3024/mark-tour-task-as-complete-after…
Browse files Browse the repository at this point in the history
…-completing-the-navattic-tour

Mark the tour task as complete on redirecting to Concierge after finishing the Navattic tour
  • Loading branch information
mountiny authored Jan 8, 2025
2 parents 66d6ba8 + ffc68dc commit e4e9af3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -926,6 +926,7 @@ const CONST = {
ADMIN_TOUR_STAGING: 'https://expensify.navattic.com/3i300k18',
EMPLOYEE_TOUR_PRODUCTION: 'https://expensify.navattic.com/35609gb',
EMPLOYEE_TOUR_STAGING: 'https://expensify.navattic.com/cf15002s',
COMPLETED: 'completed',
},
OLD_DOT_PUBLIC_URLS: {
TERMS_URL: `${EXPENSIFY_URL}/terms`,
Expand Down
21 changes: 19 additions & 2 deletions src/pages/ConciergePage.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {useFocusEffect} from '@react-navigation/native';
import {useFocusEffect, useRoute} from '@react-navigation/native';
import React, {useCallback, useEffect, useRef} from 'react';
import {View} from 'react-native';
import {useOnyx} from 'react-native-onyx';
Expand All @@ -10,6 +10,8 @@ import useThemeStyles from '@hooks/useThemeStyles';
import Navigation from '@libs/Navigation/Navigation';
import * as App from '@userActions/App';
import * as Report from '@userActions/Report';
import * as Task from '@userActions/Task';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';

/*
Expand All @@ -23,6 +25,11 @@ function ConciergePage() {
const {shouldUseNarrowLayout} = useResponsiveLayout();
const [session] = useOnyx(ONYXKEYS.SESSION);
const [isLoadingReportData] = useOnyx(ONYXKEYS.IS_LOADING_REPORT_DATA, {initialValue: true});
const route = useRoute();

const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED);
const viewTourTaskReportID = introSelected?.viewTour;
const [viewTourTaskReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${viewTourTaskReportID}`);

useFocusEffect(
useCallback(() => {
Expand All @@ -32,12 +39,22 @@ function ConciergePage() {
if (isUnmounted.current || isLoadingReportData === undefined || !!isLoadingReportData) {
return;
}

// Mark the viewTourTask as complete if we are redirected to Concierge after finishing the Navattic tour
const {navattic} = route.params as {navattic?: string};
if (navattic === CONST.NAVATTIC.COMPLETED) {
if (viewTourTaskReport) {
if (viewTourTaskReport.stateNum !== CONST.REPORT.STATE_NUM.APPROVED || viewTourTaskReport.statusNum !== CONST.REPORT.STATUS_NUM.APPROVED) {
Task.completeTask(viewTourTaskReport);
}
}
}
Report.navigateToConciergeChat(true, () => !isUnmounted.current);
});
} else {
Navigation.navigate();
}
}, [session, isLoadingReportData]),
}, [session, isLoadingReportData, route.params, viewTourTaskReport]),
);

useEffect(() => {
Expand Down

0 comments on commit e4e9af3

Please sign in to comment.