From 1aa4fe744ef5e64f39f89b6a67efd5097435ff62 Mon Sep 17 00:00:00 2001 From: VickyStash Date: Tue, 5 Nov 2024 12:33:16 +0100 Subject: [PATCH 1/4] Add Card name display to the confirmation step --- src/CONST.ts | 1 + .../API/parameters/AssignCompanyCardParams.ts | 1 + src/libs/actions/CompanyCards.ts | 3 +- .../WorkspaceCompanyCardEditCardNamePage.tsx | 5 +- .../assignCard/AssignCardFeedPage.tsx | 3 + .../companyCards/assignCard/AssigneeStep.tsx | 5 + .../companyCards/assignCard/CardNameStep.tsx | 97 +++++++++++++++++++ .../assignCard/CardSelectionStep.tsx | 4 +- .../assignCard/ConfirmationStep.tsx | 8 +- src/types/onyx/AssignCard.ts | 5 +- 10 files changed, 126 insertions(+), 6 deletions(-) create mode 100644 src/pages/workspace/companyCards/assignCard/CardNameStep.tsx diff --git a/src/CONST.ts b/src/CONST.ts index fbe12d1fdfb2..ba8f1f0cc062 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -2684,6 +2684,7 @@ const CONST = { STEP: { ASSIGNEE: 'Assignee', CARD: 'Card', + CARD_NAME: 'CardName', TRANSACTION_START_DATE: 'TransactionStartDate', CONFIRMATION: 'Confirmation', }, diff --git a/src/libs/API/parameters/AssignCompanyCardParams.ts b/src/libs/API/parameters/AssignCompanyCardParams.ts index c4dcd7c628a0..782345686c62 100644 --- a/src/libs/API/parameters/AssignCompanyCardParams.ts +++ b/src/libs/API/parameters/AssignCompanyCardParams.ts @@ -1,6 +1,7 @@ type AssignCompanyCardParams = { policyID: string; bankName: string; + cardName: string; encryptedCardNumber: string; email: string; startDate: string; diff --git a/src/libs/actions/CompanyCards.ts b/src/libs/actions/CompanyCards.ts index a106fbeff510..6ebdab59a9e6 100644 --- a/src/libs/actions/CompanyCards.ts +++ b/src/libs/actions/CompanyCards.ts @@ -159,7 +159,7 @@ function assignWorkspaceCompanyCard(policyID: string, data?: Partial Navigation.goBack(ROUTES.WORKSPACE_COMPANY_CARD_DETAILS.getRoute(policyID, cardID, bank))} /> + + {translate('workspace.moreFeatures.companyCards.giveItNameInstruction')} + ; + case CONST.COMPANY_CARD.STEP.CARD_NAME: + return ; case CONST.COMPANY_CARD.STEP.CONFIRMATION: return ( ) => { + CompanyCards.setAssignCardStepAndData({ + currentStep: CONST.COMPANY_CARD.STEP.CONFIRMATION, + data: { + cardName: values.name, + }, + isEditing: false, + }); + }; + + const validate = (values: FormOnyxValues): FormInputErrors => { + const errors = ValidationUtils.getFieldRequiredErrors(values, [INPUT_IDS.NAME]); + const length = values.name.length; + + if (length > CONST.STANDARD_LENGTH_LIMIT) { + ErrorUtils.addErrorMessage(errors, INPUT_IDS.NAME, translate('common.error.characterLimitExceedCounter', {length, limit: CONST.STANDARD_LENGTH_LIMIT})); + } + + return errors; + }; + + return ( + + + CompanyCards.setAssignCardStepAndData({currentStep: CONST.COMPANY_CARD.STEP.CONFIRMATION, isEditing: false})} + /> + + {translate('workspace.moreFeatures.companyCards.giveItNameInstruction')} + + + + + + + ); +} + +CardNameStep.displayName = 'CardNameStep'; + +export default CardNameStep; diff --git a/src/pages/workspace/companyCards/assignCard/CardSelectionStep.tsx b/src/pages/workspace/companyCards/assignCard/CardSelectionStep.tsx index 84e7ea5723a7..9795adb3fa0d 100644 --- a/src/pages/workspace/companyCards/assignCard/CardSelectionStep.tsx +++ b/src/pages/workspace/companyCards/assignCard/CardSelectionStep.tsx @@ -88,14 +88,14 @@ function CardSelectionStep({feed, policyID}: CardSelectionStepProps) { return; } - const cardName = + const cardNumber = Object.entries(filteredCardList) .find(([, encryptedCardNumber]) => encryptedCardNumber === cardSelected) ?.at(0) ?? ''; CompanyCards.setAssignCardStepAndData({ currentStep: isEditing ? CONST.COMPANY_CARD.STEP.CONFIRMATION : CONST.COMPANY_CARD.STEP.TRANSACTION_START_DATE, - data: {encryptedCardNumber: cardSelected, cardName: accountCardList?.length > 0 ? cardSelected : cardName}, + data: {encryptedCardNumber: cardSelected, cardNumber: accountCardList?.length > 0 ? cardSelected : cardNumber}, isEditing: false, }); }; diff --git a/src/pages/workspace/companyCards/assignCard/ConfirmationStep.tsx b/src/pages/workspace/companyCards/assignCard/ConfirmationStep.tsx index 2d0fab26b070..002ad9eac254 100644 --- a/src/pages/workspace/companyCards/assignCard/ConfirmationStep.tsx +++ b/src/pages/workspace/companyCards/assignCard/ConfirmationStep.tsx @@ -75,7 +75,7 @@ function ConfirmationStep({policyID, backTo}: ConfirmationStepProps) { /> editStep(CONST.COMPANY_CARD.STEP.CARD)} /> @@ -85,6 +85,12 @@ function ConfirmationStep({policyID, backTo}: ConfirmationStepProps) { shouldShowRightIcon onPress={() => editStep(CONST.COMPANY_CARD.STEP.TRANSACTION_START_DATE)} /> + editStep(CONST.COMPANY_CARD.STEP.CARD_NAME)} + />