From 4c70451aa93f806081741b85c09ffdab954b258d Mon Sep 17 00:00:00 2001 From: "buffercheck00@protonmail.com" Date: Thu, 29 Feb 2024 08:34:38 -0800 Subject: [PATCH 1/7] add delete btn --- src/pages/workspace/WorkspaceProfilePage.tsx | 36 ++++++++++++++++++-- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/src/pages/workspace/WorkspaceProfilePage.tsx b/src/pages/workspace/WorkspaceProfilePage.tsx index fa38eda8c4d5e..3b331e0722944 100644 --- a/src/pages/workspace/WorkspaceProfilePage.tsx +++ b/src/pages/workspace/WorkspaceProfilePage.tsx @@ -1,4 +1,4 @@ -import React, {useCallback} from 'react'; +import React, {useCallback, useState} from 'react'; import type {ImageStyle, StyleProp} from 'react-native'; import {Image, ScrollView, StyleSheet, View} from 'react-native'; import type {OnyxEntry} from 'react-native-onyx'; @@ -8,6 +8,7 @@ import WorkspaceProfile from '@assets/images/workspace-profile.png'; import Avatar from '@components/Avatar'; import AvatarWithImagePicker from '@components/AvatarWithImagePicker'; import Button from '@components/Button'; +import ConfirmModal from '@components/ConfirmModal'; import * as Expensicons from '@components/Icon/Expensicons'; import * as Illustrations from '@components/Icon/Illustrations'; import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription'; @@ -76,7 +77,21 @@ function WorkspaceProfilePage({policy, currencyList = {}, route}: WorkSpaceProfi ), [policy?.avatar, policyName, styles.alignSelfCenter, styles.avatarXLarge], ); + const [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false); + const confirmDeleteAndHideModal = useCallback(() => { + if (!policy?.id || !policyName) { + return; + } + + Policy.deleteWorkspace(policy?.id, policyName); + + Navigation.goBack(ROUTES.SETTINGS_WORKSPACES); + + Navigation.navigateWithSwitchPolicyID({route: ROUTES.ALL_SETTINGS}); + + setIsDeleteModalOpen(false); + }, [policy?.id, policyName]); return ( {!readOnly && ( - +