From 45f2288008c5df1c08163ff817edc7f84f1b1e5b Mon Sep 17 00:00:00 2001 From: Hans Date: Fri, 3 May 2024 15:05:15 +0700 Subject: [PATCH] update selected bank account --- .../xero/advanced/XeroAdvancedPage.tsx | 19 +++++++++++++------ .../XeroInvoiceAccountSelectorPage.tsx | 1 - 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/pages/workspace/accounting/xero/advanced/XeroAdvancedPage.tsx b/src/pages/workspace/accounting/xero/advanced/XeroAdvancedPage.tsx index cbb9f8cc608b..7ce1850b13b6 100644 --- a/src/pages/workspace/accounting/xero/advanced/XeroAdvancedPage.tsx +++ b/src/pages/workspace/accounting/xero/advanced/XeroAdvancedPage.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { useMemo } from 'react'; import ConnectionLayout from '@components/ConnectionLayout'; import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription'; import OfflineWithFeedback from '@components/OfflineWithFeedback'; @@ -19,9 +19,16 @@ function XeroAdvancedPage({policy}: WithPolicyConnectionsProps) { const {translate} = useLocalize(); const policyID = policy?.id ?? ''; - const xeroConfig = policy?.connections?.xero?.config; - const {autoSync, pendingFields, sync} = xeroConfig ?? {}; - const xeroData = policy?.connections?.xero?.data; + const xeroConfig = policy?.connections?.xero?.config; + const {autoSync, pendingFields, sync, } = xeroConfig ?? {}; + const {bankAccounts} = policy?.connections?.xero?.data ?? {}; + + const selectedBankAccountName = useMemo(() => { + const {invoiceCollectionsAccountID} = sync ?? {}; + const selectedAccount = (bankAccounts ?? []).find((bank) => bank.id === invoiceCollectionsAccountID); + + return selectedAccount?.name ?? ''; + }, [sync, bankAccounts]); return (