Skip to content

Commit

Permalink
Merge pull request #37528 from jsdev2547/addDelBtnToworkspace
Browse files Browse the repository at this point in the history
Add delete btn to workspace profile page
  • Loading branch information
mountiny authored Mar 7, 2024
2 parents 4c1f697 + cbc9224 commit 634b543
Showing 1 changed file with 33 additions and 3 deletions.
36 changes: 33 additions & 3 deletions src/pages/workspace/WorkspaceProfilePage.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import React, {useCallback} from 'react';
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 {withOnyx} from 'react-native-onyx';
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';
Expand Down Expand Up @@ -75,6 +76,19 @@ 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);

PolicyUtils.goBackFromInvalidPolicy();

setIsDeleteModalOpen(false);
}, [policy?.id, policyName]);
return (
<WorkspacePageWithSections
headerText={translate('workspace.common.profile')}
Expand Down Expand Up @@ -173,17 +187,33 @@ 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')}
style={[styles.ml2]}
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>
)}
Expand Down

0 comments on commit 634b543

Please sign in to comment.