Skip to content

Commit

Permalink
Merge pull request #33408 from MrMuzyk/feat/bank-info-step-to-ts
Browse files Browse the repository at this point in the history
feat: BankInfo migration to ts
  • Loading branch information
mountiny authored Dec 22, 2023
2 parents d918cd4 + ec5704e commit 2cfe13d
Show file tree
Hide file tree
Showing 14 changed files with 143 additions and 464 deletions.
8 changes: 4 additions & 4 deletions src/components/MenuItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ type MenuItemProps = (ResponsiveProps | UnresponsiveProps) &
titleStyle?: ViewStyle;

/** Any adjustments to style when menu item is hovered or pressed */
hoverAndPressStyle: StyleProp<AnimatedStyle<ViewStyle>>;
hoverAndPressStyle?: StyleProp<AnimatedStyle<ViewStyle>>;

/** Additional styles to style the description text below the title */
descriptionTextStyle?: StyleProp<TextStyle>;
Expand Down Expand Up @@ -174,7 +174,7 @@ type MenuItemProps = (ResponsiveProps | UnresponsiveProps) &
isSelected?: boolean;

/** Prop to identify if we should load avatars vertically instead of diagonally */
shouldStackHorizontally: boolean;
shouldStackHorizontally?: boolean;

/** Prop to represent the size of the avatar images to be shown */
avatarSize?: (typeof CONST.AVATAR_SIZE)[keyof typeof CONST.AVATAR_SIZE];
Expand Down Expand Up @@ -219,10 +219,10 @@ type MenuItemProps = (ResponsiveProps | UnresponsiveProps) &
furtherDetails?: string;

/** The function that should be called when this component is LongPressed or right-clicked. */
onSecondaryInteraction: () => void;
onSecondaryInteraction?: () => void;

/** Array of objects that map display names to their corresponding tooltip */
titleWithTooltips: DisplayNameWithTooltip[];
titleWithTooltips?: DisplayNameWithTooltip[];
};

function MenuItem(
Expand Down
11 changes: 3 additions & 8 deletions src/hooks/useSubStep.ts → src/hooks/useSubStep/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import {ReactNode, useCallback, useRef, useState} from 'react';
import {useCallback, useRef, useState} from 'react';
import {UseSubStep} from './types';

type Props = {
bodyContent: ReactNode[];
onFinished: () => void;
startFrom?: number;
};

export default function useSubStep({bodyContent, onFinished, startFrom = 0}: Props) {
export default function useSubStep({bodyContent, onFinished, startFrom = 0}: UseSubStep) {
const [screenIndex, setScreenIndex] = useState(startFrom);
const isEditing = useRef(false);

Expand Down
31 changes: 31 additions & 0 deletions src/hooks/useSubStep/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import {ComponentType} from 'react';

type SubStepProps = {
/** value indicating whether user is editing one of the sub steps */
isEditing: boolean;

/** continues to next sub step */
onNext: () => void;

/** moves user to passed sub step */
onMove: (step: number) => void;

/** index of currently displayed sub step */
screenIndex?: number;

/** moves user to previous sub step */
prevScreen?: () => void;
};

type UseSubStep = {
/** array of components that will become sub steps */
bodyContent: Array<ComponentType<SubStepProps>>;

/** called on last sub step */
onFinished: () => void;

/** index of initial sub step to display */
startFrom?: number;
};

export type {SubStepProps, UseSubStep};
4 changes: 3 additions & 1 deletion src/libs/actions/BankAccounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ type ReimbursementAccountStep = BankAccountStep | '';

type ReimbursementAccountSubStep = BankAccountSubStep | '';

type PlaidBankAccountToConnect = Omit<PlaidBankAccount, 'isSavings' | 'addressName' | 'mask'>;

function clearPlaid(): Promise<void> {
Onyx.set(ONYXKEYS.PLAID_LINK_TOKEN, '');
Onyx.set(ONYXKEYS.PLAID_CURRENT_EVENT, null);
Expand Down Expand Up @@ -142,7 +144,7 @@ function addPersonalAddressForDraft(personalAddress: {requestorAddressStreet?: s
/**
* Submit Bank Account step with Plaid data so php can perform some checks.
*/
function connectBankAccountWithPlaid(bankAccountID: number, selectedPlaidBankAccount: PlaidBankAccount) {
function connectBankAccountWithPlaid(bankAccountID: number, selectedPlaidBankAccount: PlaidBankAccountToConnect) {
const commandName = 'ConnectBankAccountWithPlaid';

type ConnectBankAccountWithPlaidParams = {
Expand Down
2 changes: 1 addition & 1 deletion src/libs/actions/ReimbursementAccount/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export {setBankAccountFormValidationErrors, setPersonalBankAccountFormValidation
* - CONST.BANK_ACCOUNT.SETUP_TYPE.MANUAL to ask them to enter their accountNumber and routingNumber
* - CONST.BANK_ACCOUNT.SETUP_TYPE.PLAID to ask them to login to their bank via Plaid
*
* @param {String} subStep
* @param {String | null} subStep
*/
function setBankAccountSubStep(subStep) {
Onyx.merge(ONYXKEYS.REIMBURSEMENT_ACCOUNT, {achData: {subStep}});
Expand Down
146 changes: 0 additions & 146 deletions src/pages/ReimbursementAccount/BankAccountManualStep.js

This file was deleted.

Loading

0 comments on commit 2cfe13d

Please sign in to comment.