Skip to content

Commit f35cc53

Browse files
committed
ai report fixes
1 parent a6d2247 commit f35cc53

6 files changed

Lines changed: 3 additions & 153 deletions

File tree

app/components/Nav/Main/MainNavigator.test.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,8 @@ describe('MainNavigator', () => {
159159
}) => React.ReactNode;
160160
};
161161

162+
// rewardsViewRoute is found via .find(r => r.name === Routes.REWARDS_VIEW),
163+
// so the inner route that wraps the nested nav state must carry that name.
162164
const buildRewardsState = (activeRouteName: string | undefined) => ({
163165
routes: [
164166
{

app/components/UI/Rewards/hooks/useLinkAccountAddress.test.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -82,16 +82,6 @@ describe('useLinkAccountAddress', () => {
8282
iconName: 'confirmation',
8383
hapticsType: 'success',
8484
}),
85-
campaignWon: jest.fn().mockReturnValue({
86-
variant: 'icon',
87-
iconName: 'trophy',
88-
hapticsType: 'success',
89-
}),
90-
campaignEnded: jest.fn().mockReturnValue({
91-
variant: 'icon',
92-
iconName: 'info',
93-
hapticsType: 'warning',
94-
}),
9585
};
9686

9787
const mockAccount: InternalAccount = {

app/components/UI/Rewards/hooks/useLinkAccountGroup.test.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -103,16 +103,6 @@ describe('useLinkAccountGroup', () => {
103103
iconName: 'error',
104104
hapticsType: 'error',
105105
}),
106-
campaignWon: jest.fn().mockReturnValue({
107-
variant: 'icon',
108-
iconName: 'trophy',
109-
hapticsType: 'success',
110-
}),
111-
campaignEnded: jest.fn().mockReturnValue({
112-
variant: 'icon',
113-
iconName: 'info',
114-
hapticsType: 'warning',
115-
}),
116106
};
117107

118108
// Mock account data

app/components/UI/Rewards/hooks/useRewardsToast.test.tsx

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -218,53 +218,6 @@ describe('useRewardsToast', () => {
218218
});
219219
});
220220

221-
it('returns campaignWon configuration with link, trophy accessory, and no timeout', () => {
222-
const { result } = renderHook(() => useRewardsToast());
223-
const onLinkPress = jest.fn();
224-
const config = result.current.RewardsToastOptions.campaignWon(
225-
'You won',
226-
'Claim now',
227-
'View',
228-
onLinkPress,
229-
);
230-
231-
expect(config).toMatchObject({
232-
variant: ToastVariants.Icon,
233-
hasNoTimeout: true,
234-
hapticsType: NotificationFeedbackType.Success,
235-
});
236-
expect(config.descriptionOptions).toEqual({ description: 'Claim now' });
237-
expect(config.startAccessory).toBeDefined();
238-
expect(config.linkButtonOptions).toMatchObject({ label: 'View' });
239-
expect(config.closeButtonOptions).toBeUndefined();
240-
config.linkButtonOptions?.onPress();
241-
expect(onLinkPress).toHaveBeenCalledTimes(1);
242-
expect(mockCloseToast).toHaveBeenCalledTimes(1);
243-
});
244-
245-
it('returns campaignEnded configuration with link and no timeout', () => {
246-
const { result } = renderHook(() => useRewardsToast());
247-
const onLinkPress = jest.fn();
248-
const config = result.current.RewardsToastOptions.campaignEnded(
249-
'Campaign ended',
250-
'Thanks for playing',
251-
'View',
252-
onLinkPress,
253-
);
254-
255-
expect(config).toMatchObject({
256-
variant: ToastVariants.Icon,
257-
iconName: IconName.Info,
258-
hasNoTimeout: true,
259-
hapticsType: NotificationFeedbackType.Warning,
260-
});
261-
expect(config.linkButtonOptions).toMatchObject({ label: 'View' });
262-
expect(config.closeButtonOptions).toBeUndefined();
263-
config.linkButtonOptions?.onPress();
264-
expect(onLinkPress).toHaveBeenCalledTimes(1);
265-
expect(mockCloseToast).toHaveBeenCalledTimes(1);
266-
});
267-
268221
it('calls closeToast when close button is pressed', () => {
269222
const { result } = renderHook(() => useRewardsToast());
270223
const config = result.current.RewardsToastOptions.success('Test Title');

app/components/UI/Rewards/hooks/useRewardsToast.tsx

Lines changed: 1 addition & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
import React, { useCallback, useContext, useMemo } from 'react';
2-
import {
3-
Box,
4-
Icon,
5-
IconSize,
6-
IconName as IconNameDesignSystem,
7-
} from '@metamask/design-system-react-native';
1+
import { useCallback, useContext, useMemo } from 'react';
82
import { ToastContext } from '../../../../component-library/components/Toast';
93
import {
104
ButtonIconVariant,
@@ -16,8 +10,6 @@ import {
1610
import { IconName } from '../../../../component-library/components/Icons/Icon';
1711
import { useAppThemeFromContext } from '../../../../util/theme';
1812
import { notificationAsync, NotificationFeedbackType } from 'expo-haptics';
19-
import TrophyIcon from '../../../../images/rewards/trophy.svg';
20-
import { ButtonSize } from '../../../../component-library/components/Buttons/Button';
2113

2214
export type RewardsToastOptions = ToastOptions & {
2315
hapticsType: NotificationFeedbackType;
@@ -27,18 +19,6 @@ export interface RewardsToastConfig {
2719
success: (title: string, subtitle?: string) => RewardsToastOptions;
2820
error: (title: string, subtitle?: string) => RewardsToastOptions;
2921
entriesClosed: (title: string, subtitle?: string) => RewardsToastOptions;
30-
campaignWon: (
31-
title: string,
32-
subtitle: string,
33-
linkLabel: string,
34-
onLinkPress: () => void,
35-
) => RewardsToastOptions;
36-
campaignEnded: (
37-
title: string,
38-
subtitle: string,
39-
linkLabel: string,
40-
onLinkPress: () => void,
41-
) => RewardsToastOptions;
4222
}
4323

4424
const getRewardsToastLabels = (title: string): ToastLabelOptions => {
@@ -137,64 +117,6 @@ const useRewardsToast = (): {
137117
},
138118
},
139119
}),
140-
campaignWon: (
141-
title: string,
142-
subtitle: string,
143-
linkLabel: string,
144-
onLinkPress: () => void,
145-
) => ({
146-
...(REWARDS_TOASTS_DEFAULT_OPTIONS as RewardsToastOptions),
147-
variant: ToastVariants.Icon,
148-
iconName: IconName.Confirmation,
149-
iconColor: theme.colors.success.default,
150-
backgroundColor: 'transparent',
151-
hapticsType: NotificationFeedbackType.Success,
152-
labelOptions: getRewardsToastLabels(title),
153-
descriptionOptions: getRewardsToastDescriptionLabels(subtitle),
154-
hasNoTimeout: true,
155-
linkButtonOptions: {
156-
label: linkLabel,
157-
size: ButtonSize.Sm,
158-
onPress: () => {
159-
onLinkPress();
160-
toastRef?.current?.closeToast();
161-
},
162-
},
163-
startAccessory: (
164-
<Box twClassName="mr-2 h-6 w-6 self-start items-center justify-center">
165-
<TrophyIcon name="trophy" width={24} height={24} />
166-
</Box>
167-
),
168-
}),
169-
campaignEnded: (
170-
title: string,
171-
subtitle: string,
172-
linkLabel: string,
173-
onLinkPress: () => void,
174-
) => ({
175-
...(REWARDS_TOASTS_DEFAULT_OPTIONS as RewardsToastOptions),
176-
variant: ToastVariants.Icon,
177-
iconName: IconName.Info,
178-
iconColor: theme.colors.icon.default,
179-
backgroundColor: 'transparent',
180-
hapticsType: NotificationFeedbackType.Warning,
181-
labelOptions: getRewardsToastLabels(title),
182-
descriptionOptions: getRewardsToastDescriptionLabels(subtitle),
183-
hasNoTimeout: true,
184-
linkButtonOptions: {
185-
label: linkLabel,
186-
size: ButtonSize.Sm,
187-
onPress: () => {
188-
onLinkPress();
189-
toastRef?.current?.closeToast();
190-
},
191-
},
192-
startAccessory: (
193-
<Box twClassName="mr-2 h-6 w-6 self-start items-center justify-center">
194-
<Icon name={IconNameDesignSystem.Joystick} size={IconSize.Md} />
195-
</Box>
196-
),
197-
}),
198120
}),
199121
[
200122
theme.colors.success.default,

locales/languages/en.json

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8275,13 +8275,6 @@
82758275
"retry_button": "Retry",
82768276
"refreshing": "Refreshing..."
82778277
},
8278-
"campaign_end_toast": {
8279-
"view": "View",
8280-
"won_title": "You won the {{campaignName}}",
8281-
"won_description": "Claim your prize now!",
8282-
"ended_title": "{{campaignName}} has ended",
8283-
"ended_description": "Thanks for participating. Open the campaign to see results."
8284-
},
82858278
"ondo_winning_banner": {
82868279
"title": "You won the {{campaignName}}",
82878280
"description": "Claim your prize now!"

0 commit comments

Comments
 (0)