From 0dce6c7c08ee3a1f8e9dfd9a29ba429d0c446781 Mon Sep 17 00:00:00 2001 From: Anusha Date: Fri, 20 Sep 2024 22:05:20 +0500 Subject: [PATCH 1/5] hide importspreadsheet button --- src/pages/workspace/categories/ImportCategoriesPage.tsx | 9 +++++++++ .../workspace/categories/ImportedCategoriesPage.tsx | 7 +++++++ .../workspace/categories/WorkspaceCategoriesPage.tsx | 9 +++++---- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/pages/workspace/categories/ImportCategoriesPage.tsx b/src/pages/workspace/categories/ImportCategoriesPage.tsx index c6e5439ec961..d0eecc54ab9c 100644 --- a/src/pages/workspace/categories/ImportCategoriesPage.tsx +++ b/src/pages/workspace/categories/ImportCategoriesPage.tsx @@ -1,7 +1,10 @@ import type {StackScreenProps} from '@react-navigation/stack'; import React from 'react'; import ImportSpreedsheet from '@components/ImportSpreadsheet'; +import usePolicy from '@hooks/usePolicy'; import type {SettingsNavigatorParamList} from '@libs/Navigation/types'; +import * as PolicyUtils from '@libs/PolicyUtils'; +import NotFoundPage from '@pages/ErrorPage/NotFoundPage'; import ROUTES from '@src/ROUTES'; import type SCREENS from '@src/SCREENS'; @@ -9,6 +12,12 @@ type ImportCategoriesPageProps = StackScreenProps; + } return ( { const roles = []; @@ -51,6 +54,10 @@ function ImportedCategoriesPage({route}: ImportedCategoriesPageProps) { const requiredColumns = columnRoles.filter((role) => role.isRequired).map((role) => role); + if (hasAccountingConnections) { + return ; + } + const validate = useCallback(() => { const columns = Object.values(spreadsheet?.columns ?? {}); let errors: Errors = {}; diff --git a/src/pages/workspace/categories/WorkspaceCategoriesPage.tsx b/src/pages/workspace/categories/WorkspaceCategoriesPage.tsx index 340bd991c609..4d84dab4dd69 100644 --- a/src/pages/workspace/categories/WorkspaceCategoriesPage.tsx +++ b/src/pages/workspace/categories/WorkspaceCategoriesPage.tsx @@ -301,8 +301,9 @@ function WorkspaceCategoriesPage({route}: WorkspaceCategoriesPageProps) { ); const threeDotsMenuItems = useMemo(() => { - const menuItems = [ - { + const menuItems = []; + if (!PolicyUtils.hasAccountingConnections(policy)) { + menuItems.push({ icon: Expensicons.Table, text: translate('spreadsheet.importSpreadsheet'), onSelected: () => { @@ -312,8 +313,8 @@ function WorkspaceCategoriesPage({route}: WorkspaceCategoriesPageProps) { } Navigation.navigate(ROUTES.WORKSPACE_CATEGORIES_IMPORT.getRoute(policyId)); }, - }, - ]; + }); + } if (hasVisibleCategories) { menuItems.push({ icon: Expensicons.Download, From 04b6602d80d7de5b1fa60c051c5e801b76f8a2ae Mon Sep 17 00:00:00 2001 From: Anusha Date: Fri, 20 Sep 2024 22:14:35 +0500 Subject: [PATCH 2/5] fix lint errors --- src/pages/workspace/categories/WorkspaceCategoriesPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/categories/WorkspaceCategoriesPage.tsx b/src/pages/workspace/categories/WorkspaceCategoriesPage.tsx index 4d84dab4dd69..407e309a3061 100644 --- a/src/pages/workspace/categories/WorkspaceCategoriesPage.tsx +++ b/src/pages/workspace/categories/WorkspaceCategoriesPage.tsx @@ -334,7 +334,7 @@ function WorkspaceCategoriesPage({route}: WorkspaceCategoriesPageProps) { } return menuItems; - }, [policyId, translate, isOffline, hasVisibleCategories]); + }, [policyId, translate, isOffline, hasVisibleCategories, policy]); const selectionModeHeader = selectionMode?.isEnabled && shouldUseNarrowLayout; From 56f035d0ff691fbf8fa2db0b8cf58c6fe73cb3ac Mon Sep 17 00:00:00 2001 From: Anusha Date: Fri, 20 Sep 2024 22:19:12 +0500 Subject: [PATCH 3/5] fix callback lint error --- .../workspace/categories/ImportedCategoriesPage.tsx | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/pages/workspace/categories/ImportedCategoriesPage.tsx b/src/pages/workspace/categories/ImportedCategoriesPage.tsx index 076eb87b1938..9171689e4134 100644 --- a/src/pages/workspace/categories/ImportedCategoriesPage.tsx +++ b/src/pages/workspace/categories/ImportedCategoriesPage.tsx @@ -33,7 +33,6 @@ function ImportedCategoriesPage({route}: ImportedCategoriesPageProps) { const [policyCategories] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${policyID}`); const policy = usePolicy(policyID); const columnNames = generateColumnNames(spreadsheet?.data?.length ?? 0); - const hasAccountingConnections = PolicyUtils.hasAccountingConnections(policy); const getColumnRoles = (): ColumnRole[] => { const roles = []; @@ -53,11 +52,6 @@ function ImportedCategoriesPage({route}: ImportedCategoriesPageProps) { const columnRoles = getColumnRoles(); const requiredColumns = columnRoles.filter((role) => role.isRequired).map((role) => role); - - if (hasAccountingConnections) { - return ; - } - const validate = useCallback(() => { const columns = Object.values(spreadsheet?.columns ?? {}); let errors: Errors = {}; @@ -112,6 +106,11 @@ function ImportedCategoriesPage({route}: ImportedCategoriesPageProps) { } }, [validate, spreadsheet, containsHeader, policyID, policyCategories]); + const hasAccountingConnections = PolicyUtils.hasAccountingConnections(policy); + if (hasAccountingConnections) { + return ; + } + const spreadsheetColumns = spreadsheet?.data; if (!spreadsheetColumns) { return; From 3d8eb02110a32b837405d4562cd35ce7f82c5f86 Mon Sep 17 00:00:00 2001 From: Anusha <93134676+Nodebrute@users.noreply.github.com> Date: Sat, 21 Sep 2024 01:17:50 +0500 Subject: [PATCH 4/5] add a line --- src/pages/workspace/categories/ImportedCategoriesPage.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pages/workspace/categories/ImportedCategoriesPage.tsx b/src/pages/workspace/categories/ImportedCategoriesPage.tsx index 9171689e4134..5d25c4a49996 100644 --- a/src/pages/workspace/categories/ImportedCategoriesPage.tsx +++ b/src/pages/workspace/categories/ImportedCategoriesPage.tsx @@ -52,6 +52,7 @@ function ImportedCategoriesPage({route}: ImportedCategoriesPageProps) { const columnRoles = getColumnRoles(); const requiredColumns = columnRoles.filter((role) => role.isRequired).map((role) => role); + const validate = useCallback(() => { const columns = Object.values(spreadsheet?.columns ?? {}); let errors: Errors = {}; From ea47bbe74cbbed218f99965280aed572c91e1960 Mon Sep 17 00:00:00 2001 From: Anusha Date: Sat, 21 Sep 2024 01:23:34 +0500 Subject: [PATCH 5/5] run prettier --- src/pages/workspace/categories/ImportedCategoriesPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/categories/ImportedCategoriesPage.tsx b/src/pages/workspace/categories/ImportedCategoriesPage.tsx index 5d25c4a49996..361337c91d63 100644 --- a/src/pages/workspace/categories/ImportedCategoriesPage.tsx +++ b/src/pages/workspace/categories/ImportedCategoriesPage.tsx @@ -52,7 +52,7 @@ function ImportedCategoriesPage({route}: ImportedCategoriesPageProps) { const columnRoles = getColumnRoles(); const requiredColumns = columnRoles.filter((role) => role.isRequired).map((role) => role); - + const validate = useCallback(() => { const columns = Object.values(spreadsheet?.columns ?? {}); let errors: Errors = {};