diff --git a/src/languages/en.ts b/src/languages/en.ts index 5ee0b939049e..0e1b55711dff 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -2720,7 +2720,6 @@ const translations = { submitExpense: 'Submit your expenses below:', defaultCategory: 'Default category', viewTransactions: 'View transactions', - leaveConfirmation: "Are you sure you want to leave this workspace? Once you leave, you'll lose access to all data and settings associated with this workspace.", }, perDiem: { subtitle: 'Set per diem rates to control daily employee spend. ', diff --git a/src/languages/es.ts b/src/languages/es.ts index 104dc52fd85b..577e13a5bdb5 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -2745,8 +2745,6 @@ const translations = { submitExpense: 'Envía tus gastos a continuación:', defaultCategory: 'Categoría predeterminada', viewTransactions: 'Ver transacciones', - leaveConfirmation: - '¿Estás seguro de que quieres salir de este espacio de trabajo? Una vez que salgas, perderás el acceso a todos los datos y configuraciones asociadas con este espacio de trabajo.', }, perDiem: { subtitle: 'Establece las tasas per diem para controlar los gastos diarios de los empleados. ', diff --git a/src/pages/workspace/WorkspaceProfilePage.tsx b/src/pages/workspace/WorkspaceProfilePage.tsx index a05be1b68528..a042480fd03f 100644 --- a/src/pages/workspace/WorkspaceProfilePage.tsx +++ b/src/pages/workspace/WorkspaceProfilePage.tsx @@ -20,7 +20,7 @@ import useResponsiveLayout from '@hooks/useResponsiveLayout'; import useThemeIllustrations from '@hooks/useThemeIllustrations'; import useThemeStyles from '@hooks/useThemeStyles'; import {clearInviteDraft} from '@libs/actions/Policy/Member'; -import {clearAvatarErrors, clearPolicyErrorField, deleteWorkspace, deleteWorkspaceAvatar, leaveWorkspace, openPolicyProfilePage, updateWorkspaceAvatar} from '@libs/actions/Policy/Policy'; +import {clearAvatarErrors, clearPolicyErrorField, deleteWorkspace, deleteWorkspaceAvatar, openPolicyProfilePage, updateWorkspaceAvatar} from '@libs/actions/Policy/Policy'; import {getLatestErrorField} from '@libs/ErrorUtils'; import resetPolicyIDInNavigationState from '@libs/Navigation/helpers/resetPolicyIDInNavigationState'; import Navigation from '@libs/Navigation/Navigation'; @@ -49,7 +49,6 @@ function WorkspaceProfilePage({policyDraft, policy: policyProp, route}: Workspac const illustrations = useThemeIllustrations(); const {canUseSpotnanaTravel} = usePermissions(); const {activeWorkspaceID, setActiveWorkspaceID} = useActiveWorkspace(); - const [isLeaveModalOpen, setIsLeaveModalOpen] = useState(false); const [currencyList = {}] = useOnyx(ONYXKEYS.CURRENCY_LIST); const [currentUserAccountID = -1] = useOnyx(ONYXKEYS.SESSION, {selector: (session) => session?.accountID}); @@ -157,23 +156,16 @@ function WorkspaceProfilePage({policyDraft, policy: policyProp, route}: Workspac const [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false); - const handleWorkspaceAction = useCallback( - (action: 'delete' | 'leave') => { - if (!policy?.id || !policyName) { - return; - } - - if (action === 'delete') { - deleteWorkspace(policy.id, policyName); - setIsDeleteModalOpen(false); - } else { - leaveWorkspace(policy.id); - } + const confirmDeleteAndHideModal = useCallback(() => { + if (!policy?.id || !policyName) { + return; + } - if (activeWorkspaceID !== policy?.id) { - return; - } + deleteWorkspace(policy.id, policyName); + setIsDeleteModalOpen(false); + // If the workspace being deleted is the active workspace, switch to the "All Workspaces" view + if (activeWorkspaceID === policy.id) { setActiveWorkspaceID(undefined); resetPolicyIDInNavigationState(); }, @@ -226,7 +218,7 @@ function WorkspaceProfilePage({policyDraft, policy: policyProp, route}: Workspac styles.sectionMenuItemTopDescription, ]} editIconStyle={styles.smallEditIconWorkspace} - isUsingDefaultAvatar={!policy?.avatarURL} + isUsingDefaultAvatar={!policy?.avatarURL ?? false} onImageSelected={(file) => { if (!policy?.id) { return; @@ -370,37 +362,17 @@ function WorkspaceProfilePage({policyDraft, policy: policyProp, route}: Workspac )} )} - {!(isPolicyAdmin || isOwner) && ( - -