Skip to content

Commit bd02f31

Browse files
committed
refactors
1 parent 7113992 commit bd02f31

6 files changed

Lines changed: 22 additions & 22 deletions

File tree

app/components/UI/Assets/PriceAlerts/Views/CreatePriceAlertView/AbsolutePriceAlertForm.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ const AbsolutePriceAlertForm: React.FC<AbsolutePriceAlertFormProps> = ({
6464

6565
const hasInput = targetAmount !== KEYPAD_EMPTY;
6666
const targetPrice = useMemo(() => {
67-
const parsed = parseFloat(targetAmount);
67+
const parsed = Number.parseFloat(targetAmount);
6868
return Number.isFinite(parsed) ? parsed : 0;
6969
}, [targetAmount]);
7070
const hasValidTarget = targetPrice > 0;

app/components/UI/Assets/PriceAlerts/Views/CreatePriceAlertView/PercentChangeAlertForm.tsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ import {
66
Button,
77
ButtonVariant,
88
FontWeight,
9+
Icon,
10+
IconColor,
11+
IconName,
12+
IconSize,
913
Text,
1014
TextColor,
1115
TextVariant,
@@ -15,11 +19,6 @@ import { strings } from '../../../../../../../locales/i18n';
1519
import KeypadComponent, {
1620
type KeypadChangeData,
1721
} from '../../../../../Base/Keypad';
18-
import Icon, {
19-
IconColor,
20-
IconName,
21-
IconSize,
22-
} from '../../../../../../component-library/components/Icons/Icon';
2322
import AlertAmountInput from '../../components/AlertAmountInput';
2423
import AlertPeriodToggle from '../../components/AlertPeriodToggle';
2524
import RecurringToggle from '../../components/RecurringToggle';
@@ -74,7 +73,7 @@ const PercentChangeAlertForm: React.FC<PercentChangeAlertFormProps> = ({
7473

7574
const hasInput = percentAmount !== KEYPAD_EMPTY;
7675
const percentValue = useMemo(() => {
77-
const parsed = parseFloat(percentAmount);
76+
const parsed = Number.parseFloat(percentAmount);
7877
return Number.isFinite(parsed) ? parsed : 0;
7978
}, [percentAmount]);
8079
const hasValidPercent = percentValue > 0;
@@ -220,7 +219,9 @@ const PercentChangeAlertForm: React.FC<PercentChangeAlertFormProps> = ({
220219
<Icon
221220
name={direction === 'up' ? IconName.TrendUp : IconName.TrendDown}
222221
size={IconSize.Md}
223-
color={direction === 'up' ? IconColor.Success : IconColor.Error}
222+
color={
223+
direction === 'up' ? IconColor.SuccessDefault : IconColor.ErrorDefault
224+
}
224225
/>
225226
</TouchableOpacity>
226227
);

app/components/UI/Assets/PriceAlerts/Views/ManagePriceAlertsView/ManagePriceAlertsView.test.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import { notifyManager } from '@tanstack/query-core';
55
import ManagePriceAlertsView from './ManagePriceAlertsView';
66
import {
77
ManagePriceAlertsTestIds,
8+
type AbsolutePriceAlert,
89
type Alert,
910
type PercentChangeAlert,
10-
type PriceAlert,
1111
} from '../../constants';
1212
import Routes from '../../../../../../constants/navigation/Routes';
1313
import { ToastContext } from '../../../../../../component-library/components/Toast';
@@ -82,7 +82,9 @@ jest.mock('../../api', () => ({
8282
priceAlertsQueryKey: (assetId: string) => ['priceAlerts', assetId],
8383
}));
8484

85-
const makeAlert = (overrides: Partial<PriceAlert> = {}): PriceAlert => ({
85+
const makeAlert = (
86+
overrides: Partial<AbsolutePriceAlert> = {},
87+
): AbsolutePriceAlert => ({
8688
id: 'alert-1',
8789
userId: 'user-1',
8890
asset: 'eip155:1/slip44:60',

app/components/UI/Assets/PriceAlerts/api.test.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ import {
1818
useSubmitPriceAlert,
1919
useSubmitPercentAlert,
2020
} from './api';
21-
import type { Alert, PercentChangeAlert, PriceAlert } from './constants';
21+
import type {
22+
AbsolutePriceAlert,
23+
Alert,
24+
PercentChangeAlert,
25+
} from './constants';
2226

2327
// Prevents teardown crashes with unstable_batchedUpdates in Jest
2428
notifyManager.setBatchNotifyFunction((callback: () => void) => {
@@ -248,7 +252,9 @@ describe('priceAlertsQueryKey', () => {
248252
});
249253
});
250254

251-
const makeAlert = (overrides: Partial<PriceAlert> = {}): PriceAlert => ({
255+
const makeAlert = (
256+
overrides: Partial<AbsolutePriceAlert> = {},
257+
): AbsolutePriceAlert => ({
252258
id: 'alert-1',
253259
userId: 'user-1',
254260
asset: 'eip155:1/slip44:60',

app/components/UI/Assets/PriceAlerts/api.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import type {
55
Alert,
66
AbsolutePriceAlert,
77
PercentChangeAlert,
8-
PriceAlert,
98
SaveAlertParams,
109
SavePercentAlertParams,
1110
UpdateAlertParams,
@@ -114,7 +113,7 @@ export const deleteAlertByType = (alert: Alert): Promise<Response> =>
114113
? deletePercentAlert(alert.id)
115114
: deleteAlert(alert.id);
116115

117-
export const useSubmitPriceAlert = (editingAlert?: PriceAlert) => {
116+
export const useSubmitPriceAlert = (editingAlert?: AbsolutePriceAlert) => {
118117
const { mutateAsync, isPending } = useMutation<void, Error, SaveAlertParams>({
119118
mutationFn: async ({ asset, threshold, recurring }) => {
120119
const response = editingAlert

app/components/UI/Assets/PriceAlerts/constants.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,6 @@ export interface PercentChangeAlert extends BaseAlert {
5959
/** Any alert returned by the API. Narrow on `type` before reading period/direction. */
6060
export type Alert = AbsolutePriceAlert | PercentChangeAlert;
6161

62-
/**
63-
* @deprecated Prefer {@link Alert} (the discriminated union). Kept as an alias
64-
* to the absolute-price shape so existing absolute-only call sites keep
65-
* compiling; older API deployments may omit `type` entirely on this shape
66-
* (see `normalizeAlert` in `api.ts`).
67-
*/
68-
export type PriceAlert = AbsolutePriceAlert;
69-
7062
export const PRICE_ALERT_QUICK_PERCENTAGES = [-10, -5, 5, 10] as const;
7163

7264
/**

0 commit comments

Comments
 (0)