From 4c70451aa93f806081741b85c09ffdab954b258d Mon Sep 17 00:00:00 2001
From: "buffercheck00@protonmail.com" <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 fa38eda8c4d5..3b331e072294 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 (
         <WorkspacePageWithSections
             headerText={translate('workspace.common.profile')}
@@ -175,17 +190,32 @@ function WorkspaceProfilePage({policy, currencyList = {}, route}: WorkSpaceProfi
                                 </View>
                             </OfflineWithFeedback>
                             {!readOnly && (
-                                <View style={[styles.flexRow, styles.mnw120]}>
+                                <View style={[styles.flexRow, styles.mt6, styles.mnw120]}>
                                     <Button
                                         accessibilityLabel={translate('common.share')}
-                                        style={styles.mt6}
                                         text={translate('common.share')}
                                         onPress={onPressShare}
                                         medium
                                     />
+                                    <Button
+                                        accessibilityLabel={translate('common.delete')}
+                                        text={translate('common.delete')}
+                                        onPress={() => setIsDeleteModalOpen(true)}
+                                        medium
+                                    />
                                 </View>
                             )}
                         </Section>
+                        <ConfirmModal
+                            title={translate('common.delete')}
+                            isVisible={isDeleteModalOpen}
+                            onConfirm={confirmDeleteAndHideModal}
+                            onCancel={() => setIsDeleteModalOpen(false)}
+                            prompt={translate('workspace.common.deleteConfirmation')}
+                            confirmText={translate('common.delete')}
+                            cancelText={translate('common.cancel')}
+                            danger
+                        />
                     </View>
                 </ScrollView>
             )}

From 39b49111720aa0e55cfbfc250f45bbc45a95df52 Mon Sep 17 00:00:00 2001
From: "buffercheck00@protonmail.com" <buffercheck00@protonmail.com>
Date: Thu, 29 Feb 2024 11:47:59 -0800
Subject: [PATCH 2/7] resolve margin

---
 src/pages/workspace/WorkspaceProfilePage.tsx | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/pages/workspace/WorkspaceProfilePage.tsx b/src/pages/workspace/WorkspaceProfilePage.tsx
index 3b331e072294..3195af92d457 100644
--- a/src/pages/workspace/WorkspaceProfilePage.tsx
+++ b/src/pages/workspace/WorkspaceProfilePage.tsx
@@ -77,6 +77,7 @@ function WorkspaceProfilePage({policy, currencyList = {}, route}: WorkSpaceProfi
         ),
         [policy?.avatar, policyName, styles.alignSelfCenter, styles.avatarXLarge],
     );
