Skip to content

Commit 55e93ce

Browse files
committed
feat(ui): add "used up" message for gifts
1 parent 1f8c588 commit 55e93ce

File tree

4 files changed

+100
-0
lines changed

4 files changed

+100
-0
lines changed

src/screens/Gift/Loading.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ const Loading = ({
4444
if (orderResult.isErr()) {
4545
if (orderResult.error.message.includes('GIFT_CODE_ALREADY_USED')) {
4646
navigation.navigate('Used', { amount });
47+
} else if (orderResult.error.message.includes('GIFT_CODE_USED_UP')) {
48+
navigation.navigate('UsedUp');
4749
} else {
4850
navigation.navigate('Error');
4951
}
@@ -108,6 +110,8 @@ const Loading = ({
108110
if (result.isErr()) {
109111
if (result.error.message.includes('GIFT_CODE_ALREADY_USED')) {
110112
navigation.navigate('Used', { amount });
113+
} else if (result.error.message.includes('GIFT_CODE_USED_UP')) {
114+
navigation.navigate('UsedUp');
111115
} else {
112116
navigation.navigate('Error');
113117
}

src/screens/Gift/UsedUp.tsx

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
import React, { ReactElement, memo } from 'react';
2+
import { useTranslation } from 'react-i18next';
3+
import { Image, StyleSheet, View } from 'react-native';
4+
5+
import BottomSheetNavigationHeader from '../../components/BottomSheetNavigationHeader';
6+
import GradientView from '../../components/GradientView';
7+
import SafeAreaInset from '../../components/SafeAreaInset';
8+
import Button from '../../components/buttons/Button';
9+
import { useSheetRef } from '../../sheets/SheetRefsProvider';
10+
import { BodyM } from '../../styles/text';
11+
12+
const imageSrc = require('../../assets/illustrations/exclamation-mark.png');
13+
14+
const UsedUp = (): ReactElement => {
15+
const { t } = useTranslation('other');
16+
const sheetRef = useSheetRef('gift');
17+
18+
const onContinue = (): void => {
19+
sheetRef.current?.close();
20+
};
21+
22+
return (
23+
<GradientView style={styles.root}>
24+
<BottomSheetNavigationHeader
25+
title={t('gift.used_up.title')}
26+
showBackButton={false}
27+
/>
28+
29+
<View style={styles.content}>
30+
<BodyM color="secondary">{t('gift.used_up.text')}</BodyM>
31+
32+
<View style={styles.imageContainer}>
33+
<Image style={styles.image} source={imageSrc} />
34+
</View>
35+
36+
<View style={styles.buttonContainer}>
37+
<Button
38+
style={styles.button}
39+
size="large"
40+
text={t('ok')}
41+
onPress={onContinue}
42+
/>
43+
</View>
44+
</View>
45+
<SafeAreaInset type="bottom" minPadding={16} />
46+
</GradientView>
47+
);
48+
};
49+
50+
const styles = StyleSheet.create({
51+
root: {
52+
flex: 1,
53+
},
54+
content: {
55+
flex: 1,
56+
paddingHorizontal: 16,
57+
},
58+
imageContainer: {
59+
flexShrink: 1,
60+
justifyContent: 'center',
61+
alignItems: 'center',
62+
alignSelf: 'center',
63+
width: 256,
64+
aspectRatio: 1,
65+
marginTop: 'auto',
66+
},
67+
image: {
68+
flex: 1,
69+
resizeMode: 'contain',
70+
},
71+
buttonContainer: {
72+
flexDirection: 'row',
73+
justifyContent: 'center',
74+
marginTop: 'auto',
75+
gap: 16,
76+
},
77+
button: {
78+
flex: 1,
79+
},
80+
});
81+
82+
export default memo(UsedUp);

src/sheets/GiftNavigation.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import BottomSheet from '../components/BottomSheet';
1010
import ErrorScreen from '../screens/Gift/Error';
1111
import Loading from '../screens/Gift/Loading';
1212
import Used from '../screens/Gift/Used';
13+
import UsedUp from '../screens/Gift/UsedUp';
1314
import { SheetsParamList } from '../store/types/ui';
1415
import BottomSheetNavigationContainer from './BottomSheetNavigationContainer';
1516

@@ -18,6 +19,7 @@ export type GiftNavigationProp = NativeStackNavigationProp<GiftStackParamList>;
1819
export type GiftStackParamList = {
1920
Loading: { code: string; amount: number };
2021
Used: { amount: number };
22+
UsedUp: undefined;
2123
Error: undefined;
2224
};
2325

@@ -45,6 +47,7 @@ const SheetContent = ({
4547
initialParams={{ code, amount }}
4648
/>
4749
<Stack.Screen name="Used" component={Used} />
50+
<Stack.Screen name="UsedUp" component={UsedUp} />
4851
<Stack.Screen name="Error" component={ErrorScreen} />
4952
</Stack.Navigator>
5053
</BottomSheetNavigationContainer>

src/utils/i18n/locales/en/other.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,17 @@
307307
"button": {
308308
"string": "OK"
309309
}
310+
},
311+
"used_up": {
312+
"title": {
313+
"string": "Out of Gifts"
314+
},
315+
"text": {
316+
"string": "Sorry, you're too late! All gifts for this code have already been claimed."
317+
},
318+
"button": {
319+
"string": "OK"
320+
}
310321
}
311322
},
312323
"shop": {

0 commit comments

Comments
 (0)