Skip to content
Merged
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions src/languages/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2268,6 +2268,11 @@ const translations: TranslationDeepObject<typeof en> = {
${amount} für ${merchant} – ${date}`,
},
freezeCard: 'Karte sperren',
unfreeze: 'Entsperren',
unfreezeCard: 'Karte entsperren',
freezeDescription: 'Eine gesperrte Karte kann nicht für Käufe und Transaktionen verwendet werden. Du kannst sie jederzeit entsperren.',
unfreezeDescription:
'Durch das Entsperren dieser Karte werden Käufe und Transaktionen wieder zugelassen. Fahre nur fort, wenn du sicher bist, dass die Karte sicher verwendet werden kann.',
},
workflowsPage: {
workflowTitle: 'Ausgaben',
Expand Down
4 changes: 4 additions & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2282,6 +2282,10 @@ const translations = {
`identified suspicious activity on card ending in ${cardLastFour}. Do you recognize this charge?\n\n${amount} for ${merchant} - ${date}`,
},
freezeCard: 'Freeze card',
unfreeze: 'Unfreeze',
unfreezeCard: 'Unfreeze card',
freezeDescription: 'A frozen card cannot be used for purchases and transactions. You can unfreeze it at any time.',
unfreezeDescription: "Unfreezing this card will start allowing purchases and transactions again. Only proceed if you're sure the card is safe to use.",
},
workflowsPage: {
workflowTitle: 'Spend',
Expand Down
4 changes: 4 additions & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2066,6 +2066,10 @@ const translations: TranslationDeepObject<typeof en> = {
${amount} para ${merchant} - ${date}`,
},
freezeCard: 'Congelar tarjeta',
unfreeze: 'Descongelar',
unfreezeCard: 'Descongelar tarjeta',
freezeDescription: 'Una tarjeta congelada no se puede usar para compras ni transacciones. Puedes descongelarla en cualquier momento.',
unfreezeDescription: 'Al descongelar esta tarjeta se volverán a permitir compras y transacciones. Continúa solo si estás seguro de que la tarjeta es segura para usar.',
},
workflowsPage: {
workflowTitle: 'Gasto',
Expand Down
5 changes: 5 additions & 0 deletions src/languages/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2274,6 +2274,11 @@ const translations: TranslationDeepObject<typeof en> = {
${amount} pour ${merchant} - ${date}`,
},
freezeCard: 'Geler la carte',
unfreeze: 'Dégeler',
unfreezeCard: 'Dégeler la carte',
freezeDescription: 'Une carte gelée ne peut pas être utilisée pour des achats ni des transactions. Vous pouvez la dégeler à tout moment.',
unfreezeDescription:
'Dégeler cette carte permettra à nouveau les achats et les transactions. Continuez uniquement si vous êtes sûr(e) que la carte peut être utilisée en toute sécurité.',
},
workflowsPage: {
workflowTitle: 'Dépense',
Expand Down
4 changes: 4 additions & 0 deletions src/languages/it.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2262,6 +2262,10 @@ const translations: TranslationDeepObject<typeof en> = {
${amount} per ${merchant} - ${date}`,
},
freezeCard: 'Blocca carta',
unfreeze: 'Sblocca',
unfreezeCard: 'Sblocca carta',
freezeDescription: 'Una carta bloccata non può essere usata per acquisti e transazioni. Puoi sbloccarla in qualsiasi momento.',
unfreezeDescription: 'Sbloccando questa carta torneranno ad essere consentiti acquisti e transazioni. Procedi solo se sei sicuro che la carta sia sicura da usare.',
},
workflowsPage: {
workflowTitle: 'Spesa',
Expand Down
4 changes: 4 additions & 0 deletions src/languages/ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2249,6 +2249,10 @@ const translations: TranslationDeepObject<typeof en> = {
${date} の ${merchant} への ${amount}`,
},
freezeCard: 'カードを一時停止',
unfreeze: '再開',
unfreezeCard: 'カードの一時停止を解除',
freezeDescription: '一時停止したカードは購入や取引に使用できません。いつでも再開できます。',
unfreezeDescription: 'このカードの一時停止を解除すると、購入と取引が再び可能になります。カードが安全に使用できると確信できる場合にのみ続行してください。',
},
workflowsPage: {
workflowTitle: '支出',
Expand Down
4 changes: 4 additions & 0 deletions src/languages/nl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2263,6 +2263,10 @@ const translations: TranslationDeepObject<typeof en> = {
${amount} voor ${merchant} - ${date}`,
},
freezeCard: 'Kaart blokkeren',
unfreeze: 'Deblokkeren',
unfreezeCard: 'Kaart deblokkeren',
freezeDescription: 'Een geblokkeerde kaart kan niet worden gebruikt voor aankopen en transacties. Je kunt deze op elk moment deblokkeren.',
unfreezeDescription: 'Door deze kaart te deblokkeren worden aankopen en transacties weer toegestaan. Ga alleen verder als je zeker weet dat de kaart veilig is om te gebruiken.',
},
workflowsPage: {
workflowTitle: 'Uitgaven',
Expand Down
4 changes: 4 additions & 0 deletions src/languages/pl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2257,6 +2257,10 @@ const translations: TranslationDeepObject<typeof en> = {
${amount} dla ${merchant} - ${date}`,
},
freezeCard: 'Zamroź kartę',
unfreeze: 'Odmroź',
unfreezeCard: 'Odmroź kartę',
freezeDescription: 'Zamrożonej karty nie można używać do zakupów i transakcji. Możesz ją odmrozić w dowolnym momencie.',
unfreezeDescription: 'Odmrożenie tej karty ponownie umożliwi zakupy i transakcje. Kontynuuj tylko wtedy, gdy masz pewność, że korzystanie z karty jest bezpieczne.',
},
workflowsPage: {
workflowTitle: 'Wydatki',
Expand Down
4 changes: 4 additions & 0 deletions src/languages/pt-BR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2256,6 +2256,10 @@ const translations: TranslationDeepObject<typeof en> = {
${amount} para ${merchant} - ${date}`,
},
freezeCard: 'Bloquear cartão',
unfreeze: 'Desbloquear',
unfreezeCard: 'Desbloquear cartão',
freezeDescription: 'Um cartão bloqueado não pode ser usado para compras e transações. Você pode desbloqueá-lo a qualquer momento.',
unfreezeDescription: 'Ao desbloquear este cartão, compras e transações voltarão a ser permitidas. Continue apenas se tiver certeza de que o cartão é seguro para uso.',
},
workflowsPage: {
workflowTitle: 'Gastos',
Expand Down
4 changes: 4 additions & 0 deletions src/languages/zh-hans.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2222,6 +2222,10 @@ const translations: TranslationDeepObject<typeof en> = {
${amount},商户:${merchant} - 日期:${date}`,
},
freezeCard: '冻结卡片',
unfreeze: '解冻',
unfreezeCard: '解冻卡片',
freezeDescription: '冻结的卡片无法用于购买和交易。你可以随时解冻。',
unfreezeDescription: '解冻此卡后,将重新允许购买和交易。仅当你确定该卡可以安全使用时再继续。',
},
workflowsPage: {
workflowTitle: '支出',
Expand Down
73 changes: 72 additions & 1 deletion src/pages/settings/Wallet/ExpensifyCardPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type {ValueOf} from 'type-fest';
import AddToWalletButton from '@components/AddToWalletButton/index';
import Button from '@components/Button';
import CardPreview from '@components/CardPreview';
import ConfirmModal from '@components/ConfirmModal';
import DotIndicatorMessage from '@components/DotIndicatorMessage';
import FormHelpMessage from '@components/FormHelpMessage';
import HeaderWithBackButton from '@components/HeaderWithBackButton';
Expand All @@ -26,6 +27,7 @@ import useOnyx from '@hooks/useOnyx';
import usePermissions from '@hooks/usePermissions';
import useThemeStyles from '@hooks/useThemeStyles';
import {resetValidateActionCodeSent} from '@libs/actions/User';
import {freezeCard, unfreezeCard} from '@libs/actions/Card';
import {formatCardExpiration, getDomainCards, getTranslationKeyForLimitType, isCardFrozen, maskCard, maskPin} from '@libs/CardUtils';
import {convertToDisplayString, getCurrencyKeyByCountryCode} from '@libs/CurrencyUtils';
import DateUtils from '@libs/DateUtils';
Expand Down Expand Up @@ -157,6 +159,42 @@ function ExpensifyCardPage({route}: ExpensifyCardPageProps) {
const isCardHolder = currentCard?.accountID === session?.accountID;

const {isBetaEnabled} = usePermissions();
const canManageCardFreeze = isBetaEnabled(CONST.BETAS.FREEZE_CARD) && isCardHolder && !!currentCard && !isAccountLocked;

const [isFreezeModalVisible, setIsFreezeModalVisible] = useState(false);
const [isUnfreezeModalVisible, setIsUnfreezeModalVisible] = useState(false);

const handleFreezePress = useCallback(() => {
setIsFreezeModalVisible(true);
}, []);

const handleDismissFreezeModal = useCallback(() => {
setIsFreezeModalVisible(false);
}, []);

const handleConfirmFreeze = useCallback(() => {
if (!currentCard) {
return;
}
freezeCard(Number(currentCard?.fundID ?? CONST.DEFAULT_NUMBER_ID), currentCard, session?.accountID ?? CONST.DEFAULT_NUMBER_ID);
handleDismissFreezeModal();
}, [currentCard, handleDismissFreezeModal, session?.accountID]);

const handleUnfreezePress = useCallback(() => {
setIsUnfreezeModalVisible(true);
}, []);

const handleDismissUnfreezeModal = useCallback(() => {
setIsUnfreezeModalVisible(false);
}, []);

const handleConfirmUnfreeze = useCallback(() => {
if (!currentCard) {
return;
}
unfreezeCard(Number(currentCard?.fundID ?? CONST.DEFAULT_NUMBER_ID), currentCard);
handleDismissUnfreezeModal();
}, [currentCard, handleDismissUnfreezeModal]);

if (isNotFound) {
return <NotFoundPage onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS_WALLET)} />;
Expand All @@ -172,6 +210,15 @@ function ExpensifyCardPage({route}: ExpensifyCardPageProps) {
<View style={[styles.flex1, styles.mb9, styles.mt9]}>
<CardPreview />
</View>
{canManageCardFreeze && isCardFrozen(currentCard) && (
<Button
medium
style={[styles.mh4, styles.mb4]}
text={translate('cardPage.unfreeze')}
onPress={handleUnfreezePress}
isDisabled={isOffline}
/>
)}

{hasDetectedDomainFraud && (
<DotIndicatorMessage
Expand Down Expand Up @@ -409,11 +456,12 @@ function ExpensifyCardPage({route}: ExpensifyCardPageProps) {
);
}}
/>
{isBetaEnabled(CONST.BETAS.FREEZE_CARD) && isCardHolder && !!currentCard && !isCardFrozen(currentCard) && (
{canManageCardFreeze && !isCardFrozen(currentCard) && (
<MenuItem
icon={expensifyIcons.FreezeCard}
title={translate('cardPage.freezeCard')}
disabled={isOffline}
onPress={handleFreezePress}
/>
)}
</>
Expand Down Expand Up @@ -446,6 +494,29 @@ function ExpensifyCardPage({route}: ExpensifyCardPageProps) {
style={[styles.mh5, styles.mb5]}
/>
)}
<ConfirmModal
title={`${translate('cardPage.freezeCard')}?`}
isVisible={isFreezeModalVisible}
onConfirm={handleConfirmFreeze}
onCancel={handleDismissFreezeModal}
onBackdropPress={handleDismissFreezeModal}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need to close on backdrop press?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MariaHCD Can you confirm?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should be fine to close?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we close on backdrop press for other confirmation modals in the app?

I think it should be fine to close in this case but would be good to be consistent with whatever the current approach is!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to be a mixed approach. At some places this is done while ignored at others.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I don't see a specific reason why we wouldn't allow closing when the backdrop is pressed. Let's go with this approach for now. If needed, we can always update this in the future.

shouldSetModalVisibility={false}
prompt={translate('cardPage.freezeDescription')}
confirmText={translate('cardPage.freezeCard')}
cancelText={translate('common.cancel')}
danger
/>
<ConfirmModal
title={`${translate('cardPage.unfreezeCard')}?`}
isVisible={isUnfreezeModalVisible}
onConfirm={handleConfirmUnfreeze}
onCancel={handleDismissUnfreezeModal}
onBackdropPress={handleDismissUnfreezeModal}
shouldSetModalVisibility={false}
prompt={translate('cardPage.unfreezeDescription')}
confirmText={translate('cardPage.unfreezeCard')}
cancelText={translate('common.cancel')}
/>
</ScreenWrapper>
);
}
Expand Down
Loading