Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[No QA] StartIssueNewCardFlow api call #45912

Merged
merged 5 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/libs/API/parameters/StartIssueNewCardFlowParams.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type StartIssueNewCardFlowParams = {
policyID: string;
};

export default StartIssueNewCardFlowParams;
1 change: 1 addition & 0 deletions src/libs/API/parameters/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,3 +267,4 @@ export type {default as UpdateNetSuiteCustomersJobsParams} from './UpdateNetSuit
export type {default as CopyExistingPolicyConnectionParams} from './CopyExistingPolicyConnectionParams';
export type {default as ExportSearchItemsToCSVParams} from './ExportSearchItemsToCSVParams';
export type {default as UpdateExpensifyCardLimitParams} from './UpdateExpensifyCardLimitParams';
export type {default as StartIssueNewCardFlowParams} from './StartIssueNewCardFlowParams';
2 changes: 2 additions & 0 deletions src/libs/API/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,7 @@ const READ_COMMANDS = {
SEARCH: 'Search',
OPEN_SUBSCRIPTION_PAGE: 'OpenSubscriptionPage',
OPEN_DRAFT_DISTANCE_EXPENSE: 'OpenDraftDistanceExpense',
START_ISSUE_NEW_CARD_FLOW: 'StartIssueNewCardFlow',
} as const;

type ReadCommand = ValueOf<typeof READ_COMMANDS>;
Expand Down Expand Up @@ -752,6 +753,7 @@ type ReadCommandParameters = {
[READ_COMMANDS.SEARCH]: Parameters.SearchParams;
[READ_COMMANDS.OPEN_SUBSCRIPTION_PAGE]: null;
[READ_COMMANDS.OPEN_DRAFT_DISTANCE_EXPENSE]: null;
[READ_COMMANDS.START_ISSUE_NEW_CARD_FLOW]: Parameters.StartIssueNewCardFlowParams;
};

const SIDE_EFFECT_REQUEST_COMMANDS = {
Expand Down
12 changes: 11 additions & 1 deletion src/libs/actions/Card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ import type {
ReportVirtualExpensifyCardFraudParams,
RequestReplacementExpensifyCardParams,
RevealExpensifyCardDetailsParams,
StartIssueNewCardFlowParams,
UpdateExpensifyCardLimitParams,
} from '@libs/API/parameters';
import {SIDE_EFFECT_REQUEST_COMMANDS, WRITE_COMMANDS} from '@libs/API/types';
import {READ_COMMANDS, SIDE_EFFECT_REQUEST_COMMANDS, WRITE_COMMANDS} from '@libs/API/types';
import * as ErrorUtils from '@libs/ErrorUtils';
import * as NetworkStore from '@libs/Network/NetworkStore';
import CONST from '@src/CONST';
Expand Down Expand Up @@ -372,6 +373,14 @@ function updateExpensifyCardLimit(policyID: string, cardID: number, newLimit: nu
API.write(WRITE_COMMANDS.UPDATE_EXPENSIFY_CARD_LIMIT, parameters, {optimisticData, successData, failureData});
}

function startIssueNewCardFlow(policyID: string) {
const parameters: StartIssueNewCardFlowParams = {
policyID,
};

API.read(READ_COMMANDS.START_ISSUE_NEW_CARD_FLOW, parameters);
}

export {
requestReplacementExpensifyCard,
activatePhysicalExpensifyCard,
Expand All @@ -383,5 +392,6 @@ export {
clearIssueNewCardFlow,
updateExpensifyCardLimit,
updateSettlementAccount,
startIssueNewCardFlow,
};
export type {ReplacementReason};
7 changes: 5 additions & 2 deletions src/pages/workspace/card/issueNew/IssueNewCardPage.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React from 'react';
import React, {useEffect} from 'react';
import {useOnyx} from 'react-native-onyx';
import type {WithPolicyAndFullscreenLoadingProps} from '@pages/workspace/withPolicyAndFullscreenLoading';
import withPolicyAndFullscreenLoading from '@pages/workspace/withPolicyAndFullscreenLoading';
import * as Card from '@userActions/Card';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import AssigneeStep from './AssigneeStep';
Expand All @@ -17,7 +18,9 @@ function IssueNewCardPage({policy}: WithPolicyAndFullscreenLoadingProps) {
const {currentStep} = issueNewCard ?? {};

// TODO: add logic to skip Assignee step when the flow is started from the member's profile page
// TODO: StartIssueNewCardFlow call to API
useEffect(() => {
Card.startIssueNewCardFlow(policy?.id ?? '-1');
}, [policy?.id]);

switch (currentStep) {
case CONST.EXPENSIFY_CARD.STEP.ASSIGNEE:
Expand Down
Loading