Skip to content

Commit

Permalink
Merge pull request #45703 from waterim/feat-44320-Create-Deactivate-c…
Browse files Browse the repository at this point in the history
…ard-logic

Feature: Create Deactivate card logic
  • Loading branch information
mountiny authored Jul 19, 2024
2 parents b7a3deb + dbe6c2e commit 46bc6a7
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2966,6 +2966,11 @@ export default {
limitType: 'Limit type',
name: 'Name',
},
deactivateCardModal: {
deactivate: 'Deactivate',
deactivateCard: 'Deactivate card',
deactivateConfirmation: 'Deactivating this card will decline all future transactions and can’t be undone.',
},
},
reimburse: {
captureReceipts: 'Capture receipts',
Expand Down
5 changes: 5 additions & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3218,6 +3218,11 @@ export default {
limitType: 'Tipo de limite',
name: 'Nombre',
},
deactivateCardModal: {
deactivate: 'Desactivar',
deactivateCard: 'Desactivar tarjeta',
deactivateConfirmation: 'Al desactivar esta tarjeta, se rechazarán todas las transacciones futuras y no se podrá deshacer.',
},
},
reimburse: {
captureReceipts: 'Captura recibos',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import type {StackScreenProps} from '@react-navigation/stack';
import React from 'react';
import React, {useState} from 'react';
import {View} from 'react-native';
import {useOnyx} from 'react-native-onyx';
import ExpensifyCardImage from '@assets/images/expensify-card.svg';
import Badge from '@components/Badge';
import ConfirmModal from '@components/ConfirmModal';
import HeaderWithBackButton from '@components/HeaderWithBackButton';
import {FallbackAvatar} from '@components/Icon/Expensicons';
import * as Expensicons from '@components/Icon/Expensicons';
Expand Down Expand Up @@ -45,6 +46,7 @@ type WorkspaceExpensifyCardDetailsPageProps = StackScreenProps<SettingsNavigator
function WorkspaceExpensifyCardDetailsPage({route}: WorkspaceExpensifyCardDetailsPageProps) {
const {policyID, cardID, backTo} = route.params;

const [isDeactivateModalVisible, setIsDeactivateModalVisible] = useState(false);
const {translate} = useLocalize();
const styles = useThemeStyles();
const theme = useTheme();
Expand All @@ -60,6 +62,14 @@ function WorkspaceExpensifyCardDetailsPage({route}: WorkspaceExpensifyCardDetail
const displayName = PersonalDetailsUtils.getDisplayNameOrDefault(cardholder);
const translationForLimitType = CardUtils.getTranslationKeyForLimitType(card.nameValuePairs?.limitType);

const deactivateCard = () => {
setIsDeactivateModalVisible(false);

// TODO: add API call when it's supported https://github.com/Expensify/Expensify/issues/407841

Navigation.goBack();
};

return (
<AccessOrNotFoundWrapper
accessVariants={[CONST.POLICY.ACCESS_VARIANTS.ADMIN, CONST.POLICY.ACCESS_VARIANTS.PAID]}
Expand Down Expand Up @@ -135,7 +145,18 @@ function WorkspaceExpensifyCardDetailsPage({route}: WorkspaceExpensifyCardDetail
iconFill={theme.icon}
title={translate('workspace.expensifyCard.deactivate')}
style={styles.mv1}
onPress={() => {}} // TODO: create Deactivate card logic https://github.com/Expensify/App/issues/44320
onPress={() => setIsDeactivateModalVisible(true)}
/>
<ConfirmModal
title={translate('workspace.card.deactivateCardModal.deactivateCard')}
isVisible={isDeactivateModalVisible}
onConfirm={deactivateCard}
onCancel={() => setIsDeactivateModalVisible(false)}
shouldSetModalVisibility={false}
prompt={translate('workspace.card.deactivateCardModal.deactivateConfirmation')}
confirmText={translate('workspace.card.deactivateCardModal.deactivate')}
cancelText={translate('common.cancel')}
danger
/>
</ScrollView>
</>
Expand Down

0 comments on commit 46bc6a7

Please sign in to comment.