diff --git a/src/ROUTES.ts b/src/ROUTES.ts index 336c4b0cfa68..cd94035e0fff 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -1238,8 +1238,8 @@ const ROUTES = { getRoute: (policyID: string) => `settings/workspaces/${policyID}/company-cards/settings` as const, }, WORKSPACE_COMPANY_CARDS_SETTINGS_FEED_NAME: { - route: 'settings/workspaces/:policyID/company-cards/settings/feed-name/:feedName', - getRoute: (policyID: string, feedName: string) => `settings/workspaces/${policyID}/company-cards/settings/feed-name/${encodeURIComponent(feedName)}` as const, + route: 'settings/workspaces/:policyID/company-cards/settings/feed-name', + getRoute: (policyID: string) => `settings/workspaces/${policyID}/company-cards/settings/feed-name` as const, }, WORKSPACE_RULES: { route: 'settings/workspaces/:policyID/rules', diff --git a/src/libs/Navigation/types.ts b/src/libs/Navigation/types.ts index 1630954c666a..ba859efff944 100644 --- a/src/libs/Navigation/types.ts +++ b/src/libs/Navigation/types.ts @@ -854,7 +854,6 @@ type SettingsNavigatorParamList = { }; [SCREENS.WORKSPACE.COMPANY_CARDS_SETTINGS_FEED_NAME]: { policyID: string; - feedName?: string; }; [SCREENS.WORKSPACE.EXPENSIFY_CARD_DETAILS]: { policyID: string; diff --git a/src/pages/workspace/companyCards/WorkspaceCompanyCardsSettingsFeedNamePage.tsx b/src/pages/workspace/companyCards/WorkspaceCompanyCardsSettingsFeedNamePage.tsx index 33ee035f133c..3bc7a7301163 100644 --- a/src/pages/workspace/companyCards/WorkspaceCompanyCardsSettingsFeedNamePage.tsx +++ b/src/pages/workspace/companyCards/WorkspaceCompanyCardsSettingsFeedNamePage.tsx @@ -5,6 +5,7 @@ import {useOnyx} from 'react-native-onyx'; import FormProvider from '@components/Form/FormProvider'; import InputWrapper from '@components/Form/InputWrapper'; import type {FormInputErrors, FormOnyxValues} from '@components/Form/types'; +import FullScreenLoadingIndicator from '@components/FullscreenLoadingIndicator'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; import ScreenWrapper from '@components/ScreenWrapper'; import Text from '@components/Text'; @@ -25,12 +26,13 @@ import ROUTES from '@src/ROUTES'; import type SCREENS from '@src/SCREENS'; import type {WorkspaceCompanyCardFeedName} from '@src/types/form/WorkspaceCompanyCardFeedName'; import INPUT_IDS from '@src/types/form/WorkspaceTaxCustomName'; +import isLoadingOnyxValue from '@src/types/utils/isLoadingOnyxValue'; type WorkspaceCompanyCardsSettingsFeedNamePageProps = StackScreenProps; function WorkspaceCompanyCardsSettingsFeedNamePage({ route: { - params: {policyID, feedName: selectedFeedName}, + params: {policyID}, }, }: WorkspaceCompanyCardsSettingsFeedNamePageProps) { const styles = useThemeStyles(); @@ -38,12 +40,10 @@ function WorkspaceCompanyCardsSettingsFeedNamePage({ const {inputCallbackRef} = useAutoFocusInput(); const policy = usePolicy(policyID); const workspaceAccountID = policy?.workspaceAccountID ?? -1; - const [lastSelectedFeed] = useOnyx(`${ONYXKEYS.COLLECTION.LAST_SELECTED_FEED}${policyID}`); - const [cardFeeds] = useOnyx(`${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER}${workspaceAccountID}`); + const [lastSelectedFeed, lastSelectedFeedResult] = useOnyx(`${ONYXKEYS.COLLECTION.LAST_SELECTED_FEED}${policyID}`); + const [cardFeeds, cardFeedsResult] = useOnyx(`${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER}${workspaceAccountID}`); const selectedFeed = CardUtils.getSelectedFeed(lastSelectedFeed, cardFeeds); - const feedName = selectedFeed - ? cardFeeds?.settings?.companyCardNicknames?.[selectedFeed] ?? translate('workspace.companyCards.feedName', {feedName: CardUtils.getCardFeedName(selectedFeed)}) - : decodeURIComponent(selectedFeedName ?? ''); + const feedName = cardFeeds?.settings?.companyCardNicknames?.[selectedFeed] ?? translate('workspace.companyCards.feedName', {feedName: CardUtils.getCardFeedName(selectedFeed)}); const validate = useCallback( (values: FormOnyxValues) => { @@ -64,6 +64,10 @@ function WorkspaceCompanyCardsSettingsFeedNamePage({ Navigation.goBack(ROUTES.WORKSPACE_COMPANY_CARDS_SETTINGS.getRoute(policyID)); }; + if (isLoadingOnyxValue(cardFeedsResult) || isLoadingOnyxValue(lastSelectedFeedResult)) { + return ; + } + return ( { - Navigation.navigate(ROUTES.WORKSPACE_COMPANY_CARDS_SETTINGS_FEED_NAME.getRoute(policyID, feedName)); + Navigation.navigate(ROUTES.WORKSPACE_COMPANY_CARDS_SETTINGS_FEED_NAME.getRoute(policyID)); }; const deleteCompanyCardFeed = () => {