From a4cc8971a93f0d05c889bfc9d9a5f9c3bcce2fa1 Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Fri, 3 May 2024 11:37:53 +0700 Subject: [PATCH 01/13] Display error when deleting receipt failure --- src/languages/en.ts | 1 + src/languages/es.ts | 1 + src/libs/actions/IOU.ts | 5 ++++- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index a81589f634a3..1e327edf99c3 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -714,6 +714,7 @@ export default { other: 'Unexpected error, please try again later.', genericCreateFailureMessage: 'Unexpected error submitting this expense. Please try again later.', genericCreateInvoiceFailureMessage: 'Unexpected error sending invoice, please try again later.', + receiptDeleteFailureError: 'Unexpected error deleting this receipt. Please try again later.', // eslint-disable-next-line rulesdir/use-periods-for-error-messages receiptFailureMessage: "The receipt didn't upload. ", // eslint-disable-next-line rulesdir/use-periods-for-error-messages diff --git a/src/languages/es.ts b/src/languages/es.ts index cbedd0c555a4..4e5257f3bf8e 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -709,6 +709,7 @@ export default { other: 'Error inesperado, por favor inténtalo más tarde.', genericCreateFailureMessage: 'Error inesperado al enviar este gasto. Por favor, inténtalo más tarde.', genericCreateInvoiceFailureMessage: 'Error inesperado al enviar la factura, inténtalo de nuevo más tarde.', + receiptDeleteFailureError: 'Error inesperado al borrar este recibo. Vuelva a intentarlo más tarde.', // eslint-disable-next-line rulesdir/use-periods-for-error-messages receiptFailureMessage: 'El recibo no se subió. ', // eslint-disable-next-line rulesdir/use-periods-for-error-messages diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index e0b406ad9c45..1a3391fa6d18 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -6250,7 +6250,10 @@ function detachReceipt(transactionID: string) { { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, - value: transaction, + value: { + ...transaction, + errors: ErrorUtils.getMicroSecondOnyxError('iou.error.receiptDeleteFailureError'), + }, }, ]; From 4c12752804ee1f5688656ce0a9b069ed7f62da0a Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Mon, 6 May 2024 11:09:58 +0700 Subject: [PATCH 02/13] update translation --- src/languages/es.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/languages/es.ts b/src/languages/es.ts index b379a342de1d..fb97e1ce675f 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -710,7 +710,7 @@ export default { other: 'Error inesperado, por favor inténtalo más tarde.', genericCreateFailureMessage: 'Error inesperado al enviar este gasto. Por favor, inténtalo más tarde.', genericCreateInvoiceFailureMessage: 'Error inesperado al enviar la factura, inténtalo de nuevo más tarde.', - receiptDeleteFailureError: 'Error inesperado al borrar este recibo. Vuelva a intentarlo más tarde.', + receiptDeleteFailureError: 'Error inesperado al borrar este recibo. Vuelve a intentarlo más tarde.', // eslint-disable-next-line rulesdir/use-periods-for-error-messages receiptFailureMessage: 'El recibo no se subió. ', // eslint-disable-next-line rulesdir/use-periods-for-error-messages From 016944fd82f9e18812448e7393f95c9dadcfa2ad Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Mon, 6 May 2024 11:13:18 +0700 Subject: [PATCH 03/13] Fix close button is not aligned --- src/components/ReportActionItem/MoneyRequestView.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/ReportActionItem/MoneyRequestView.tsx b/src/components/ReportActionItem/MoneyRequestView.tsx index 9b7bfb2c2f17..c3c505cfce2c 100644 --- a/src/components/ReportActionItem/MoneyRequestView.tsx +++ b/src/components/ReportActionItem/MoneyRequestView.tsx @@ -346,7 +346,7 @@ function MoneyRequestView({ { if (!transaction?.transactionID) { return; From 794e31377ff01185d993e840337986754669d3e6 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 10 May 2024 15:13:40 +0530 Subject: [PATCH 04/13] remove subtitle and add header subtitle --- src/components/ConnectionLayout.tsx | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/src/components/ConnectionLayout.tsx b/src/components/ConnectionLayout.tsx index a91dea9bfc92..b22a7d094fef 100644 --- a/src/components/ConnectionLayout.tsx +++ b/src/components/ConnectionLayout.tsx @@ -20,15 +20,15 @@ type ConnectionLayoutProps = { /** Header title for the connection */ headerTitle: TranslationPaths; + /** The subtitle to show in the header */ + headerSubtitle?: string; + /** React nodes that will be shown */ children?: React.ReactNode; /** Title of the connection component */ title?: TranslationPaths; - /** Subtitle of the connection */ - subtitle?: TranslationPaths; - /** The current policyID */ policyID: string; @@ -44,22 +44,18 @@ type ConnectionLayoutProps = { /** Style of the title text */ titleStyle?: StyleProp | undefined; - /** Style of the subtitle text */ - subTitleStyle?: StyleProp | undefined; - /** Whether to use ScrollView or not */ shouldUseScrollView?: boolean; }; -type ConnectionLayoutContentProps = Pick; +type ConnectionLayoutContentProps = Pick; -function ConnectionLayoutContent({title, titleStyle, subtitle, subTitleStyle, children}: ConnectionLayoutContentProps) { +function ConnectionLayoutContent({title, titleStyle, children}: ConnectionLayoutContentProps) { const {translate} = useLocalize(); const styles = useThemeStyles(); return ( <> {title && {translate(title)}} - {subtitle && {translate(subtitle)}} {children} ); @@ -70,13 +66,12 @@ function ConnectionLayout({ headerTitle, children, title, - subtitle, + headerSubtitle: subtitle, policyID, accessVariants, featureName, contentContainerStyle, titleStyle, - subTitleStyle, shouldUseScrollView = true, }: ConnectionLayoutProps) { const {translate} = useLocalize(); @@ -85,14 +80,12 @@ function ConnectionLayout({ () => ( {children} ), - [title, subtitle, titleStyle, subTitleStyle, children], + [title, titleStyle, children], ); return ( @@ -108,6 +101,7 @@ function ConnectionLayout({ > Navigation.goBack()} /> {shouldUseScrollView ? ( From 4daa8b9eef8ae99ddd9d154938ba744166f1aae2 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 10 May 2024 15:14:36 +0530 Subject: [PATCH 05/13] show org name in export page --- .../accounting/xero/export/XeroExportConfigurationPage.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/pages/workspace/accounting/xero/export/XeroExportConfigurationPage.tsx b/src/pages/workspace/accounting/xero/export/XeroExportConfigurationPage.tsx index 934c41dab614..bb02a28dd1bf 100644 --- a/src/pages/workspace/accounting/xero/export/XeroExportConfigurationPage.tsx +++ b/src/pages/workspace/accounting/xero/export/XeroExportConfigurationPage.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, {useMemo} from 'react'; import ConnectionLayout from '@components/ConnectionLayout'; import type {MenuItemProps} from '@components/MenuItem'; import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription'; @@ -6,6 +6,7 @@ import OfflineWithFeedback from '@components/OfflineWithFeedback'; import type {OfflineWithFeedbackProps} from '@components/OfflineWithFeedback'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; +import {findCurrentXeroOrganization, getXeroTenants} from '@libs/PolicyUtils'; import type {WithPolicyConnectionsProps} from '@pages/workspace/withPolicyConnections'; import withPolicyConnections from '@pages/workspace/withPolicyConnections'; import CONST from '@src/CONST'; @@ -19,6 +20,9 @@ function XeroExportConfigurationPage({policy}: WithPolicyConnectionsProps) { const policyOwner = policy?.owner ?? ''; const {export: exportConfiguration, errorFields, pendingFields} = policy?.connections?.xero?.config ?? {}; + const tenants = useMemo(() => getXeroTenants(policy ?? undefined), [policy]); + const currentXeroOrganization = findCurrentXeroOrganization(tenants, policy?.connections?.xero?.config?.tenantID); + const menuItems: MenuItem[] = [ { description: translate('workspace.xero.preferredExporter'), @@ -77,6 +81,7 @@ function XeroExportConfigurationPage({policy}: WithPolicyConnectionsProps) { Date: Fri, 10 May 2024 15:14:47 +0530 Subject: [PATCH 06/13] show org name in adv page --- .../workspace/accounting/xero/advanced/XeroAdvancedPage.tsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/pages/workspace/accounting/xero/advanced/XeroAdvancedPage.tsx b/src/pages/workspace/accounting/xero/advanced/XeroAdvancedPage.tsx index 154f5f8a97f9..11781bb5707f 100644 --- a/src/pages/workspace/accounting/xero/advanced/XeroAdvancedPage.tsx +++ b/src/pages/workspace/accounting/xero/advanced/XeroAdvancedPage.tsx @@ -7,6 +7,7 @@ import useThemeStyles from '@hooks/useThemeStyles'; import * as Connections from '@libs/actions/connections'; import * as ErrorUtils from '@libs/ErrorUtils'; import Navigation from '@libs/Navigation/Navigation'; +import {findCurrentXeroOrganization, getXeroTenants} from '@libs/PolicyUtils'; import type {WithPolicyConnectionsProps} from '@pages/workspace/withPolicyConnections'; import withPolicyConnections from '@pages/workspace/withPolicyConnections'; import ToggleSettingOptionRow from '@pages/workspace/workflows/ToggleSettingsOptionRow'; @@ -30,10 +31,14 @@ function XeroAdvancedPage({policy}: WithPolicyConnectionsProps) { return selectedAccount?.name ?? ''; }, [bankAccounts, invoiceCollectionsAccountID]); + const tenants = useMemo(() => getXeroTenants(policy ?? undefined), [policy]); + const currentXeroOrganization = findCurrentXeroOrganization(tenants, policy?.connections?.xero?.config?.tenantID); + return ( Date: Fri, 10 May 2024 15:24:40 +0530 Subject: [PATCH 07/13] rename to header subtitle --- src/components/ConnectionLayout.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/ConnectionLayout.tsx b/src/components/ConnectionLayout.tsx index b22a7d094fef..8abe0e5759fc 100644 --- a/src/components/ConnectionLayout.tsx +++ b/src/components/ConnectionLayout.tsx @@ -66,7 +66,7 @@ function ConnectionLayout({ headerTitle, children, title, - headerSubtitle: subtitle, + headerSubtitle, policyID, accessVariants, featureName, @@ -101,7 +101,7 @@ function ConnectionLayout({ > Navigation.goBack()} /> {shouldUseScrollView ? ( From 3c386ab9fe085be16a7e65cc61a75b8d93584fd7 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 10 May 2024 16:41:55 +0530 Subject: [PATCH 08/13] add get org name util --- src/libs/PolicyUtils.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/libs/PolicyUtils.ts b/src/libs/PolicyUtils.ts index 51221ddb1236..433bfd01d426 100644 --- a/src/libs/PolicyUtils.ts +++ b/src/libs/PolicyUtils.ts @@ -406,6 +406,10 @@ function findCurrentXeroOrganization(tenants: Tenant[] | undefined, organization return tenants?.find((tenant) => tenant.id === organizationID); } +function getCurrentXeroOrganizationName(policy: Policy | undefined): string | undefined { + return findCurrentXeroOrganization(getXeroTenants(policy), policy?.connections?.xero?.config?.tenantID)?.name; +} + export { getActivePolicies, hasAccountingConnections, @@ -453,6 +457,7 @@ export { canSendInvoice, getXeroTenants, findCurrentXeroOrganization, + getCurrentXeroOrganizationName, }; export type {MemberEmailsToAccountIDs}; From 51db1474d46752ab8a1737c5b79bdb0ecffaf5ce Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 10 May 2024 16:42:13 +0530 Subject: [PATCH 09/13] use get org util --- src/pages/workspace/accounting/PolicyAccountingPage.tsx | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/pages/workspace/accounting/PolicyAccountingPage.tsx b/src/pages/workspace/accounting/PolicyAccountingPage.tsx index fbd5b669fa62..1c27618950c6 100644 --- a/src/pages/workspace/accounting/PolicyAccountingPage.tsx +++ b/src/pages/workspace/accounting/PolicyAccountingPage.tsx @@ -25,7 +25,7 @@ import useThemeStyles from '@hooks/useThemeStyles'; import useWindowDimensions from '@hooks/useWindowDimensions'; import {removePolicyConnection} from '@libs/actions/connections'; import {syncConnection} from '@libs/actions/connections/QuickBooksOnline'; -import {findCurrentXeroOrganization, getXeroTenants} from '@libs/PolicyUtils'; +import {getCurrentXeroOrganizationName, getXeroTenants} from '@libs/PolicyUtils'; import Navigation from '@navigation/Navigation'; import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; @@ -120,8 +120,7 @@ function PolicyAccountingPage({policy, connectionSyncProgress}: PolicyAccounting const policyConnectedToXero = connectedIntegration === CONST.POLICY.CONNECTIONS.NAME.XERO; const tenants = useMemo(() => getXeroTenants(policy), [policy]); - - const currentXeroOrganization = findCurrentXeroOrganization(tenants, policy?.connections?.xero?.config?.tenantID); + const currentXeroOrganizationName = useMemo(() => getCurrentXeroOrganizationName(policy), [policy]); const overflowMenu: ThreeDotsMenuProps['menuItems'] = useMemo( () => [ @@ -200,7 +199,7 @@ function PolicyAccountingPage({policy, connectionSyncProgress}: PolicyAccounting { description: translate('workspace.xero.organization'), iconRight: Expensicons.ArrowRight, - title: currentXeroOrganization?.name, + title: currentXeroOrganizationName, wrapperStyle: [styles.sectionMenuItemTopDescription], titleStyle: styles.fontWeightNormal, shouldShowRightIcon: tenants.length > 1, @@ -246,7 +245,7 @@ function PolicyAccountingPage({policy, connectionSyncProgress}: PolicyAccounting }, [ connectedIntegration, connectionSyncProgress?.stageInProgress, - currentXeroOrganization, + currentXeroOrganizationName, tenants, isSyncInProgress, overflowMenu, From 60160e1d80f17139a796cfb134126e8a6c0543d1 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 10 May 2024 16:42:28 +0530 Subject: [PATCH 10/13] use get org util --- .../accounting/xero/advanced/XeroAdvancedPage.tsx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/pages/workspace/accounting/xero/advanced/XeroAdvancedPage.tsx b/src/pages/workspace/accounting/xero/advanced/XeroAdvancedPage.tsx index 11781bb5707f..b2646d5b8c55 100644 --- a/src/pages/workspace/accounting/xero/advanced/XeroAdvancedPage.tsx +++ b/src/pages/workspace/accounting/xero/advanced/XeroAdvancedPage.tsx @@ -7,7 +7,7 @@ import useThemeStyles from '@hooks/useThemeStyles'; import * as Connections from '@libs/actions/connections'; import * as ErrorUtils from '@libs/ErrorUtils'; import Navigation from '@libs/Navigation/Navigation'; -import {findCurrentXeroOrganization, getXeroTenants} from '@libs/PolicyUtils'; +import {getCurrentXeroOrganizationName} from '@libs/PolicyUtils'; import type {WithPolicyConnectionsProps} from '@pages/workspace/withPolicyConnections'; import withPolicyConnections from '@pages/workspace/withPolicyConnections'; import ToggleSettingOptionRow from '@pages/workspace/workflows/ToggleSettingsOptionRow'; @@ -31,14 +31,13 @@ function XeroAdvancedPage({policy}: WithPolicyConnectionsProps) { return selectedAccount?.name ?? ''; }, [bankAccounts, invoiceCollectionsAccountID]); - const tenants = useMemo(() => getXeroTenants(policy ?? undefined), [policy]); - const currentXeroOrganization = findCurrentXeroOrganization(tenants, policy?.connections?.xero?.config?.tenantID); + const currentXeroOrganizationName = useMemo(() => getCurrentXeroOrganizationName(policy ?? undefined), [policy]); return ( Date: Fri, 10 May 2024 16:42:36 +0530 Subject: [PATCH 11/13] use get org util --- src/pages/workspace/accounting/xero/XeroImportPage.tsx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/pages/workspace/accounting/xero/XeroImportPage.tsx b/src/pages/workspace/accounting/xero/XeroImportPage.tsx index fbd0d6add7e5..c069e5adfa75 100644 --- a/src/pages/workspace/accounting/xero/XeroImportPage.tsx +++ b/src/pages/workspace/accounting/xero/XeroImportPage.tsx @@ -8,7 +8,7 @@ import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; import Navigation from '@libs/Navigation/Navigation'; -import {getXeroTenants} from '@libs/PolicyUtils'; +import {getCurrentXeroOrganizationName} from '@libs/PolicyUtils'; import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper'; import withPolicy from '@pages/workspace/withPolicy'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; @@ -22,8 +22,7 @@ function XeroImportPage({policy}: WithPolicyProps) { const policyID = policy?.id ?? ''; const {importCustomers, importTaxRates, importTrackingCategories, pendingFields} = policy?.connections?.xero?.config ?? {}; - const tenants = useMemo(() => getXeroTenants(policy ?? undefined), [policy]); - const currentXeroOrganization = tenants.find((tenant) => tenant.id === policy?.connections?.xero.config.tenantID); + const currentXeroOrganizationName = useMemo(() => getCurrentXeroOrganizationName(policy ?? undefined), [policy]); const sections = useMemo( () => [ @@ -88,7 +87,7 @@ function XeroImportPage({policy}: WithPolicyProps) { > {translate('workspace.xero.importDescription')} From edba2778fb410a3deb432967a79c94130210fa3f Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 10 May 2024 16:42:42 +0530 Subject: [PATCH 12/13] use get org util --- .../accounting/xero/export/XeroExportConfigurationPage.tsx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/pages/workspace/accounting/xero/export/XeroExportConfigurationPage.tsx b/src/pages/workspace/accounting/xero/export/XeroExportConfigurationPage.tsx index bb02a28dd1bf..9f5a8bfc3273 100644 --- a/src/pages/workspace/accounting/xero/export/XeroExportConfigurationPage.tsx +++ b/src/pages/workspace/accounting/xero/export/XeroExportConfigurationPage.tsx @@ -6,7 +6,7 @@ import OfflineWithFeedback from '@components/OfflineWithFeedback'; import type {OfflineWithFeedbackProps} from '@components/OfflineWithFeedback'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; -import {findCurrentXeroOrganization, getXeroTenants} from '@libs/PolicyUtils'; +import {getCurrentXeroOrganizationName} from '@libs/PolicyUtils'; import type {WithPolicyConnectionsProps} from '@pages/workspace/withPolicyConnections'; import withPolicyConnections from '@pages/workspace/withPolicyConnections'; import CONST from '@src/CONST'; @@ -20,8 +20,7 @@ function XeroExportConfigurationPage({policy}: WithPolicyConnectionsProps) { const policyOwner = policy?.owner ?? ''; const {export: exportConfiguration, errorFields, pendingFields} = policy?.connections?.xero?.config ?? {}; - const tenants = useMemo(() => getXeroTenants(policy ?? undefined), [policy]); - const currentXeroOrganization = findCurrentXeroOrganization(tenants, policy?.connections?.xero?.config?.tenantID); + const currentXeroOrganizationName = useMemo(() => getCurrentXeroOrganizationName(policy ?? undefined), [policy]); const menuItems: MenuItem[] = [ { @@ -81,7 +80,7 @@ function XeroExportConfigurationPage({policy}: WithPolicyConnectionsProps) { Date: Fri, 10 May 2024 16:48:15 +0530 Subject: [PATCH 13/13] fix lint --- src/pages/workspace/accounting/PolicyAccountingPage.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/pages/workspace/accounting/PolicyAccountingPage.tsx b/src/pages/workspace/accounting/PolicyAccountingPage.tsx index 25f57efb0f3d..c6a63c3f61cc 100644 --- a/src/pages/workspace/accounting/PolicyAccountingPage.tsx +++ b/src/pages/workspace/accounting/PolicyAccountingPage.tsx @@ -25,7 +25,7 @@ import useThemeStyles from '@hooks/useThemeStyles'; import useWindowDimensions from '@hooks/useWindowDimensions'; import {removePolicyConnection} from '@libs/actions/connections'; import {syncConnection} from '@libs/actions/connections/QuickBooksOnline'; -import {getCurrentXeroOrganizationName, getXeroTenants} from '@libs/PolicyUtils'; +import {findCurrentXeroOrganization, getCurrentXeroOrganizationName, getXeroTenants} from '@libs/PolicyUtils'; import Navigation from '@navigation/Navigation'; import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; @@ -120,6 +120,7 @@ function PolicyAccountingPage({policy, connectionSyncProgress}: PolicyAccounting const policyConnectedToXero = connectedIntegration === CONST.POLICY.CONNECTIONS.NAME.XERO; const tenants = useMemo(() => getXeroTenants(policy), [policy]); + const currentXeroOrganization = findCurrentXeroOrganization(tenants, policy?.connections?.xero?.config?.tenantID); const currentXeroOrganizationName = useMemo(() => getCurrentXeroOrganizationName(policy), [policy]); const overflowMenu: ThreeDotsMenuProps['menuItems'] = useMemo( @@ -245,6 +246,7 @@ function PolicyAccountingPage({policy, connectionSyncProgress}: PolicyAccounting }, [ connectedIntegration, connectionSyncProgress?.stageInProgress, + currentXeroOrganization, currentXeroOrganizationName, tenants, isSyncInProgress,