Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 8 additions & 0 deletions src/hooks/useReimbursementAccountStepFormSubmit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ type UseReimbursementAccountStepFormSubmitParams = Pick<SubStepProps, 'isEditing
fieldIds: Array<keyof ReimbursementAccountDraftValues>;
};

/**
* Hook for handling submit method in ReimbursementAccount substeps.
* When user is in editing mode we should save values only when user confirm that
* @param formId - ID for particular form
* @param isEditing - if form is in editing mode
* @param onNext - callback
* @param fieldIds - field IDs for particular step
*/
export default function useReimbursementAccountStepFormSubmit({
formId = ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM,
isEditing,
Expand Down
3 changes: 3 additions & 0 deletions src/hooks/useSubStep/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import type {SubStepProps, UseSubStep} from './types';

/**
* This hook ensures uniform handling of components across different screens, enabling seamless integration and navigation through sub steps of the VBBA flow.
* @param bodyContent - array of components to display in particular step
* @param onFinished - callback triggered after finish last step
* @param startFrom - initial index for bodyContent array
*/
export default function useSubStep<TProps extends SubStepProps>({bodyContent, onFinished, startFrom = 0}: UseSubStep<TProps>) {
const [screenIndex, setScreenIndex] = useState(startFrom);
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useSubStep/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type UseSubStep<TProps extends SubStepProps> = {
/** array of components that will become sub steps */
bodyContent: Array<ComponentType<SubStepProps & TProps>>;

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

/** index of initial sub step to display */
Expand Down
2 changes: 1 addition & 1 deletion src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ export default {
continue: 'Continuar',
firstName: 'Nombre',
lastName: 'Apellidos',
phone: 'teléfono',
phone: 'Teléfono',
phoneNumber: 'Número de teléfono',
phoneNumberPlaceholder: '(xxx) xxx-xxxx',
email: 'Email',
Expand Down
5 changes: 1 addition & 4 deletions src/libs/ErrorUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,7 @@ type OnyxDataWithErrors = {
};

function getLatestErrorMessage<TOnyxData extends OnyxDataWithErrors>(onyxData: TOnyxData | null): Localize.MaybePhraseKey {
if (!onyxData) {
return '';
}
const errors = onyxData.errors ?? {};
const errors = onyxData?.errors ?? {};
Comment thread
Swor71 marked this conversation as resolved.
Resolved

if (Object.keys(errors).length === 0) {
return '';
Expand Down
7 changes: 6 additions & 1 deletion src/libs/ValidationUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ function isValidPastDate(date: string | Date): boolean {

/**
* Used to validate a value that is "required".
* @param value - field value
*/
function isRequiredFulfilled(value?: string | boolean | Date | unknown[] | Record<string, unknown> | null): boolean {
if (!value) {
Expand All @@ -91,11 +92,15 @@ function isRequiredFulfilled(value?: string | boolean | Date | unknown[] | Recor
}
return Boolean(value);
}

/**
* Used for getting errors for required fields.
*/
type GetFieldRequiredErrorsReturn<K extends string[]> = {[P in K[number]]: string};

/**
* Used to add requiredField error to the fields passed.
* @param values - all form values
* @param requiredFields - required fields for particular form
*/
function getFieldRequiredErrors<T extends OnyxFormValuesFields, K extends string[]>(values: T, requiredFields: K): GetFieldRequiredErrorsReturn<K> {
const errors: GetFieldRequiredErrorsReturn<K> = {} as GetFieldRequiredErrorsReturn<K>;
Expand Down
18 changes: 15 additions & 3 deletions src/libs/actions/BankAccounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ function getVBBADataForOnyx(currentStep?: BankAccountStep): OnyxData {
};
}

function addBusinessWebsiteForDraft(website: string) {
Onyx.merge(ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM_DRAFT, {website});
function addBusinessWebsiteForDraft(websiteUrl: string) {
Onyx.merge(ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM_DRAFT, {website: websiteUrl});
}

/**
Expand Down Expand Up @@ -251,6 +251,8 @@ function deletePaymentBankAccount(bankAccountID: number) {
* Update the user's personal information on the bank account in database.
*
* This action is called by the requestor step in the Verified Bank Account flow
* @param bankAccountID - ID for bank account
* @param params - User personal data
*/
function updatePersonalInformationForBankAccount(bankAccountID: number, params: RequestorStepProps) {
API.write(
Expand Down Expand Up @@ -308,6 +310,13 @@ function clearReimbursementAccount() {
Onyx.set(ONYXKEYS.REIMBURSEMENT_ACCOUNT, null);
}

/**
* Function to display and fetch data for Reimbursement Account step
* @param stepToOpen - current step to open
* @param subStep - particular step
* @param localCurrentStep - last step on device
* @param policyID - policy ID
*/
function openReimbursementAccountPage(stepToOpen: ReimbursementAccountStep, subStep: ReimbursementAccountSubStep, localCurrentStep: ReimbursementAccountStep, policyID: string) {
const onyxData: OnyxData = {
optimisticData: [
Expand Down Expand Up @@ -352,6 +361,7 @@ function openReimbursementAccountPage(stepToOpen: ReimbursementAccountStep, subS

/**
* Updates the bank account in the database with the company step data
* @param params - Business step form data
*/
function updateCompanyInformationForBankAccount(bankAccountID: number, params: CompanyStepProps) {
API.write(
Expand All @@ -367,6 +377,7 @@ function updateCompanyInformationForBankAccount(bankAccountID: number, params: C

/**
* Add beneficial owners for the bank account and verify the accuracy of the information provided
* @param params - Beneficial Owners step form params
*/
function updateBeneficialOwnersForBankAccount(bankAccountID: number, params: BeneficialOwnersStepProps) {
API.write(
Expand All @@ -382,6 +393,7 @@ function updateBeneficialOwnersForBankAccount(bankAccountID: number, params: Ben

/**
* Accept the ACH terms and conditions and verify the accuracy of the information provided
* @param params - Verification step form params
*/
function acceptACHContractForBankAccount(bankAccountID: number, params: ACHContractStepProps) {
API.write(
Expand All @@ -397,7 +409,7 @@ function acceptACHContractForBankAccount(bankAccountID: number, params: ACHContr

/**
* Create the bank account with manually entered data.
*
* @param plaidMask - scheme for Plaid account number
*/
function connectBankAccountManually(bankAccountID: number, accountNumber?: string, routingNumber?: string, plaidMask?: string, policyID?: string) {
const parameters: ConnectBankAccountManuallyParams = {
Expand Down