+
     const [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false);
 
     const confirmDeleteAndHideModal = useCallback(() => {
@@ -85,11 +86,8 @@ function WorkspaceProfilePage({policy, currencyList = {}, route}: WorkSpaceProfi
         }
 
         Policy.deleteWorkspace(policy?.id, policyName);
-
         Navigation.goBack(ROUTES.SETTINGS_WORKSPACES);
-
         Navigation.navigateWithSwitchPolicyID({route: ROUTES.ALL_SETTINGS});
-
         setIsDeleteModalOpen(false);
     }, [policy?.id, policyName]);
     return (
@@ -200,6 +198,7 @@ function WorkspaceProfilePage({policy, currencyList = {}, route}: WorkSpaceProfi
                                     <Button
                                         accessibilityLabel={translate('common.delete')}
                                         text={translate('common.delete')}
+                                        style={[styles.ml2]}
                                         onPress={() => setIsDeleteModalOpen(true)}
                                         medium
                                     />

From 0f2c00548f9b623a6bdba87d0804a5bfb9690fe2 Mon Sep 17 00:00:00 2001
From: "buffercheck00@protonmail.com" <buffercheck00@protonmail.com>
Date: Mon, 4 Mar 2024 23:43:24 +0100
Subject: [PATCH 3/7] handle statusbar background

---
 src/components/Modal/index.tsx               | 5 +++--
 src/pages/workspace/WorkspaceProfilePage.tsx | 5 +++--
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/components/Modal/index.tsx b/src/components/Modal/index.tsx
index 71c0fe47ffca..1434b1f3a549 100644
--- a/src/components/Modal/index.tsx
+++ b/src/components/Modal/index.tsx
@@ -1,6 +1,7 @@
 import React, {useState} from 'react';
 import useStyleUtils from '@hooks/useStyleUtils';
 import useTheme from '@hooks/useTheme';
+import useWindowDimensions from '@hooks/useWindowDimensions';
 import StatusBar from '@libs/StatusBar';
 import CONST from '@src/CONST';
 import BaseModal from './BaseModal';
@@ -10,7 +11,7 @@ function Modal({fullscreen = true, onModalHide = () => {}, type, onModalShow = (
     const theme = useTheme();
     const StyleUtils = useStyleUtils();
     const [previousStatusBarColor, setPreviousStatusBarColor] = useState<string>();
-
+    const {isSmallScreenWidth} = useWindowDimensions();
     const setStatusBarColor = (color = theme.appBG) => {
         if (!fullscreen) {
             return;
@@ -32,7 +33,7 @@ function Modal({fullscreen = true, onModalHide = () => {}, type, onModalShow = (
         if (statusBarColor) {
             setPreviousStatusBarColor(statusBarColor);
             // If it is a full screen modal then match it with appBG, otherwise we use the backdrop color
-            setStatusBarColor(isFullScreenModal ? theme.appBG : StyleUtils.getThemeBackgroundColor(statusBarColor));
+            setStatusBarColor(isFullScreenModal || isSmallScreenWidth ? theme.appBG : StyleUtils.getThemeBackgroundColor(statusBarColor));
         }
 
         onModalShow?.();
diff --git a/src/pages/workspace/WorkspaceProfilePage.tsx b/src/pages/workspace/WorkspaceProfilePage.tsx
index 3195af92d457..19e796b870fa 100644
--- a/src/pages/workspace/WorkspaceProfilePage.tsx
+++ b/src/pages/workspace/WorkspaceProfilePage.tsx
@@ -86,8 +86,9 @@ function WorkspaceProfilePage({policy, currencyList = {}, route}: WorkSpaceProfi
         }
 
         Policy.deleteWorkspace(policy?.id, policyName);
-        Navigation.goBack(ROUTES.SETTINGS_WORKSPACES);
-        Navigation.navigateWithSwitchPolicyID({route: ROUTES.ALL_SETTINGS});
+
+        PolicyUtils.goBackFromInvalidPolicy();
+
         setIsDeleteModalOpen(false);
     }, [policy?.id, policyName]);
     return (

From bc86bd44e6cc395ebbaa298c8bce07d0919994f8 Mon Sep 17 00:00:00 2001
From: "buffercheck00@protonmail.com" <buffercheck00@protonmail.com>
Date: Thu, 7 Mar 2024 09:51:08 +0100
Subject: [PATCH 4/7] revert isSmallScreenWidth

---
 src/components/Modal/index.tsx | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/components/Modal/index.tsx b/src/components/Modal/index.tsx
index 1434b1f3a549..74f4bcbea811 100644
--- a/src/components/Modal/index.tsx
+++ b/src/components/Modal/index.tsx
@@ -33,7 +33,7 @@ function Modal({fullscreen = true, onModalHide = () => {}, type, onModalShow = (
         if (statusBarColor) {
             setPreviousStatusBarColor(statusBarColor);
             // If it is a full screen modal then match it with appBG, otherwise we use the backdrop color
-            setStatusBarColor(isFullScreenModal || isSmallScreenWidth ? theme.appBG : StyleUtils.getThemeBackgroundColor(statusBarColor));
+            setStatusBarColor(isFullScreenModal ? theme.appBG : StyleUtils.getThemeBackgroundColor(statusBarColor));
         }
 
         onModalShow?.();

From bb6e3a662201214c5ae2b75daeb257585a452cb8 Mon Sep 17 00:00:00 2001
From: "buffercheck00@protonmail.com" <buffercheck00@protonmail.com>
Date: Thu, 7 Mar 2024 10:04:36 +0100
Subject: [PATCH 5/7] revert

---
 src/components/Modal/index.tsx | 2 --
 1 file changed, 2 deletions(-)

diff --git a/src/components/Modal/index.tsx b/src/components/Modal/index.tsx
index 74f4bcbea811..17ca84badfae 100644
--- a/src/components/Modal/index.tsx
+++ b/src/components/Modal/index.tsx
@@ -1,7 +1,6 @@
 import React, {useState} from 'react';
 import useStyleUtils from '@hooks/useStyleUtils';
 import useTheme from '@hooks/useTheme';
-import useWindowDimensions from '@hooks/useWindowDimensions';
 import StatusBar from '@libs/StatusBar';
 import CONST from '@src/CONST';
 import BaseModal from './BaseModal';
@@ -11,7 +10,6 @@ function Modal({fullscreen = true, onModalHide = () => {}, type, onModalShow = (
     const theme = useTheme();
     const StyleUtils = useStyleUtils();
     const [previousStatusBarColor, setPreviousStatusBarColor] = useState<string>();
-    const {isSmallScreenWidth} = useWindowDimensions();
     const setStatusBarColor = (color = theme.appBG) => {
         if (!fullscreen) {
             return;

From 96ab665db584205469d0841d106bbf5c4edc94bd Mon Sep 17 00:00:00 2001
From: "buffercheck00@protonmail.com" <buffercheck00@protonmail.com>
Date: Thu, 7 Mar 2024 10:44:03 +0100
Subject: [PATCH 6/7] revert

---
 src/components/Modal/index.tsx | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/components/Modal/index.tsx b/src/components/Modal/index.tsx
index 17ca84badfae..25bea7e5c188 100644
--- a/src/components/Modal/index.tsx
+++ b/src/components/Modal/index.tsx
@@ -10,6 +10,7 @@ function Modal({fullscreen = true, onModalHide = () => {}, type, onModalShow = (
     const theme = useTheme();
     const StyleUtils = useStyleUtils();
     const [previousStatusBarColor, setPreviousStatusBarColor] = useState<string>();
+    
     const setStatusBarColor = (color = theme.appBG) => {
         if (!fullscreen) {
             return;

From cbc9224adec5e9bd8f7017c143a0b656fb837789 Mon Sep 17 00:00:00 2001
From: "buffercheck00@protonmail.com" <buffercheck00@protonmail.com>
Date: Thu, 7 Mar 2024 10:59:08 +0100
Subject: [PATCH 7/7] revert

---
 src/components/Modal/index.tsx | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/components/Modal/index.tsx b/src/components/Modal/index.tsx
index 25bea7e5c188..71c0fe47ffca 100644
--- a/src/components/Modal/index.tsx
+++ b/src/components/Modal/index.tsx
@@ -10,7 +10,7 @@ function Modal({fullscreen = true, onModalHide = () => {}, type, onModalShow = (
     const theme = useTheme();
     const StyleUtils = useStyleUtils();
     const [previousStatusBarColor, setPreviousStatusBarColor] = useState<string>();
-    
+
     const setStatusBarColor = (color = theme.appBG) => {
         if (!fullscreen) {
             return;
