From ae379c03d7a6e751064dcd9b63b890652561b684 Mon Sep 17 00:00:00 2001 From: Artem Makushov Date: Wed, 2 Oct 2024 16:23:10 +0200 Subject: [PATCH 1/5] add translations --- src/languages/en.ts | 1 + src/languages/es.ts | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/languages/en.ts b/src/languages/en.ts index ae5a9314d72..4a140dbba80 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -2290,6 +2290,7 @@ const translations = { }), settlementFrequency: 'Settlement frequency', deleteConfirmation: 'Are you sure you want to delete this workspace?', + deleteWithCardsConfirmation: 'Are you sure you want to delete this workspace? This will remove all card feeds and assigned cards', unavailable: 'Unavailable workspace', memberNotFound: 'Member not found. To invite a new member to the workspace, please use the invite button above.', notAuthorized: `You don't have access to this page. If you're trying to join this workspace, just ask the workspace owner to add you as a member. Something else? Reach out to ${CONST.EMAIL.CONCIERGE}.`, diff --git a/src/languages/es.ts b/src/languages/es.ts index 71cb5037029..3864338724e 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -2310,6 +2310,8 @@ const translations = { }), settlementFrequency: 'Frecuencia de liquidación', deleteConfirmation: '¿Estás seguro de que quieres eliminar este espacio de trabajo?', + deleteWithCardsConfirmation: + '¿Estás seguro de que quieres eliminar este espacio de trabajo? De este modo, se eliminarán todos los datos de las tarjetas y las tarjetas asignadas.', unavailable: 'Espacio de trabajo no disponible', memberNotFound: 'Miembro no encontrado. Para invitar a un nuevo miembro al espacio de trabajo, por favor, utiliza el botón invitar que está arriba.', notAuthorized: `No tienes acceso a esta página. Si estás intentando unirte a este espacio de trabajo, pide al dueño del espacio de trabajo que te añada como miembro. ¿Necesitas algo más? Comunícate con ${CONST.EMAIL.CONCIERGE}`, From af2d2c6fae67be99b97ccd619c9aa71821b5082f Mon Sep 17 00:00:00 2001 From: Artem Makushov Date: Thu, 3 Oct 2024 16:22:52 +0200 Subject: [PATCH 2/5] update delte translation with cards --- src/pages/workspace/WorkspaceProfilePage.tsx | 10 ++++++++-- src/pages/workspace/WorkspacesListPage.tsx | 8 +++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/pages/workspace/WorkspaceProfilePage.tsx b/src/pages/workspace/WorkspaceProfilePage.tsx index cbd43fd1752..3400943cb6d 100644 --- a/src/pages/workspace/WorkspaceProfilePage.tsx +++ b/src/pages/workspace/WorkspaceProfilePage.tsx @@ -63,6 +63,12 @@ function WorkspaceProfilePage({policyDraft, policy: policyProp, currencyList = { const currencySymbol = currencyList?.[outputCurrency]?.symbol ?? ''; const formattedCurrency = !isEmptyObject(policy) && !isEmptyObject(currencyList) ? `${outputCurrency} - ${currencySymbol}` : ''; + // We need this to update translation for deleting a workspace when it has third party card feeds or expensify card assigned. + const workspaceAccountID = PolicyUtils.getWorkspaceAccountID(policy?.id ?? '-1'); + const [cardFeeds] = useOnyx(`${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER}${workspaceAccountID}`); + const [cardsList] = useOnyx(`${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${workspaceAccountID}_${CONST.EXPENSIFY_CARD.BANK}`); + const hasCardFeedOrExpensifyCard = !isEmptyObject(cardFeeds) || !isEmptyObject(cardsList); + const [street1, street2] = (policy?.address?.addressStreet ?? '').split('\n'); const formattedAddress = !isEmptyObject(policy) && !isEmptyObject(policy.address) @@ -285,11 +291,11 @@ function WorkspaceProfilePage({policyDraft, policy: policyProp, currencyList = { )} setIsDeleteModalOpen(false)} - prompt={translate('workspace.common.deleteConfirmation')} + prompt={hasCardFeedOrExpensifyCard ? translate('workspace.common.deleteWithCardsConfirmation') : translate('workspace.common.deleteConfirmation')} confirmText={translate('common.delete')} cancelText={translate('common.cancel')} danger diff --git a/src/pages/workspace/WorkspacesListPage.tsx b/src/pages/workspace/WorkspacesListPage.tsx index 1dd3ee4a74d..3002d434ae9 100755 --- a/src/pages/workspace/WorkspacesListPage.tsx +++ b/src/pages/workspace/WorkspacesListPage.tsx @@ -119,6 +119,12 @@ function WorkspacesListPage() { const [policyNameToDelete, setPolicyNameToDelete] = useState(); const isLessThanMediumScreen = isMediumScreenWidth || shouldUseNarrowLayout; + // We need this to update translation for deleting a workspace when it has third party card feeds or expensify card assigned. + const workspaceAccountID = PolicyUtils.getWorkspaceAccountID(policyIDToDelete ?? '-1'); + const [cardFeeds] = useOnyx(`${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER}${workspaceAccountID}`); + const [cardsList] = useOnyx(`${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${workspaceAccountID}_${CONST.EXPENSIFY_CARD.BANK}`); + const hasCardFeedOrExpensifyCard = !isEmptyObject(cardFeeds) || !isEmptyObject(cardsList); + const confirmDeleteAndHideModal = () => { if (!policyIDToDelete || !policyNameToDelete) { return; @@ -430,7 +436,7 @@ function WorkspacesListPage() { isVisible={isDeleteModalOpen} onConfirm={confirmDeleteAndHideModal} onCancel={() => setIsDeleteModalOpen(false)} - prompt={translate('workspace.common.deleteConfirmation')} + prompt={hasCardFeedOrExpensifyCard ? translate('workspace.common.deleteWithCardsConfirmation') : translate('workspace.common.deleteConfirmation')} confirmText={translate('common.delete')} cancelText={translate('common.cancel')} danger From d4f554214b6825ad14e5b121abaaf454e7c2bb82 Mon Sep 17 00:00:00 2001 From: Artem Makushov Date: Thu, 3 Oct 2024 16:59:24 +0200 Subject: [PATCH 3/5] remove deprecated withOnyx --- src/pages/workspace/WorkspaceProfilePage.tsx | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/src/pages/workspace/WorkspaceProfilePage.tsx b/src/pages/workspace/WorkspaceProfilePage.tsx index 3400943cb6d..1413ad96806 100644 --- a/src/pages/workspace/WorkspaceProfilePage.tsx +++ b/src/pages/workspace/WorkspaceProfilePage.tsx @@ -3,8 +3,7 @@ import type {StackScreenProps} from '@react-navigation/stack'; import React, {useCallback, useState} from 'react'; import type {ImageStyle, StyleProp} from 'react-native'; import {Image, StyleSheet, View} from 'react-native'; -import type {OnyxEntry} from 'react-native-onyx'; -import {useOnyx, withOnyx} from 'react-native-onyx'; +import {useOnyx} from 'react-native-onyx'; import Avatar from '@components/Avatar'; import AvatarWithImagePicker from '@components/AvatarWithImagePicker'; import Button from '@components/Button'; @@ -34,20 +33,14 @@ import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; import type SCREENS from '@src/SCREENS'; -import type * as OnyxTypes from '@src/types/onyx'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; import type {WithPolicyProps} from './withPolicy'; import withPolicy from './withPolicy'; import WorkspacePageWithSections from './WorkspacePageWithSections'; -type WorkspaceProfilePageOnyxProps = { - /** Constant, list of available currencies */ - currencyList: OnyxEntry; -}; +type WorkspaceProfilePageProps = WithPolicyProps & StackScreenProps; -type WorkspaceProfilePageProps = WithPolicyProps & WorkspaceProfilePageOnyxProps & StackScreenProps; - -function WorkspaceProfilePage({policyDraft, policy: policyProp, currencyList = {}, route}: WorkspaceProfilePageProps) { +function WorkspaceProfilePage({policyDraft, policy: policyProp, route}: WorkspaceProfilePageProps) { const styles = useThemeStyles(); const {translate} = useLocalize(); const {shouldUseNarrowLayout} = useResponsiveLayout(); @@ -55,6 +48,7 @@ function WorkspaceProfilePage({policyDraft, policy: policyProp, currencyList = { const {activeWorkspaceID, setActiveWorkspaceID} = useActiveWorkspace(); const {canUseSpotnanaTravel} = usePermissions(); + const [currencyList = {}] = useOnyx(ONYXKEYS.CURRENCY_LIST); const [currentUserAccountID = -1] = useOnyx(ONYXKEYS.SESSION, {selector: (session) => session?.accountID}); // When we create a new workspace, the policy prop will be empty on the first render. Therefore, we have to use policyDraft until policy has been set in Onyx. @@ -308,8 +302,4 @@ function WorkspaceProfilePage({policyDraft, policy: policyProp, currencyList = { WorkspaceProfilePage.displayName = 'WorkspaceProfilePage'; -export default withPolicy( - withOnyx({ - currencyList: {key: ONYXKEYS.CURRENCY_LIST}, - })(WorkspaceProfilePage), -); +export default withPolicy(WorkspaceProfilePage); From 9a2b2bf04f53b527b38612001d6141282c1122c5 Mon Sep 17 00:00:00 2001 From: Artem Makushov Date: Mon, 7 Oct 2024 16:47:40 +0200 Subject: [PATCH 4/5] update translation --- src/languages/en.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index 4a140dbba80..0b7d9492590 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -2290,7 +2290,7 @@ const translations = { }), settlementFrequency: 'Settlement frequency', deleteConfirmation: 'Are you sure you want to delete this workspace?', - deleteWithCardsConfirmation: 'Are you sure you want to delete this workspace? This will remove all card feeds and assigned cards', + deleteWithCardsConfirmation: 'Are you sure you want to delete this workspace? This will remove all card feeds and assigned cards.', unavailable: 'Unavailable workspace', memberNotFound: 'Member not found. To invite a new member to the workspace, please use the invite button above.', notAuthorized: `You don't have access to this page. If you're trying to join this workspace, just ask the workspace owner to add you as a member. Something else? Reach out to ${CONST.EMAIL.CONCIERGE}.`, From f41875ff661d631f312c2a3d93162dd234329d73 Mon Sep 17 00:00:00 2001 From: Artem Makushov Date: Mon, 7 Oct 2024 16:48:35 +0200 Subject: [PATCH 5/5] update spanish translation --- src/languages/es.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/languages/es.ts b/src/languages/es.ts index 3864338724e..275b0cac090 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -2310,8 +2310,7 @@ const translations = { }), settlementFrequency: 'Frecuencia de liquidación', deleteConfirmation: '¿Estás seguro de que quieres eliminar este espacio de trabajo?', - deleteWithCardsConfirmation: - '¿Estás seguro de que quieres eliminar este espacio de trabajo? De este modo, se eliminarán todos los datos de las tarjetas y las tarjetas asignadas.', + deleteWithCardsConfirmation: '¿Estás seguro de que quieres eliminar este espacio de trabajo? Se eliminarán todos los datos de las tarjetas y las tarjetas asignadas.', unavailable: 'Espacio de trabajo no disponible', memberNotFound: 'Miembro no encontrado. Para invitar a un nuevo miembro al espacio de trabajo, por favor, utiliza el botón invitar que está arriba.', notAuthorized: `No tienes acceso a esta página. Si estás intentando unirte a este espacio de trabajo, pide al dueño del espacio de trabajo que te añada como miembro. ¿Necesitas algo más? Comunícate con ${CONST.EMAIL.CONCIERGE}`,