From d164b7ac3ebb6e9e5dc28f38a0bc5d1ef3600624 Mon Sep 17 00:00:00 2001 From: daledah Date: Wed, 19 Jun 2024 11:46:37 +0700 Subject: [PATCH 01/11] Workspace member has option to edit categories, which leads to not here page --- src/languages/en.ts | 4 ++ src/languages/es.ts | 4 ++ .../request/step/IOURequestStepCategory.tsx | 61 ++++++++++++++----- 3 files changed, 54 insertions(+), 15 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index e3eaafc54bd3..96d037128474 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -2193,7 +2193,11 @@ export default { subtitle: 'Get a better overview of where money is being spent. Use our default categories or add your own.', emptyCategories: { title: "You haven't created any categories", + memberTitle: (workspaceName: string) => `${workspaceName} doesn' have any categories enabled.`, subtitle: 'Add a category to organize your spend.', + otherWorkspace: 'Categorize this expense by choosing a different workspace, or ', + askYourAdmin: 'ask your admin', + enableForThisWorkspace: ' to enable categories for this workspace.', }, updateFailureMessage: 'An error occurred while updating the category, please try again.', createFailureMessage: 'An error occurred while creating the category, please try again.', diff --git a/src/languages/es.ts b/src/languages/es.ts index ece0f7f70cdb..1136b827ec45 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -2230,6 +2230,10 @@ export default { emptyCategories: { title: 'No has creado ninguna categoría', subtitle: 'Añade una categoría para organizar tu gasto.', + memberTitle: (workspaceName: string) => `${workspaceName} no tiene ninguna categoría activada.`, + otherWorkspace: 'Categorice este gasto eligiendo un espacio de trabajo diferente, o ', + askYourAdmin: 'pida a su administrador', + enableForThisWorkspace: ' que habilite categorías para este espacio de trabajo.', }, updateFailureMessage: 'Se ha producido un error al intentar eliminar la categoría. Por favor, inténtalo más tarde.', createFailureMessage: 'Se ha producido un error al intentar crear la categoría. Por favor, inténtalo más tarde.', diff --git a/src/pages/iou/request/step/IOURequestStepCategory.tsx b/src/pages/iou/request/step/IOURequestStepCategory.tsx index 18ddc19644ef..12032b07fd65 100644 --- a/src/pages/iou/request/step/IOURequestStepCategory.tsx +++ b/src/pages/iou/request/step/IOURequestStepCategory.tsx @@ -1,17 +1,20 @@ import lodashIsEmpty from 'lodash/isEmpty'; import React, {useEffect} from 'react'; +import type {ReactNode} from 'react'; import {ActivityIndicator, View} from 'react-native'; import type {OnyxEntry} from 'react-native-onyx'; import {withOnyx} from 'react-native-onyx'; import Button from '@components/Button'; import CategoryPicker from '@components/CategoryPicker'; import FixedFooter from '@components/FixedFooter'; +import Icon from '@components/Icon'; import * as Illustrations from '@components/Icon/Illustrations'; import type {ListItem} from '@components/SelectionList/types'; import Text from '@components/Text'; -import WorkspaceEmptyStateSection from '@components/WorkspaceEmptyStateSection'; +import TextLink from '@components/TextLink'; import useLocalize from '@hooks/useLocalize'; import useNetwork from '@hooks/useNetwork'; +import useResponsiveLayout from '@hooks/useResponsiveLayout'; import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; import Navigation from '@libs/Navigation/Navigation'; @@ -85,6 +88,8 @@ function IOURequestStepCategory({ const {translate} = useLocalize(); const isEditing = action === CONST.IOU.ACTION.EDIT; const isEditingSplitBill = isEditing && iouType === CONST.IOU.TYPE.SPLIT; + const isAdmin = policy?.role === CONST.POLICY.ROLE.ADMIN; + const {shouldUseNarrowLayout} = useResponsiveLayout(); const transactionCategory = ReportUtils.getTransactionDetails(isEditingSplitBill && !lodashIsEmpty(splitDraftTransaction) ? splitDraftTransaction : transaction)?.category; // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing @@ -151,6 +156,36 @@ function IOURequestStepCategory({ navigateBack(); }; + const renderCategoriesEmptyStateSection = (): ReactNode => ( + + + + + + + {isAdmin ? translate('workspace.categories.emptyCategories.title') : translate('workspace.categories.emptyCategories.memberTitle', policy?.name ?? '')} + + + + + {isAdmin ? ( + {translate('workspace.categories.emptyCategories.subtitle')} + ) : ( + + {translate('workspace.categories.emptyCategories.otherWorkspace')} + {}}>{translate('workspace.categories.emptyCategories.askYourAdmin')} + {translate('workspace.categories.emptyCategories.enableForThisWorkspace')} + + )} + + + + ); + return ( - + {renderCategoriesEmptyStateSection()}