From eda2c6bbfb4ebd7da97db727982969e7f75e22a4 Mon Sep 17 00:00:00 2001 From: Rutika Pawar <183392827+twilight2294@users.noreply.github.com> Date: Fri, 22 Nov 2024 23:24:32 +0530 Subject: [PATCH 1/3] set default bank account when none is selected on selector --- .../accounting/xero/export/XeroBankAccountSelectPage.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/pages/workspace/accounting/xero/export/XeroBankAccountSelectPage.tsx b/src/pages/workspace/accounting/xero/export/XeroBankAccountSelectPage.tsx index 040b89a436e6..cc9c47b02dc7 100644 --- a/src/pages/workspace/accounting/xero/export/XeroBankAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/xero/export/XeroBankAccountSelectPage.tsx @@ -27,9 +27,10 @@ function XeroBankAccountSelectPage({policy}: WithPolicyConnectionsProps) { const policyID = policy?.id ?? '-1'; const {config} = policy?.connections?.xero ?? {}; + const {bankAccounts} = policy?.connections?.xero?.data ?? {}; const xeroSelectorOptions = useMemo( - () => getXeroBankAccounts(policy ?? undefined, config?.export?.nonReimbursableAccount), - [config?.export?.nonReimbursableAccount, policy], + () => getXeroBankAccounts(policy ?? undefined, config?.export?.nonReimbursableAccount || bankAccounts?.[0]?.id), + [config?.export?.nonReimbursableAccount, policy, bankAccounts], ); const listHeaderComponent = useMemo( From 33fa79656b4de4239e9ccde3a6d8299de1cb144b Mon Sep 17 00:00:00 2001 From: Rutika Pawar <183392827+twilight2294@users.noreply.github.com> Date: Sun, 24 Nov 2024 21:32:38 +0530 Subject: [PATCH 2/3] supress typescript error as the variable is an empty string --- .../accounting/xero/export/XeroBankAccountSelectPage.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/pages/workspace/accounting/xero/export/XeroBankAccountSelectPage.tsx b/src/pages/workspace/accounting/xero/export/XeroBankAccountSelectPage.tsx index cc9c47b02dc7..ebb4a1a4f214 100644 --- a/src/pages/workspace/accounting/xero/export/XeroBankAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/xero/export/XeroBankAccountSelectPage.tsx @@ -28,6 +28,8 @@ function XeroBankAccountSelectPage({policy}: WithPolicyConnectionsProps) { const {config} = policy?.connections?.xero ?? {}; const {bankAccounts} = policy?.connections?.xero?.data ?? {}; + + // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing nonReimbursableAccount is an empty string so we cannot use `??` const xeroSelectorOptions = useMemo( () => getXeroBankAccounts(policy ?? undefined, config?.export?.nonReimbursableAccount || bankAccounts?.[0]?.id), [config?.export?.nonReimbursableAccount, policy, bankAccounts], From 71d18bdd909fb43347e11fe371d6d3f6433987e6 Mon Sep 17 00:00:00 2001 From: Rutika Pawar <183392827+twilight2294@users.noreply.github.com> Date: Sun, 24 Nov 2024 21:38:45 +0530 Subject: [PATCH 3/3] fix lint and comment --- .../accounting/xero/export/XeroBankAccountSelectPage.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/pages/workspace/accounting/xero/export/XeroBankAccountSelectPage.tsx b/src/pages/workspace/accounting/xero/export/XeroBankAccountSelectPage.tsx index ebb4a1a4f214..a8a7eb10b0e0 100644 --- a/src/pages/workspace/accounting/xero/export/XeroBankAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/xero/export/XeroBankAccountSelectPage.tsx @@ -28,9 +28,8 @@ function XeroBankAccountSelectPage({policy}: WithPolicyConnectionsProps) { const {config} = policy?.connections?.xero ?? {}; const {bankAccounts} = policy?.connections?.xero?.data ?? {}; - - // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing nonReimbursableAccount is an empty string so we cannot use `??` const xeroSelectorOptions = useMemo( + // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing () => getXeroBankAccounts(policy ?? undefined, config?.export?.nonReimbursableAccount || bankAccounts?.[0]?.id), [config?.export?.nonReimbursableAccount, policy, bankAccounts], );