Repository navigation
feat(rain-sunset): show a closed card for holders whose card the sunset closed #2911
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
MusabShakeel576
wants to merge
4
commits into
master
Choose a base branch
from
claude/rain-sunset-bulk-cancel
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+639
−46
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
83486af
feat(rain-sunset): show a closed card for holders whose card the suns…
claude 5880b26
fix(rain-sunset): offer the move on a closed card's notice; wait for …
claude 25e8458
fix(rain-sunset): keep a card link while the card status cannot be read
claude 4776557
fix(rain-sunset): a card link waits for a known card status, offline …
claude File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 />; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 }, | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.