From f48d74a1e35f792b0336221170e6660a3e05ef89 Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Sun, 14 Jul 2024 23:35:08 +0700 Subject: [PATCH 01/43] fix: Attachment - Press enter fullscreen mode in video player by Tab --- src/components/VideoPlayer/IconButton.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/components/VideoPlayer/IconButton.tsx b/src/components/VideoPlayer/IconButton.tsx index e2b931bc256..7cf73765caa 100644 --- a/src/components/VideoPlayer/IconButton.tsx +++ b/src/components/VideoPlayer/IconButton.tsx @@ -5,6 +5,7 @@ import PressableWithFeedback from '@components/Pressable/PressableWithFeedback'; import Tooltip from '@components/Tooltip'; import useThemeStyles from '@hooks/useThemeStyles'; import type IconAsset from '@src/types/utils/IconAsset'; +import CONST from '@src/CONST'; type IconButtonProps = { src: IconAsset; @@ -29,6 +30,7 @@ function IconButton({src, fill = 'white', onPress, style, hoverStyle, tooltipTex onPress={onPress} style={[styles.videoIconButton, style]} hoverStyle={[styles.videoIconButtonHovered, hoverStyle]} + role={CONST.ROLE.BUTTON} > Date: Mon, 15 Jul 2024 00:00:05 +0700 Subject: [PATCH 02/43] fix lint --- src/components/VideoPlayer/IconButton.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/VideoPlayer/IconButton.tsx b/src/components/VideoPlayer/IconButton.tsx index 7cf73765caa..3066cc7620e 100644 --- a/src/components/VideoPlayer/IconButton.tsx +++ b/src/components/VideoPlayer/IconButton.tsx @@ -4,8 +4,8 @@ import Icon from '@components/Icon'; import PressableWithFeedback from '@components/Pressable/PressableWithFeedback'; import Tooltip from '@components/Tooltip'; import useThemeStyles from '@hooks/useThemeStyles'; -import type IconAsset from '@src/types/utils/IconAsset'; import CONST from '@src/CONST'; +import type IconAsset from '@src/types/utils/IconAsset'; type IconButtonProps = { src: IconAsset; From f69f05ea4d602063bbc678ee9f426cc7202982e0 Mon Sep 17 00:00:00 2001 From: kirillzyusko Date: Thu, 29 Aug 2024 12:47:10 +0200 Subject: [PATCH 03/43] feat: build baseline from previous commit --- .github/workflows/e2ePerformanceTests.yml | 39 +++++++++++++---------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/.github/workflows/e2ePerformanceTests.yml b/.github/workflows/e2ePerformanceTests.yml index e5755614397..a9bf38b996a 100644 --- a/.github/workflows/e2ePerformanceTests.yml +++ b/.github/workflows/e2ePerformanceTests.yml @@ -1,6 +1,8 @@ name: E2E Performance Tests on: + pull_request: + types: [opened, synchronize, reopened] workflow_call: inputs: PR_NUMBER: @@ -39,25 +41,28 @@ jobs: env: GITHUB_TOKEN: ${{ github.token }} - - name: Check if there's an existing artifact for this baseline - id: checkForExistingArtifact - uses: ./.github/actions/javascript/getArtifactInfo - with: - GITHUB_TOKEN: ${{ secrets.OS_BOTIFY_COMMIT_TOKEN }} - ARTIFACT_NAME: baseline-apk-${{ steps.getMostRecentRelease.outputs.VERSION }} - - - name: Skip build if there's already an existing artifact for the baseline - if: ${{ fromJSON(steps.checkForExistingArtifact.outputs.ARTIFACT_FOUND) }} - run: echo 'APK for baseline ${{ steps.getMostRecentRelease.outputs.VERSION }} already exists, reusing existing build' - - - name: Checkout "Baseline" commit (last release) - if: ${{ !fromJSON(steps.checkForExistingArtifact.outputs.ARTIFACT_FOUND) }} + # - name: Check if there's an existing artifact for this baseline + # id: checkForExistingArtifact + # uses: ./.github/actions/javascript/getArtifactInfo + # with: + # GITHUB_TOKEN: ${{ secrets.OS_BOTIFY_COMMIT_TOKEN }} + # ARTIFACT_NAME: baseline-apk-${{ steps.getMostRecentRelease.outputs.VERSION }} + + # - name: Skip build if there's already an existing artifact for the baseline + # if: ${{ fromJSON(steps.checkForExistingArtifact.outputs.ARTIFACT_FOUND) }} + # run: echo 'APK for baseline ${{ steps.getMostRecentRelease.outputs.VERSION }} already exists, reusing existing build' + + - name: Checkout "Baseline" commit (prev merge commit) + # if: ${{ !fromJSON(steps.checkForExistingArtifact.outputs.ARTIFACT_FOUND) }} + # run: | + # git fetch origin tag ${{ steps.getMostRecentRelease.outputs.VERSION }} --no-tags --depth=1 + # git switch --detach ${{ steps.getMostRecentRelease.outputs.VERSION }} run: | - git fetch origin tag ${{ steps.getMostRecentRelease.outputs.VERSION }} --no-tags --depth=1 - git switch --detach ${{ steps.getMostRecentRelease.outputs.VERSION }} - + previous_merge=$(git rev-list --merges HEAD~1 | head -n 1) + git checkout $previous_merge + echo $previous_merge - uses: Expensify/App/.github/actions/composite/buildAndroidE2EAPK@main - if: ${{ !fromJSON(steps.checkForExistingArtifact.outputs.ARTIFACT_FOUND) }} + # if: ${{ !fromJSON(steps.checkForExistingArtifact.outputs.ARTIFACT_FOUND) }} with: ARTIFACT_NAME: baseline-apk-${{ steps.getMostRecentRelease.outputs.VERSION }} PACKAGE_SCRIPT_NAME: android-build-e2e From 67bb835605d173c4ba77dda74205032faf926520 Mon Sep 17 00:00:00 2001 From: kirillzyusko Date: Thu, 29 Aug 2024 12:51:40 +0200 Subject: [PATCH 04/43] fix: do not use botify token --- .github/workflows/e2ePerformanceTests.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/e2ePerformanceTests.yml b/.github/workflows/e2ePerformanceTests.yml index a9bf38b996a..b643510400a 100644 --- a/.github/workflows/e2ePerformanceTests.yml +++ b/.github/workflows/e2ePerformanceTests.yml @@ -31,15 +31,15 @@ jobs: ARTIFACT_WORKFLOW_ID: ${{ steps.checkForExistingArtifact.outputs.ARTIFACT_WORKFLOW_ID }} steps: - uses: actions/checkout@v4 - with: - # The OS_BOTIFY_COMMIT_TOKEN is a personal access token tied to osbotify (we need a PAT to access the artifact API) - token: ${{ secrets.OS_BOTIFY_COMMIT_TOKEN }} - - - name: Get most recent release version - id: getMostRecentRelease - run: echo "VERSION=$(gh release list --limit 1 | awk '{ print $1 }')" >> "$GITHUB_OUTPUT" - env: - GITHUB_TOKEN: ${{ github.token }} + # with: + # # The OS_BOTIFY_COMMIT_TOKEN is a personal access token tied to osbotify (we need a PAT to access the artifact API) + # token: ${{ secrets.OS_BOTIFY_COMMIT_TOKEN }} + + # - name: Get most recent release version + # id: getMostRecentRelease + # run: echo "VERSION=$(gh release list --limit 1 | awk '{ print $1 }')" >> "$GITHUB_OUTPUT" + # env: + # GITHUB_TOKEN: ${{ github.token }} # - name: Check if there's an existing artifact for this baseline # id: checkForExistingArtifact From aad08b3cd43964316e026f216afd19aa0789bcc6 Mon Sep 17 00:00:00 2001 From: kirillzyusko Date: Thu, 29 Aug 2024 12:55:10 +0200 Subject: [PATCH 05/43] fix: fetch entire repo history for baseline build --- .github/workflows/e2ePerformanceTests.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/e2ePerformanceTests.yml b/.github/workflows/e2ePerformanceTests.yml index b643510400a..a3f6fdfa8d8 100644 --- a/.github/workflows/e2ePerformanceTests.yml +++ b/.github/workflows/e2ePerformanceTests.yml @@ -31,6 +31,8 @@ jobs: ARTIFACT_WORKFLOW_ID: ${{ steps.checkForExistingArtifact.outputs.ARTIFACT_WORKFLOW_ID }} steps: - uses: actions/checkout@v4 + with: + fetch-depth: 0 # Fetches the entire history # with: # # The OS_BOTIFY_COMMIT_TOKEN is a personal access token tied to osbotify (we need a PAT to access the artifact API) # token: ${{ secrets.OS_BOTIFY_COMMIT_TOKEN }} From d33ed612487217b0411431e9d5bceb8a8d6c4ee1 Mon Sep 17 00:00:00 2001 From: kirillzyusko Date: Thu, 29 Aug 2024 13:12:36 +0200 Subject: [PATCH 06/43] fix: cleanup build file --- .github/workflows/e2ePerformanceTests.yml | 33 +---------------------- 1 file changed, 1 insertion(+), 32 deletions(-) diff --git a/.github/workflows/e2ePerformanceTests.yml b/.github/workflows/e2ePerformanceTests.yml index a3f6fdfa8d8..6b3bff0eeb4 100644 --- a/.github/workflows/e2ePerformanceTests.yml +++ b/.github/workflows/e2ePerformanceTests.yml @@ -1,8 +1,6 @@ name: E2E Performance Tests on: - pull_request: - types: [opened, synchronize, reopened] workflow_call: inputs: PR_NUMBER: @@ -25,48 +23,19 @@ jobs: buildBaseline: runs-on: ubuntu-latest-xl name: Build apk from latest release as a baseline - outputs: - VERSION: ${{ steps.getMostRecentRelease.outputs.VERSION }} - ARTIFACT_FOUND: ${{ steps.checkForExistingArtifact.outputs.ARTIFACT_FOUND }} - ARTIFACT_WORKFLOW_ID: ${{ steps.checkForExistingArtifact.outputs.ARTIFACT_WORKFLOW_ID }} steps: - uses: actions/checkout@v4 with: fetch-depth: 0 # Fetches the entire history - # with: - # # The OS_BOTIFY_COMMIT_TOKEN is a personal access token tied to osbotify (we need a PAT to access the artifact API) - # token: ${{ secrets.OS_BOTIFY_COMMIT_TOKEN }} - - # - name: Get most recent release version - # id: getMostRecentRelease - # run: echo "VERSION=$(gh release list --limit 1 | awk '{ print $1 }')" >> "$GITHUB_OUTPUT" - # env: - # GITHUB_TOKEN: ${{ github.token }} - - # - name: Check if there's an existing artifact for this baseline - # id: checkForExistingArtifact - # uses: ./.github/actions/javascript/getArtifactInfo - # with: - # GITHUB_TOKEN: ${{ secrets.OS_BOTIFY_COMMIT_TOKEN }} - # ARTIFACT_NAME: baseline-apk-${{ steps.getMostRecentRelease.outputs.VERSION }} - - # - name: Skip build if there's already an existing artifact for the baseline - # if: ${{ fromJSON(steps.checkForExistingArtifact.outputs.ARTIFACT_FOUND) }} - # run: echo 'APK for baseline ${{ steps.getMostRecentRelease.outputs.VERSION }} already exists, reusing existing build' - name: Checkout "Baseline" commit (prev merge commit) - # if: ${{ !fromJSON(steps.checkForExistingArtifact.outputs.ARTIFACT_FOUND) }} - # run: | - # git fetch origin tag ${{ steps.getMostRecentRelease.outputs.VERSION }} --no-tags --depth=1 - # git switch --detach ${{ steps.getMostRecentRelease.outputs.VERSION }} run: | previous_merge=$(git rev-list --merges HEAD~1 | head -n 1) git checkout $previous_merge echo $previous_merge - uses: Expensify/App/.github/actions/composite/buildAndroidE2EAPK@main - # if: ${{ !fromJSON(steps.checkForExistingArtifact.outputs.ARTIFACT_FOUND) }} with: - ARTIFACT_NAME: baseline-apk-${{ steps.getMostRecentRelease.outputs.VERSION }} + ARTIFACT_NAME: "" PACKAGE_SCRIPT_NAME: android-build-e2e APP_OUTPUT_PATH: android/app/build/outputs/apk/e2e/release/app-e2e-release.apk MAPBOX_SDK_DOWNLOAD_TOKEN: ${{ secrets.MAPBOX_SDK_DOWNLOAD_TOKEN }} From 537c5e7c5b9c6e7d72f60678451da55864db5846 Mon Sep 17 00:00:00 2001 From: kirillzyusko Date: Thu, 29 Aug 2024 14:06:59 +0200 Subject: [PATCH 07/43] fix: provide identifiers to baseline artifact --- .github/workflows/e2ePerformanceTests.yml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/e2ePerformanceTests.yml b/.github/workflows/e2ePerformanceTests.yml index 6b3bff0eeb4..4306a73f866 100644 --- a/.github/workflows/e2ePerformanceTests.yml +++ b/.github/workflows/e2ePerformanceTests.yml @@ -23,19 +23,24 @@ jobs: buildBaseline: runs-on: ubuntu-latest-xl name: Build apk from latest release as a baseline + outputs: + BASELINE_REF: ${{ steps.getBaselineRef.outputs.BASELINE_REF }} steps: - uses: actions/checkout@v4 with: fetch-depth: 0 # Fetches the entire history - name: Checkout "Baseline" commit (prev merge commit) + id: getBaselineRef run: | previous_merge=$(git rev-list --merges HEAD~1 | head -n 1) git checkout $previous_merge echo $previous_merge + echo "BASELINE_REF=$previous_merge" >> "$GITHUB_OUTPUT" + - uses: Expensify/App/.github/actions/composite/buildAndroidE2EAPK@main with: - ARTIFACT_NAME: "" + ARTIFACT_NAME: baseline-apk-${{ steps.getBaselineRef.outputs.BASELINE_REF }} PACKAGE_SCRIPT_NAME: android-build-e2e APP_OUTPUT_PATH: android/app/build/outputs/apk/e2e/release/app-e2e-release.apk MAPBOX_SDK_DOWNLOAD_TOKEN: ${{ secrets.MAPBOX_SDK_DOWNLOAD_TOKEN }} @@ -137,11 +142,8 @@ jobs: uses: actions/download-artifact@v4 id: downloadBaselineAPK with: - name: baseline-apk-${{ needs.buildBaseline.outputs.VERSION }} + name: baseline-apk-${{ needs.buildBaseline.outputs.BASELINE_REF }} path: zip - # Set github-token only if the baseline was built in this workflow run: - github-token: ${{ needs.buildBaseline.outputs.ARTIFACT_WORKFLOW_ID && github.token }} - run-id: ${{ needs.buildBaseline.outputs.ARTIFACT_WORKFLOW_ID }} # The downloaded artifact will be a file named "app-e2e-release.apk" so we have to rename it - name: Rename baseline APK From 9c80dcf24c03d0631cd9ee62e9515278266a6d4d Mon Sep 17 00:00:00 2001 From: kirillzyusko Date: Thu, 29 Aug 2024 14:42:43 +0200 Subject: [PATCH 08/43] fix: action lint --- .github/workflows/e2ePerformanceTests.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/e2ePerformanceTests.yml b/.github/workflows/e2ePerformanceTests.yml index 4306a73f866..564f6218043 100644 --- a/.github/workflows/e2ePerformanceTests.yml +++ b/.github/workflows/e2ePerformanceTests.yml @@ -33,10 +33,10 @@ jobs: - name: Checkout "Baseline" commit (prev merge commit) id: getBaselineRef run: | - previous_merge=$(git rev-list --merges HEAD~1 | head -n 1) - git checkout $previous_merge - echo $previous_merge - echo "BASELINE_REF=$previous_merge" >> "$GITHUB_OUTPUT" + previous_merge=$(git rev-list --merges HEAD~1 | head -n 1) + git checkout $previous_merge + echo $previous_merge + echo "BASELINE_REF=$previous_merge" >> "$GITHUB_OUTPUT" - uses: Expensify/App/.github/actions/composite/buildAndroidE2EAPK@main with: From 6c7e327f9657c32faad7267e16c441f588ac7a26 Mon Sep 17 00:00:00 2001 From: kirillzyusko Date: Thu, 29 Aug 2024 16:10:20 +0200 Subject: [PATCH 09/43] fix: CI checks --- .github/workflows/e2ePerformanceTests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/e2ePerformanceTests.yml b/.github/workflows/e2ePerformanceTests.yml index 564f6218043..ee6248264cb 100644 --- a/.github/workflows/e2ePerformanceTests.yml +++ b/.github/workflows/e2ePerformanceTests.yml @@ -34,8 +34,8 @@ jobs: id: getBaselineRef run: | previous_merge=$(git rev-list --merges HEAD~1 | head -n 1) - git checkout $previous_merge - echo $previous_merge + git checkout "$previous_merge" + echo "$previous_merge" echo "BASELINE_REF=$previous_merge" >> "$GITHUB_OUTPUT" - uses: Expensify/App/.github/actions/composite/buildAndroidE2EAPK@main From f51fbdafff5badb0d7f11930cd6a01ac3e6ffd84 Mon Sep 17 00:00:00 2001 From: kirillzyusko Date: Thu, 29 Aug 2024 16:22:32 +0200 Subject: [PATCH 10/43] fix: rename job name --- .github/workflows/e2ePerformanceTests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/e2ePerformanceTests.yml b/.github/workflows/e2ePerformanceTests.yml index ee6248264cb..4a61feea04b 100644 --- a/.github/workflows/e2ePerformanceTests.yml +++ b/.github/workflows/e2ePerformanceTests.yml @@ -22,7 +22,7 @@ concurrency: jobs: buildBaseline: runs-on: ubuntu-latest-xl - name: Build apk from latest release as a baseline + name: Build apk from baseline outputs: BASELINE_REF: ${{ steps.getBaselineRef.outputs.BASELINE_REF }} steps: From 51f403cb111f94a2b17201e81d60b3bc6ad57022 Mon Sep 17 00:00:00 2001 From: Vit Horacek Date: Fri, 11 Oct 2024 12:18:11 +0200 Subject: [PATCH 11/43] Use the new API command to ship all physical expensify cards --- ... SetPersonalDetailsAndShipExpensifyCardsParams.ts} | 5 ++--- src/libs/API/parameters/index.ts | 2 +- src/libs/API/types.ts | 4 ++-- src/libs/actions/PersonalDetails.ts | 11 +++++------ .../MissingPersonalDetailsContent.tsx | 2 +- 5 files changed, 11 insertions(+), 13 deletions(-) rename src/libs/API/parameters/{SetMissingPersonalDetailsAndShipExpensifyCardParams.ts => SetPersonalDetailsAndShipExpensifyCardsParams.ts} (63%) diff --git a/src/libs/API/parameters/SetMissingPersonalDetailsAndShipExpensifyCardParams.ts b/src/libs/API/parameters/SetPersonalDetailsAndShipExpensifyCardsParams.ts similarity index 63% rename from src/libs/API/parameters/SetMissingPersonalDetailsAndShipExpensifyCardParams.ts rename to src/libs/API/parameters/SetPersonalDetailsAndShipExpensifyCardsParams.ts index 54d73aec5df..0ab82ba6b75 100644 --- a/src/libs/API/parameters/SetMissingPersonalDetailsAndShipExpensifyCardParams.ts +++ b/src/libs/API/parameters/SetPersonalDetailsAndShipExpensifyCardsParams.ts @@ -1,4 +1,4 @@ -type SetMissingPersonalDetailsAndShipExpensifyCardParams = { +type SetPersonalDetailsAndShipExpensifyCardsParams = { legalFirstName: string; legalLastName: string; phoneNumber: string; @@ -9,7 +9,6 @@ type SetMissingPersonalDetailsAndShipExpensifyCardParams = { addressCountry: string; addressState: string; dob: string; - cardID: number; }; -export default SetMissingPersonalDetailsAndShipExpensifyCardParams; +export default SetPersonalDetailsAndShipExpensifyCardsParams; diff --git a/src/libs/API/parameters/index.ts b/src/libs/API/parameters/index.ts index ed4798515c3..0df5e8dcaee 100644 --- a/src/libs/API/parameters/index.ts +++ b/src/libs/API/parameters/index.ts @@ -328,6 +328,6 @@ export type {default as UnassignCompanyCard} from './UnassignCompanyCard'; export type {default as UpdateCompanyCard} from './UpdateCompanyCard'; export type {default as UpdateCompanyCardNameParams} from './UpdateCompanyCardNameParams'; export type {default as SetCompanyCardExportAccountParams} from './SetCompanyCardExportAccountParams'; -export type {default as SetMissingPersonalDetailsAndShipExpensifyCardParams} from './SetMissingPersonalDetailsAndShipExpensifyCardParams'; +export type {default as SetPersonalDetailsAndShipExpensifyCardsParams} from './SetPersonalDetailsAndShipExpensifyCardsParams'; export type {default as SetInvoicingTransferBankAccountParams} from './SetInvoicingTransferBankAccountParams'; export type {default as ConnectPolicyToQuickBooksDesktopParams} from './ConnectPolicyToQuickBooksDesktopParams'; diff --git a/src/libs/API/types.ts b/src/libs/API/types.ts index d4f6e581a42..596eea8def5 100644 --- a/src/libs/API/types.ts +++ b/src/libs/API/types.ts @@ -408,7 +408,7 @@ const WRITE_COMMANDS = { UPDATE_COMPANY_CARD: 'SyncCard', UPDATE_COMPANY_CARD_NAME: 'SetCardName', SET_CARD_EXPORT_ACCOUNT: 'SetCardExportAccount', - SET_MISSING_PERSONAL_DETAILS_AND_SHIP_EXPENSIFY_CARD: 'SetMissingPersonalDetailsAndShipExpensifyCard', + SET_PERSONAL_DETAILS_AND_SHIP_EXPENSIFY_CARDS: 'SetPersonalDetailsAndShipExpensifyCards', SET_INVOICING_TRANSFER_BANK_ACCOUNT: 'SetInvoicingTransferBankAccount', } as const; @@ -810,7 +810,7 @@ type WriteCommandParameters = { [WRITE_COMMANDS.DELETE_SAVED_SEARCH]: Parameters.DeleteSavedSearchParams; [WRITE_COMMANDS.UPDATE_CARD_SETTLEMENT_FREQUENCY]: Parameters.UpdateCardSettlementFrequencyParams; [WRITE_COMMANDS.UPDATE_CARD_SETTLEMENT_ACCOUNT]: Parameters.UpdateCardSettlementAccountParams; - [WRITE_COMMANDS.SET_MISSING_PERSONAL_DETAILS_AND_SHIP_EXPENSIFY_CARD]: Parameters.SetMissingPersonalDetailsAndShipExpensifyCardParams; + [WRITE_COMMANDS.SET_PERSONAL_DETAILS_AND_SHIP_EXPENSIFY_CARDS]: Parameters.SetPersonalDetailsAndShipExpensifyCardsParams; // Xero API [WRITE_COMMANDS.UPDATE_XERO_TENANT_ID]: Parameters.UpdateXeroGenericTypeParams; diff --git a/src/libs/actions/PersonalDetails.ts b/src/libs/actions/PersonalDetails.ts index 7fb1c9a4cc7..4d8041b07bc 100644 --- a/src/libs/actions/PersonalDetails.ts +++ b/src/libs/actions/PersonalDetails.ts @@ -4,7 +4,7 @@ import type {FormOnyxValues} from '@components/Form/types'; import * as API from '@libs/API'; import type { OpenPublicProfilePageParams, - SetMissingPersonalDetailsAndShipExpensifyCardParams, + SetPersonalDetailsAndShipExpensifyCardsParams, UpdateAutomaticTimezoneParams, UpdateDateOfBirthParams, UpdateDisplayNameParams, @@ -428,8 +428,8 @@ function clearAvatarErrors() { }); } -function updatePersonalDetailsAndShipExpensifyCard(values: FormOnyxValues, cardID: number) { - const parameters: SetMissingPersonalDetailsAndShipExpensifyCardParams = { +function updatePersonalDetailsAndShipExpensifyCards(values: FormOnyxValues) { + const parameters: SetPersonalDetailsAndShipExpensifyCardsParams = { legalFirstName: values.legalFirstName?.trim() ?? '', legalLastName: values.legalLastName?.trim() ?? '', phoneNumber: LoginUtils.appendCountryCode(values.phoneNumber?.trim() ?? ''), @@ -440,10 +440,9 @@ function updatePersonalDetailsAndShipExpensifyCard(values: FormOnyxValues Date: Fri, 11 Oct 2024 12:23:39 +0200 Subject: [PATCH 12/43] Update the card shipment flow to not required cardID --- .../MissingPersonalDetailsContent.tsx | 11 ++++------- src/pages/MissingPersonalDetails/index.tsx | 4 +--- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/pages/MissingPersonalDetails/MissingPersonalDetailsContent.tsx b/src/pages/MissingPersonalDetails/MissingPersonalDetailsContent.tsx index eb646f59ffc..a3e4fa28e15 100644 --- a/src/pages/MissingPersonalDetails/MissingPersonalDetailsContent.tsx +++ b/src/pages/MissingPersonalDetails/MissingPersonalDetailsContent.tsx @@ -15,7 +15,7 @@ import * as PersonalDetails from '@userActions/PersonalDetails'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import type {PersonalDetailsForm} from '@src/types/form'; -import type {CardList, PrivatePersonalDetails} from '@src/types/onyx'; +import type {PrivatePersonalDetails} from '@src/types/onyx'; import Address from './substeps/Address'; import Confirmation from './substeps/Confirmation'; import DateOfBirth from './substeps/DateOfBirth'; @@ -26,13 +26,12 @@ import {getInitialSubstep, getSubstepValues} from './utils'; type MissingPersonalDetailsContentProps = { privatePersonalDetails: OnyxEntry; - cardList: OnyxEntry; draftValues: OnyxEntry; }; const formSteps = [LegalName, DateOfBirth, Address, PhoneNumber, Confirmation]; -function MissingPersonalDetailsContent({privatePersonalDetails, cardList, draftValues}: MissingPersonalDetailsContentProps) { +function MissingPersonalDetailsContent({privatePersonalDetails, draftValues}: MissingPersonalDetailsContentProps) { const styles = useThemeStyles(); const {translate} = useLocalize(); const ref: ForwardedRef = useRef(null); @@ -41,16 +40,14 @@ function MissingPersonalDetailsContent({privatePersonalDetails, cardList, draftV const startFrom = useMemo(() => getInitialSubstep(values), [values]); - const firstUnissuedCard = useMemo(() => Object.values(cardList ?? {}).find((card) => card.state === CONST.EXPENSIFY_CARD.STATE.STATE_NOT_ISSUED), [cardList]); - const handleFinishStep = useCallback(() => { if (!values) { return; } - PersonalDetails.updatePersonalDetailsAndShipExpensifyCards(values, firstUnissuedCard?.cardID ?? 0); + PersonalDetails.updatePersonalDetailsAndShipExpensifyCards(values); FormActions.clearDraftValues(ONYXKEYS.FORMS.PERSONAL_DETAILS_FORM); Navigation.goBack(); - }, [firstUnissuedCard?.cardID, values]); + }, [values]); const { componentToRender: SubStep, diff --git a/src/pages/MissingPersonalDetails/index.tsx b/src/pages/MissingPersonalDetails/index.tsx index 5c4f94b09b2..51f1b87c197 100644 --- a/src/pages/MissingPersonalDetails/index.tsx +++ b/src/pages/MissingPersonalDetails/index.tsx @@ -7,10 +7,9 @@ import MissingPersonalDetailsContent from './MissingPersonalDetailsContent'; function MissingPersonalDetails() { const [privatePersonalDetails, privatePersonalDetailsMetadata] = useOnyx(ONYXKEYS.PRIVATE_PERSONAL_DETAILS); - const [cardList, cardListMetadata] = useOnyx(ONYXKEYS.CARD_LIST); const [draftValues, draftValuesMetadata] = useOnyx(ONYXKEYS.FORMS.PERSONAL_DETAILS_FORM_DRAFT); - const isLoading = isLoadingOnyxValue(privatePersonalDetailsMetadata, cardListMetadata, draftValuesMetadata); + const isLoading = isLoadingOnyxValue(privatePersonalDetailsMetadata, draftValuesMetadata); if (isLoading) { return ; @@ -19,7 +18,6 @@ function MissingPersonalDetails() { return ( ); From c898e8be2bdec4178f086796af91e6810b73da4f Mon Sep 17 00:00:00 2001 From: truph01 Date: Mon, 14 Oct 2024 18:35:52 +0700 Subject: [PATCH 13/43] fix: remove link if card is deactivated --- .../ReportActionItem/IssueCardMessage.tsx | 17 ++++++++++++++++- src/libs/ReportActionsUtils.ts | 9 +++++---- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/components/ReportActionItem/IssueCardMessage.tsx b/src/components/ReportActionItem/IssueCardMessage.tsx index c9fa9a6f2df..9ac60e3a3a2 100644 --- a/src/components/ReportActionItem/IssueCardMessage.tsx +++ b/src/components/ReportActionItem/IssueCardMessage.tsx @@ -6,6 +6,7 @@ import RenderHTML from '@components/RenderHTML'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; import Navigation from '@libs/Navigation/Navigation'; +import * as PolicyUtils from '@libs/PolicyUtils'; import * as ReportActionsUtils from '@libs/ReportActionsUtils'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; @@ -24,6 +25,9 @@ function IssueCardMessage({action, policyID}: IssueCardMessageProps) { const styles = useThemeStyles(); const [privatePersonalDetails] = useOnyx(ONYXKEYS.PRIVATE_PERSONAL_DETAILS); const [session] = useOnyx(ONYXKEYS.SESSION); + const workspaceAccountID = PolicyUtils.getWorkspaceAccountID(policyID ?? '-1'); + const [cardList = {}] = useOnyx(ONYXKEYS.CARD_LIST); + const [cardsList] = useOnyx(`${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${workspaceAccountID}_${CONST.EXPENSIFY_CARD.BANK}`); const assigneeAccountID = (ReportActionsUtils.getOriginalMessage(action) as IssueNewCardOriginalMessage)?.assigneeAccountID; @@ -38,10 +42,21 @@ function IssueCardMessage({action, policyID}: IssueCardMessageProps) { const isAssigneeCurrentUser = !isEmptyObject(session) && session.accountID === assigneeAccountID; const shouldShowAddMissingDetailsButton = action?.actionName === CONST.REPORT.ACTIONS.TYPE.CARD_MISSING_ADDRESS && missingDetails && isAssigneeCurrentUser; + const cardIssuedActionOriginalMessage = ReportActionsUtils.isActionOfType( + action, + CONST.REPORT.ACTIONS.TYPE.CARD_ISSUED, + CONST.REPORT.ACTIONS.TYPE.CARD_ISSUED_VIRTUAL, + CONST.REPORT.ACTIONS.TYPE.CARD_MISSING_ADDRESS, + ) + ? ReportActionsUtils.getOriginalMessage(action) + : undefined; + const cardID = cardIssuedActionOriginalMessage?.cardID ?? -1; + const isPolicyAdmin = PolicyUtils.isPolicyAdmin(PolicyUtils.getPolicy(policyID)); + const card = isPolicyAdmin ? cardsList?.[cardID] : cardList[cardID]; return ( <> - ${ReportActionsUtils.getCardIssuedMessage(action, true, policyID)}`} /> + ${ReportActionsUtils.getCardIssuedMessage(action, true, policyID, !!card)}`} /> {shouldShowAddMissingDetailsButton && (