Skip to content
Open
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
4 changes: 3 additions & 1 deletion app/(protected)/(tabs)/card/_layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ export default function CardLayout() {
<Stack.Screen name="ready" />
<Stack.Screen name="pending" />
<Stack.Screen name="activate" />
{/* Rain sunset: the move to the new card, and emptying the closing one. */}
{/* Rain sunset: the move to the new card, emptying the closing one, and the
card the sunset closed. */}
<Stack.Screen name="new-card" />
<Stack.Screen name="closing-withdraw" />
<Stack.Screen name="closed" />
<Stack.Screen name="credit" />
<Stack.Screen name="credit/loan-safety" />
{/* No screen animation: the card hero overlay plus the screen's own staggered
Expand Down
6 changes: 5 additions & 1 deletion app/(protected)/(tabs)/card/activate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { BASE_SPEND_DEPLOYMENT } from '@/constants/spendModuleDeployments';
import { useActivateCard } from '@/hooks/useActivateCard';
import { useCardStatus } from '@/hooks/useCardStatus';
import { useCardSpendDeployments } from '@/hooks/useEuroSpendEnablement';
import { routesToNewCard } from '@/lib/utils/rainSunset';
import { routesToClosedCard, routesToNewCard } from '@/lib/utils/rainSunset';

export default function ActivateMobile() {
const router = useRouter();
Expand Down Expand Up @@ -59,6 +59,10 @@ export default function ActivateMobile() {
if (routesToNewCard(cardStatus)) {
return <Redirect href={path.CARD_NEW_CARD} />;
}
// A card the sunset closed is not one to activate.
if (routesToClosedCard(cardStatus)) {
return <Redirect href={path.CARD_CLOSED} />;
}

if (isCardStatusLoading || isCheckingCountry || isResolvingWirexFlow) {
return (
Expand Down
6 changes: 6 additions & 0 deletions app/(protected)/(tabs)/card/closed.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { RainCardClosedScreen } from '@/components/Card/RainSunset/RainCardClosedScreen';

/** Rain sunset: the card the sunset closed, and what its holder can still do. */
export default function ClosedCardRoute() {
return <RainCardClosedScreen />;
}
8 changes: 7 additions & 1 deletion app/(protected)/(tabs)/card/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
hasPendingCard,
} from '@/lib/utils';
import { isKycAwaitingDecision } from '@/lib/utils/kyc/verificationProgress';
import { routesToNewCard } from '@/lib/utils/rainSunset';
import { routesToClosedCard, routesToNewCard } from '@/lib/utils/rainSunset';

/**
* `/card` is deprecated as a destination — it used to render the standalone card
Expand All @@ -36,6 +36,12 @@ export default function Card() {
return <Redirect href={path.CARD_NEW_CARD} />;
}

// Rain sunset: a card the sunset closed, with no new card to send them to.
// Read as "no card", it would land in the issuance flow offering to activate it.
if (routesToClosedCard(cardStatus)) {
return <Redirect href={path.CARD_CLOSED} />;
}

// BD users who haven't met the minimum card deposit are sent to the issuance
// flow (activate) to complete the deposit step; everyone else goes straight
// to card details.
Expand Down
28 changes: 17 additions & 11 deletions components/Card/NewCardDetails/CardDetailsPane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,11 @@ const CardDetailsPane = () => {
const { data: cardStatus } = useCardStatus();
// Rain sunset: the card-closing notice under the card art.
const { sunset: rainSunset } = useRainSunset();
const showsClosingNotice = Boolean(rainSunset?.notice && rainSunset.hasRainCard);
// A card the sunset already closed gets the closed notice, and no actions: it
// cannot be funded, frozen or spent from any more.
const cardClosedBySunset = Boolean(rainSunset?.cardClosed);
const showsClosingNotice =
cardClosedBySunset || Boolean(rainSunset?.notice && rainSunset.hasRainCard);
const { data: customer } = useCustomer();
const { provider } = useCardProvider();
// Either read: the status names the issuer from KYC on, so the card-live popup is never preceded
Expand Down Expand Up @@ -365,16 +369,18 @@ const CardDetailsPane = () => {
<RainClosingCardNotice />
</HeroEnter>
) : null}
<HeroEnter spec={HERO_ENTER.actions} style={styles.actionsRow}>
<CardActionsRow
isCardFrozen={isCardFrozen}
canToggleFreeze={canToggleFreeze}
isFreezing={isFreezing}
onFreezeToggle={handleFreezeToggle}
onManagePress={openSpendSheet}
canAddFunds={canAddFundsToCard(fundsAccess)}
/>
</HeroEnter>
{cardClosedBySunset ? null : (
<HeroEnter spec={HERO_ENTER.actions} style={styles.actionsRow}>
<CardActionsRow
isCardFrozen={isCardFrozen}
canToggleFreeze={canToggleFreeze}
isFreezing={isFreezing}
onFreezeToggle={handleFreezeToggle}
onManagePress={openSpendSheet}
canAddFunds={canAddFundsToCard(fundsAccess)}
/>
</HeroEnter>
)}
{/* In the spend-mode row's place, which cannot show at the same time: that row needs
card spending to be on, and this one is only here while it is off. */}
{showsEnableSpending ? (
Expand Down
113 changes: 113 additions & 0 deletions components/Card/RainSunset/RainCardClosedScreen.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
import { ActivityIndicator, StyleSheet, View } from 'react-native';
import { Image } from 'expo-image';
import { Redirect, useRouter } from 'expo-router';

import { WirexOnboardingLayout } from '@/components/Card/WirexOnboarding/WirexOnboardingLayout';
import { Button } from '@/components/ui/button';
import { Text } from '@/components/ui/text';
import { COUNTRIES } from '@/constants/countries';
import { path } from '@/constants/path';
import { useRainSunset } from '@/hooks/useRainSunset';
import { getAsset } from '@/lib/assets';
import {
closedCardCopy,
formatClosingBalance,
hasClosingBalance,
isClosingBalanceUnknown,
} from '@/lib/utils/rainSunset';

/**
* The card the Rain sunset closed: why it no longer works, the way to whatever
* was left on it, and the way to the new card where there is one.
*
* Without this screen a closed card reads as "no card": the card flow offered
* to activate it, and the card screen drew it as if it still worked. Reached
* from `/card`, the activate screen, Home's card and the closed-card banner.
*/
export function RainCardClosedScreen() {
const router = useRouter();
const { sunset, cardStatus, isLoading, balanceUsd, isBalanceLoading } = useRainSunset();

if (isLoading) {
return (
<View style={styles.loading}>
<ActivityIndicator color="#FFFFFF" />
</View>
);
}

// Not (or no longer) a closed card — moved to the new card, say: the card
// flow knows where they belong.
if (!sunset?.cardClosed) return <Redirect href={path.CARD} />;

const countryName = COUNTRIES.find(
country => country.code === cardStatus?.country?.toUpperCase(),
)?.name;
const { title, message } = closedCardCopy(sunset, balanceUsd, countryName);
// A read that failed still offers the withdrawal (its screen re-reads); one
// still in flight waits rather than flashing a button that may go away.
const balanceUnknown = isClosingBalanceUnknown(balanceUsd);
const hasBalance = hasClosingBalance(balanceUsd) || (balanceUnknown && !isBalanceLoading);
const newCard = sunset.newCardAvailable || Boolean(sunset.migration);

const goHome = () => router.replace(path.HOME);

return (
<WirexOnboardingLayout
onBack={goHome}
footer={
<View style={styles.buttons}>
{hasBalance ? (
<Button
variant="brand"
className="h-[54px] w-full rounded-full"
onPress={() => router.push(path.CARD_CLOSING_WITHDRAW)}
>
<Text className="text-[17px] font-semibold text-black">
{balanceUnknown
? 'Withdraw card balance'
: `Withdraw ${formatClosingBalance(balanceUsd ?? 0)}`}
</Text>
</Button>
) : null}
{newCard ? (
<Button
variant={hasBalance ? undefined : 'brand'}
className={`h-[54px] w-full rounded-full ${hasBalance ? 'bg-white' : ''}`}
onPress={() => router.push(path.CARD_NEW_CARD)}
>
<Text className="text-[17px] font-semibold text-black">
{sunset.migration ? 'Continue to your new card' : 'Get your new card'}
</Text>
</Button>
) : null}
{!hasBalance && !newCard ? (
<Button className="h-[54px] w-full rounded-full bg-white" onPress={goHome}>
<Text className="text-[17px] font-semibold text-black">Back to home</Text>
</Button>
) : null}
</View>
}
>
<View className="items-center gap-5">
<Image
source={getAsset('images/card-closing-art.svg')}
style={styles.art}
contentFit="contain"
/>
<View className="w-full gap-2">
<Text className="text-center text-[28px] font-semibold leading-[34px] text-white">
{title}
</Text>
<Text className="text-center text-[15px] leading-[21px] text-white/70">{message}</Text>
</View>
</View>
</WirexOnboardingLayout>
);
}

const styles = StyleSheet.create({
loading: { flex: 1, alignItems: 'center', justifyContent: 'center', backgroundColor: '#111111' },
buttons: { gap: 10 },
art: { width: 120, height: 120 },
});
16 changes: 12 additions & 4 deletions components/Card/RainSunset/RainClosingCardNotice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { path } from '@/constants/path';
import { useRainSunset } from '@/hooks/useRainSunset';
import {
cardNoticeCopy,
closedCardCopy,
formatClosingBalance,
hasClosingBalance,
isClosingBalanceUnknown,
Expand Down Expand Up @@ -57,12 +58,16 @@ const RainClosingCardNotice = () => {
const { sunset, cardStatus, balanceUsd, isBalanceLoading } = useRainSunset();
const openSheet = useRainSunsetStore(state => state.setSheetOpen);

if (!sunset?.notice || !sunset.hasRainCard) return null;
const closed = Boolean(sunset?.cardClosed);
if (!sunset || (!closed && (!sunset.notice || !sunset.hasRainCard))) return null;
Comment thread
MusabShakeel576 marked this conversation as resolved.
Resolved

const countryName = COUNTRIES.find(
country => country.code === cardStatus?.country?.toUpperCase(),
)?.name;
const { title, message } = cardNoticeCopy(sunset, balanceUsd, countryName);
// A card the sunset already closed: why it no longer works, and what is left.
const { title, message } = closed
? closedCardCopy(sunset, balanceUsd, countryName)
: cardNoticeCopy(sunset, balanceUsd, countryName);
// A read that failed still offers the withdrawal (its screen re-reads); one
// still in flight waits rather than flashing a button that may go away.
const balanceUnknown = isClosingBalanceUnknown(balanceUsd);
Expand All @@ -73,6 +78,9 @@ const RainClosingCardNotice = () => {

const goToNewCard = () => router.push(path.CARD_NEW_CARD);
const goToWithdraw = () => router.push(path.CARD_CLOSING_WITHDRAW);
// A closed card whose holder already started the move offers to continue
// it, as its copy and the closed-card screen do.
const offersNewCard = sunset.newCardAvailable || (closed && Boolean(sunset.migration));

return (
<View style={styles.notice}>
Expand All @@ -82,14 +90,14 @@ const RainClosingCardNotice = () => {
</View>
<View style={styles.titles}>
<Text className="text-[13px] font-semibold" style={{ color: AMBER }}>
Card closing
{closed ? 'Card closed' : 'Card closing'}
</Text>
<Text className="text-[18px] font-semibold leading-[24px] text-white">{title}</Text>
</View>
</View>
<Text className="text-[15px] leading-[21px] text-white/70">{message}</Text>
<View style={styles.buttons}>
{sunset.newCardAvailable ? (
{offersNewCard ? (
<>
<NoticeButton
label={sunset.migration ? 'Continue to your new card' : 'Get your new card'}
Expand Down
19 changes: 16 additions & 3 deletions components/Card/RainSunset/RainClosingHomeBanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { path } from '@/constants/path';
import { useRainSunset } from '@/hooks/useRainSunset';
import { getAsset } from '@/lib/assets';
import {
holdsClosingCard,
homeBannerCopy,
RainClosingBannerState,
rainClosingBannerState,
Expand Down Expand Up @@ -53,6 +54,9 @@ const PillButton = ({
* - `closing-balance`: no new card for them yet, money on the card — Withdraw.
* No close button: the design keeps it up while there is money to move.
* - `closing-empty`: nothing to withdraw — closable.
* - `closed-balance`: the sunset closed their card and money is left on it —
* Withdraw, and not closable while there is money to move.
* - `closed-empty`: closed, nothing left, no new card where they live — closable.
*
* Renders nothing for anyone the sunset does not affect, which is almost
* everyone, and nothing while the balance is still being read.
Expand All @@ -65,7 +69,7 @@ const RainClosingHomeBanner = ({ className }: { className?: string }) => {
const openSheet = useRainSunsetStore(state => state.setSheetOpen);

if (!sunset) return null;
if (sunset.hasRainCard && isBalanceLoading) return null;
if (holdsClosingCard(sunset) && isBalanceLoading) return null;

const state = rainClosingBannerState(sunset, balanceUsd);
if (!state) return null;
Expand All @@ -75,6 +79,8 @@ const RainClosingHomeBanner = ({ className }: { className?: string }) => {
'new-card': true,
'closing-balance': false,
'closing-empty': true,
'closed-balance': false,
'closed-empty': true,
};
if (closable[state] && dismissed.includes(key)) return null;

Expand All @@ -101,10 +107,17 @@ const RainClosingHomeBanner = ({ className }: { className?: string }) => {
onPress={goToNewCard}
/>
) : null}
{state === 'closing-balance' ? (
{state === 'closing-balance' || state === 'closed-balance' ? (
<PillButton label="Withdraw" primary onPress={goToWithdraw} />
) : null}
{state !== 'new-card' ? (
{state === 'closed-balance' && (sunset.newCardAvailable || sunset.migration) ? (
<PillButton
label={sunset.migration ? 'Continue' : 'Get new card'}
primary={false}
onPress={goToNewCard}
/>
) : null}
{state === 'closing-balance' || state === 'closing-empty' ? (
<PillButton
label="What's changing"
primary={state === 'closing-empty'}
Expand Down
11 changes: 7 additions & 4 deletions components/Card/RainSunset/RainClosingWithdraw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ export function RainClosingWithdraw() {
// No answer at all is not an empty card: say so and offer to read it again.
const unreadable = !collateral && isError;

const goToCard = () => router.replace(path.CARD_INFO);
// A card the sunset closed has no card screen to go back to; its own does.
const goToCard = () => router.replace(sunset?.cardClosed ? path.CARD_CLOSED : path.CARD_INFO);

/**
* Withdraw every token from `start` on. A retry after a failure resumes at
Expand Down Expand Up @@ -288,9 +289,11 @@ export function RainClosingWithdraw() {
tokens.length > 1
? `You'll confirm with your passkey, once for each of the ${tokens.length} tokens.`
: "You'll confirm with your passkey.";
const stays = closesOn
? ` Your card keeps working until ${closesOn.long}.`
: ' Your card keeps working until it closes.';
const stays = sunset?.cardClosed
? ' Your card is closed, but what was left on it is still yours.'
: closesOn
? ` Your card keeps working until ${closesOn.long}.`
: ' Your card keeps working until it closes.';

return (
<PageLayout desktopOnly scrollable={false}>
Expand Down
Loading
Loading