Skip to content

Commit

Permalink
add policyID and add logi for stripe submit
Browse files Browse the repository at this point in the history
  • Loading branch information
waterim committed Oct 15, 2024
1 parent 494570a commit 6731f3a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
10 changes: 8 additions & 2 deletions src/pages/workspace/companyCards/addNew/AddNewCardPage.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
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 CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type SCREENS from '@src/SCREENS';
import CardInstructionsStep from './CardInstructionsStep';
import CardNameStep from './CardNameStep';
import CardTypeStep from './CardTypeStep';
import DetailsStep from './DetailsStep';
import SelectBankStep from './SelectBankStep';
import SelectFeedType from './SelectFeedType';

function AddNewCardPage() {
type AddNewCardPageProps = StackScreenProps<FullScreenNavigatorParamList, typeof SCREENS.WORKSPACE.COMPANY_CARDS_ADD_NEW>;

function AddNewCardPage({route}: AddNewCardPageProps) {
const {policyID} = route.params;
const [addNewCardFeed] = useOnyx(ONYXKEYS.ADD_NEW_COMPANY_CARD);
const {canUseDirectFeeds} = usePermissions();

Expand All @@ -26,7 +32,7 @@ function AddNewCardPage() {
case CONST.COMPANY_CARDS.STEP.CARD_TYPE:
return <CardTypeStep />;
case CONST.COMPANY_CARDS.STEP.CARD_INSTRUCTIONS:
return <CardInstructionsStep />;
return <CardInstructionsStep policyID={policyID} />;
case CONST.COMPANY_CARDS.STEP.CARD_NAME:
return <CardNameStep />;
case CONST.COMPANY_CARDS.STEP.CARD_DETAILS:
Expand Down
16 changes: 12 additions & 4 deletions src/pages/workspace/companyCards/addNew/CardInstructionsStep.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,36 @@ import ScrollView from '@components/ScrollView';
import Text from '@components/Text';
import useLocalize from '@hooks/useLocalize';
import useNetwork from '@hooks/useNetwork';
import usePermissions from '@hooks/usePermissions';
import useThemeStyles from '@hooks/useThemeStyles';
import Parser from '@libs/Parser';
import Navigation from '@navigation/Navigation';
import * as Card from '@userActions/Card';
import * as CompanyCards from '@userActions/CompanyCards';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';

function CardInstructionsStep() {
type CardInstructionsStepProps = {
policyID: string;
};
function CardInstructionsStep({policyID}: CardInstructionsStepProps) {
const {translate} = useLocalize();
const styles = useThemeStyles();
const {isOffline} = useNetwork();
const {canUseDirectFeeds} = usePermissions();

const [addNewCard] = useOnyx(ONYXKEYS.ADD_NEW_COMPANY_CARD);

const data = addNewCard?.data;
const feedProvider = data?.cardType;

const isStripeFeedProvider = feedProvider === CONST.COMPANY_CARDS.CARD_TYPE.STRIPE;

const buttonTranslation = isStripeFeedProvider ? translate('common.submit') : translate('common.next');

const submit = () => {
if (isStripeFeedProvider) {
// TODO: add submit logic
if (canUseDirectFeeds && isStripeFeedProvider) {
Card.updateSelectedFeed(feedProvider, policyID);
Navigation.goBack();
return;
}
CompanyCards.setAddNewCompanyCardStepAndData({
Expand Down

0 comments on commit 6731f3a

Please sign in to comment.