Skip to content

Commit

Permalink
fix: send single file binary
Browse files Browse the repository at this point in the history
  • Loading branch information
MrMuzyk committed Jan 31, 2025
1 parent d56902f commit 4ca4d77
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import type {FileObject} from '@components/AttachmentModal';
import type {BeneficialOwnerDataKey} from '@src/types/form/ReimbursementAccountForm';

type SaveCorpayOnboardingBeneficialOwnerParams = {
inputs: string;
files: string;
beneficialOwnerIDs: string;
bankAccountID: number;
[key: BeneficialOwnerDataKey]: FileObject;
};

export default SaveCorpayOnboardingBeneficialOwnerParams;
3 changes: 2 additions & 1 deletion src/libs/actions/BankAccounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -408,12 +408,13 @@ function getCorpayBankAccountFields(country: string, currency: string) {
return API.read(READ_COMMANDS.GET_CORPAY_BANK_ACCOUNT_FIELDS, parameters, onyxData);
}

function createCorpayBankAccount(fields: ReimbursementAccountForm) {
function createCorpayBankAccount(fields: ReimbursementAccountForm, policyID: string | undefined) {
const parameters = {
type: 1,
isSavings: false,
isWithdrawal: true,
inputs: JSON.stringify(fields),
policyID,
};

const onyxData: OnyxData = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function BankInfo({onBackButtonPress, onSubmit}: BankInfoProps) {
const submit = () => {
const {formFields, isLoading, isSuccess, ...corpayData} = corpayFields ?? {};

createCorpayBankAccount({...reimbursementAccountDraft, ...corpayData} as ReimbursementAccountForm);
createCorpayBankAccount({...reimbursementAccountDraft, ...corpayData} as ReimbursementAccountForm, policyID);
};

useEffect(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ function BeneficialOwnerInfo({onBackButtonPress, onSubmit}: BeneficialOwnerInfoP

saveCorpayOnboardingBeneficialOwners({
inputs: JSON.stringify({...ownerDetails, anyIndividualOwn25PercentOrMore: isUserOwner || isAnyoneElseOwner}),
files: JSON.stringify(ownerFiles),
...ownerFiles,
beneficialOwnerIDs: ownerKeys.join(','),
bankAccountID,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const ownerFilesFields = [PROOF_OF_OWNERSHIP, COPY_OF_ID, ADDRESS_PROOF, CODICE_

function getOwnerDetailsAndOwnerFilesForBeneficialOwners(ownerKeys: string[], reimbursementAccountDraft: OnyxEntry<ReimbursementAccountForm>) {
const ownerDetails: Record<BeneficialOwnerDataKey, string | FileObject[]> = {};
const ownerFiles: Record<BeneficialOwnerDataKey, string | FileObject[]> = {};
const ownerFiles: Record<BeneficialOwnerDataKey, string | FileObject> = {};

ownerKeys.forEach((ownerKey) => {
const ownerDetailsFullNameKey = `${PREFIX}_${ownerKey}_${FULL_NAME}` as const;
Expand Down Expand Up @@ -75,7 +75,7 @@ function getOwnerDetailsAndOwnerFilesForBeneficialOwners(ownerKeys: string[], re
return;
}

ownerFiles[ownerFilesKey] = reimbursementAccountDraft?.[ownerFilesKey];
ownerFiles[ownerFilesKey] = reimbursementAccountDraft?.[ownerFilesKey][0];
});
});

Expand Down

0 comments on commit 4ca4d77

Please sign in to comment.