From 161e5f96e49f57ea6cbc596ea257beb88b4d6435 Mon Sep 17 00:00:00 2001 From: Artem Makushov Date: Tue, 15 Oct 2024 17:01:09 +0200 Subject: [PATCH] fix policy --- .../workspace/companyCards/addNew/AddNewCardPage.tsx | 12 ++++-------- .../companyCards/addNew/CardInstructionsStep.tsx | 4 ++-- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/pages/workspace/companyCards/addNew/AddNewCardPage.tsx b/src/pages/workspace/companyCards/addNew/AddNewCardPage.tsx index 549a9ca0c2e1..44b444314c66 100644 --- a/src/pages/workspace/companyCards/addNew/AddNewCardPage.tsx +++ b/src/pages/workspace/companyCards/addNew/AddNewCardPage.tsx @@ -1,12 +1,10 @@ -import type {StackScreenProps} from '@react-navigation/stack'; import React from 'react'; import {useOnyx} from 'react-native-onyx'; import usePermissions from '@hooks/usePermissions'; -import type {FullScreenNavigatorParamList} from '@libs/Navigation/types'; import withPolicyAndFullscreenLoading from '@pages/workspace/withPolicyAndFullscreenLoading'; +import type {WithPolicyAndFullscreenLoadingProps} from '@pages/workspace/withPolicyAndFullscreenLoading'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; -import type SCREENS from '@src/SCREENS'; import AmexCustomFeed from './AmexCustomFeed'; import CardInstructionsStep from './CardInstructionsStep'; import CardNameStep from './CardNameStep'; @@ -15,10 +13,8 @@ import DetailsStep from './DetailsStep'; import SelectBankStep from './SelectBankStep'; import SelectFeedType from './SelectFeedType'; -type AddNewCardPageProps = StackScreenProps; - -function AddNewCardPage({route}: AddNewCardPageProps) { - const {policyID} = route.params; +function AddNewCardPage({policy}: WithPolicyAndFullscreenLoadingProps) { + const policyID = policy?.id; const [addNewCardFeed] = useOnyx(ONYXKEYS.ADD_NEW_COMPANY_CARD); const {canUseDirectFeeds} = usePermissions(); @@ -48,7 +44,7 @@ function AddNewCardPage({route}: AddNewCardPageProps) { case CONST.COMPANY_CARDS.STEP.CARD_TYPE: return ; case CONST.COMPANY_CARDS.STEP.CARD_INSTRUCTIONS: - return ; + return ; case CONST.COMPANY_CARDS.STEP.CARD_NAME: return ; case CONST.COMPANY_CARDS.STEP.CARD_DETAILS: diff --git a/src/pages/workspace/companyCards/addNew/CardInstructionsStep.tsx b/src/pages/workspace/companyCards/addNew/CardInstructionsStep.tsx index 76228f2ff3ae..7cd23f1c2604 100644 --- a/src/pages/workspace/companyCards/addNew/CardInstructionsStep.tsx +++ b/src/pages/workspace/companyCards/addNew/CardInstructionsStep.tsx @@ -20,7 +20,7 @@ import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; type CardInstructionsStepProps = { - policyID: string; + policyID?: string; }; function CardInstructionsStep({policyID}: CardInstructionsStepProps) { const {translate} = useLocalize(); @@ -39,7 +39,7 @@ function CardInstructionsStep({policyID}: CardInstructionsStepProps) { const submit = () => { if (canUseDirectFeeds && isStripeFeedProvider) { - Card.updateSelectedFeed(feedProvider, policyID); + Card.updateSelectedFeed(feedProvider, policyID ?? '-1'); Navigation.goBack(); return; }