Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 33 additions & 3 deletions src/pages/workspace/WorkspaceProfilePage.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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';
Expand Down Expand Up @@ -77,6 +78,19 @@ function WorkspaceProfilePage({policy, currencyList = {}, route}: WorkSpaceProfi
[policy?.avatar, policyName, styles.alignSelfCenter, styles.avatarXLarge],
);

const [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false);
Comment thread
This conversation was marked as resolved.

const confirmDeleteAndHideModal = useCallback(() => {
if (!policy?.id || !policyName) {
return;
}

Policy.deleteWorkspace(policy?.id, policyName);

PolicyUtils.goBackFromInvalidPolicy();

setIsDeleteModalOpen(false);
}, [policy?.id, policyName]);
return (
Comment thread
This conversation was marked as resolved.
Comment thread
This conversation was marked as resolved.
<WorkspacePageWithSections
headerText={translate('workspace.common.profile')}
Expand Down Expand Up @@ -175,17 +189,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')}
Comment thread
This conversation was marked as resolved.
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