Skip to content

Commit

Permalink
Merge pull request #44700 from Expensify/revert-42901-vit-41914
Browse files Browse the repository at this point in the history
Revert "Add new read commands for the workspace profile and initial settings pages"

(cherry picked from commit 1198227)
  • Loading branch information
puneetlath authored and OSBotify committed Jul 1, 2024
1 parent 859ac6c commit eba535c
Show file tree
Hide file tree
Showing 8 changed files with 6 additions and 70 deletions.
5 changes: 0 additions & 5 deletions src/libs/API/parameters/OpenPolicyInitialPageParams.ts

This file was deleted.

5 changes: 0 additions & 5 deletions src/libs/API/parameters/OpenPolicyProfilePageParams.ts

This file was deleted.

2 changes: 0 additions & 2 deletions src/libs/API/parameters/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,6 @@ export type {default as OpenPolicyDistanceRatesPageParams} from './OpenPolicyDis
export type {default as OpenPolicyTaxesPageParams} from './OpenPolicyTaxesPageParams';
export type {default as EnablePolicyTaxesParams} from './EnablePolicyTaxesParams';
export type {default as OpenPolicyMoreFeaturesPageParams} from './OpenPolicyMoreFeaturesPageParams';
export type {default as OpenPolicyProfilePageParams} from './OpenPolicyProfilePageParams';
export type {default as OpenPolicyInitialPageParams} from './OpenPolicyInitialPageParams';
export type {default as CreatePolicyDistanceRateParams} from './CreatePolicyDistanceRateParams';
export type {default as SetPolicyDistanceRatesUnitParams} from './SetPolicyDistanceRatesUnitParams';
export type {default as SetPolicyDistanceRatesDefaultCategoryParams} from './SetPolicyDistanceRatesDefaultCategoryParams';
Expand Down
4 changes: 0 additions & 4 deletions src/libs/API/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -504,8 +504,6 @@ const READ_COMMANDS = {
OPEN_POLICY_WORKFLOWS_PAGE: 'OpenPolicyWorkflowsPage',
OPEN_POLICY_DISTANCE_RATES_PAGE: 'OpenPolicyDistanceRatesPage',
OPEN_POLICY_MORE_FEATURES_PAGE: 'OpenPolicyMoreFeaturesPage',
OPEN_POLICY_PROFILE_PAGE: 'OpenPolicyProfilePage',
OPEN_POLICY_INITIAL_PAGE: 'OpenPolicyInitialPage',
OPEN_POLICY_ACCOUNTING_PAGE: 'OpenPolicyAccountingPage',
SEARCH: 'Search',
OPEN_SUBSCRIPTION_PAGE: 'OpenSubscriptionPage',
Expand Down Expand Up @@ -554,8 +552,6 @@ type ReadCommandParameters = {
[READ_COMMANDS.OPEN_POLICY_WORKFLOWS_PAGE]: Parameters.OpenPolicyWorkflowsPageParams;
[READ_COMMANDS.OPEN_POLICY_DISTANCE_RATES_PAGE]: Parameters.OpenPolicyDistanceRatesPageParams;
[READ_COMMANDS.OPEN_POLICY_MORE_FEATURES_PAGE]: Parameters.OpenPolicyMoreFeaturesPageParams;
[READ_COMMANDS.OPEN_POLICY_PROFILE_PAGE]: Parameters.OpenPolicyProfilePageParams;
[READ_COMMANDS.OPEN_POLICY_INITIAL_PAGE]: Parameters.OpenPolicyInitialPageParams;
[READ_COMMANDS.OPEN_POLICY_ACCOUNTING_PAGE]: Parameters.OpenPolicyAccountingPageParams;
[READ_COMMANDS.SEARCH]: Parameters.SearchParams;
[READ_COMMANDS.OPEN_SUBSCRIPTION_PAGE]: null;
Expand Down
16 changes: 0 additions & 16 deletions src/libs/actions/Policy/Policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ import type {
EnablePolicyWorkflowsParams,
LeavePolicyParams,
OpenDraftWorkspaceRequestParams,
OpenPolicyInitialPageParams,
OpenPolicyMoreFeaturesPageParams,
OpenPolicyProfilePageParams,
OpenPolicyTaxesPageParams,
OpenPolicyWorkflowsPageParams,
OpenWorkspaceInvitePageParams,
Expand Down Expand Up @@ -2771,18 +2769,6 @@ function openPolicyMoreFeaturesPage(policyID: string) {
API.read(READ_COMMANDS.OPEN_POLICY_MORE_FEATURES_PAGE, params);
}

function openPolicyProfilePage(policyID: string) {
const params: OpenPolicyProfilePageParams = {policyID};

API.read(READ_COMMANDS.OPEN_POLICY_PROFILE_PAGE, params);
}

function openPolicyInitialPage(policyID: string) {
const params: OpenPolicyInitialPageParams = {policyID};

API.read(READ_COMMANDS.OPEN_POLICY_INITIAL_PAGE, params);
}

function setPolicyCustomTaxName(policyID: string, customTaxName: string) {
const policy = getPolicy(policyID);
const originalCustomTaxName = policy?.taxRates?.name;
Expand Down Expand Up @@ -2986,8 +2972,6 @@ export {
enablePolicyWorkflows,
enableDistanceRequestTax,
openPolicyMoreFeaturesPage,
openPolicyProfilePage,
openPolicyInitialPage,
generateCustomUnitID,
clearQBOErrorField,
clearXeroErrorField,
Expand Down
16 changes: 2 additions & 14 deletions src/pages/workspace/WorkspaceInitialPage.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {useFocusEffect, useNavigationState} from '@react-navigation/native';
import {useNavigationState} from '@react-navigation/native';
import type {StackScreenProps} from '@react-navigation/stack';
import React, {useCallback, useEffect, useMemo, useState} from 'react';
import {View} from 'react-native';
Expand Down Expand Up @@ -86,7 +86,7 @@ function dismissError(policyID: string, pendingAction: PendingAction | undefined
}
}

function WorkspaceInitialPage({policyDraft, policy: policyProp, reimbursementAccount, policyCategories, route}: WorkspaceInitialPageProps) {
function WorkspaceInitialPage({policyDraft, policy: policyProp, reimbursementAccount, policyCategories}: WorkspaceInitialPageProps) {
const styles = useThemeStyles();
const policy = policyDraft?.id ? policyDraft : policyProp;
const [isCurrencyModalOpen, setIsCurrencyModalOpen] = useState(false);
Expand Down Expand Up @@ -133,18 +133,6 @@ function WorkspaceInitialPage({policyDraft, policy: policyProp, reimbursementAcc
setIsCurrencyModalOpen(false);
}, [policy?.outputCurrency, isCurrencyModalOpen]);

const fetchPolicyData = useCallback(() => {
Policy.openPolicyInitialPage(route.params.policyID);
}, [route.params.policyID]);

useNetwork({onReconnect: fetchPolicyData});

useFocusEffect(
useCallback(() => {
fetchPolicyData();
}, [fetchPolicyData]),
);

/** Call update workspace currency and hide the modal */
const confirmCurrencyChangeAndHideModal = useCallback(() => {
Policy.updateGeneralSettings(policyID, policyName, CONST.CURRENCY.USD);
Expand Down
27 changes: 4 additions & 23 deletions src/pages/workspace/WorkspaceProfilePage.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import {useFocusEffect} from '@react-navigation/native';
import type {StackScreenProps} from '@react-navigation/stack';
import {ExpensiMark} from 'expensify-common';
import React, {useCallback, useState} from 'react';
import type {ImageStyle, StyleProp} from 'react-native';
Expand All @@ -17,14 +15,12 @@ import OfflineWithFeedback from '@components/OfflineWithFeedback';
import Section from '@components/Section';
import useActiveWorkspace from '@hooks/useActiveWorkspace';
import useLocalize from '@hooks/useLocalize';
import useNetwork from '@hooks/useNetwork';
import usePermissions from '@hooks/usePermissions';
import useThemeIllustrations from '@hooks/useThemeIllustrations';
import useThemeStyles from '@hooks/useThemeStyles';
import useWindowDimensions from '@hooks/useWindowDimensions';
import * as ErrorUtils from '@libs/ErrorUtils';
import Navigation from '@libs/Navigation/Navigation';
import type {FullScreenNavigatorParamList} from '@libs/Navigation/types';
import * as PolicyUtils from '@libs/PolicyUtils';
import * as ReportUtils from '@libs/ReportUtils';
import StringUtils from '@libs/StringUtils';
Expand All @@ -33,23 +29,22 @@ import * as Policy from '@userActions/Policy/Policy';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import type SCREENS from '@src/SCREENS';
import type * as OnyxTypes from '@src/types/onyx';
import {isEmptyObject} from '@src/types/utils/EmptyObject';
import withPolicy from './withPolicy';
import type {WithPolicyProps} from './withPolicy';
import WorkspacePageWithSections from './WorkspacePageWithSections';

type WorkspaceProfilePageOnyxProps = {
type WorkSpaceProfilePageOnyxProps = {
/** Constant, list of available currencies */
currencyList: OnyxEntry<OnyxTypes.CurrencyList>;
};

type WorkspaceProfilePageProps = WithPolicyProps & WorkspaceProfilePageOnyxProps & StackScreenProps<FullScreenNavigatorParamList, typeof SCREENS.WORKSPACE.PROFILE>;
type WorkSpaceProfilePageProps = WithPolicyProps & WorkSpaceProfilePageOnyxProps;

const parser = new ExpensiMark();

function WorkspaceProfilePage({policy, currencyList = {}, route}: WorkspaceProfilePageProps) {
function WorkspaceProfilePage({policy, currencyList = {}, route}: WorkSpaceProfilePageProps) {
const styles = useThemeStyles();
const {translate} = useLocalize();
const {isSmallScreenWidth} = useWindowDimensions();
Expand Down Expand Up @@ -87,20 +82,6 @@ function WorkspaceProfilePage({policy, currencyList = {}, route}: WorkspaceProfi
const imageStyle: StyleProp<ImageStyle> = isSmallScreenWidth ? [styles.mhv12, styles.mhn5, styles.mbn5] : [styles.mhv8, styles.mhn8, styles.mbn5];
const shouldShowAddress = !readOnly || formattedAddress;

const fetchPolicyData = useCallback(() => {
Policy.openPolicyProfilePage(route.params.policyID);
}, [route.params.policyID]);

useNetwork({onReconnect: fetchPolicyData});

// We have the same focus effect in the WorkspaceInitialPage, this way we can get the policy data in narrow
// as well as in the wide layout when looking at policy settings.
useFocusEffect(
useCallback(() => {
fetchPolicyData();
}, [fetchPolicyData]),
);

const DefaultAvatar = useCallback(
() => (
<Avatar
Expand Down Expand Up @@ -301,7 +282,7 @@ function WorkspaceProfilePage({policy, currencyList = {}, route}: WorkspaceProfi
WorkspaceProfilePage.displayName = 'WorkspaceProfilePage';

export default withPolicy(
withOnyx<WorkspaceProfilePageProps, WorkspaceProfilePageOnyxProps>({
withOnyx<WorkSpaceProfilePageProps, WorkSpaceProfilePageOnyxProps>({
currencyList: {key: ONYXKEYS.CURRENCY_LIST},
})(WorkspaceProfilePage),
);
1 change: 0 additions & 1 deletion src/pages/workspace/withPolicy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ type PolicyRoute = RouteProp<
NavigatorsParamList,
| typeof SCREENS.REIMBURSEMENT_ACCOUNT_ROOT
| typeof SCREENS.WORKSPACE.INITIAL
| typeof SCREENS.WORKSPACE.PROFILE
| typeof SCREENS.WORKSPACE.BILLS
| typeof SCREENS.WORKSPACE.MORE_FEATURES
| typeof SCREENS.WORKSPACE.MEMBERS
Expand Down

0 comments on commit eba535c

Please sign in to comment.