Skip to content

Commit 1c22b53

Browse files
committed
small parameter refactor
1 parent 956fcda commit 1c22b53

5 files changed

Lines changed: 4 additions & 16 deletions

File tree

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ const baseProps: React.ComponentProps<typeof AbsolutePriceAlertForm> = {
5353
displayTicker: 'ETH',
5454
currentPrice: 1201.98,
5555
currentCurrency: 'USD',
56-
isEditing: false,
5756
};
5857

5958
const editingAlert: AbsolutePriceAlert = {
@@ -504,7 +503,6 @@ describe('AbsolutePriceAlertForm', () => {
504503
describe('editing', () => {
505504
const renderEditingForm = () =>
506505
renderForm({
507-
isEditing: true,
508506
editingAlert,
509507
existingThresholds: [1500],
510508
fromManage: true,
@@ -713,7 +711,6 @@ describe('AbsolutePriceAlertForm', () => {
713711

714712
it('tracks previous and updated threshold properties while editing', async () => {
715713
const screen = renderForm({
716-
isEditing: true,
717714
editingAlert,
718715
existingThresholds: [1500],
719716
fromManage: true,

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ interface AbsolutePriceAlertFormProps {
3838
currentPrice: number;
3939
currentCurrency: string;
4040
fromManage?: boolean;
41-
isEditing: boolean;
4241
editingAlert?: AbsolutePriceAlert;
4342
existingThresholds?: number[];
4443
}
@@ -49,12 +48,12 @@ const AbsolutePriceAlertForm: React.FC<AbsolutePriceAlertFormProps> = ({
4948
currentPrice,
5049
currentCurrency,
5150
fromManage,
52-
isEditing,
5351
editingAlert,
5452
existingThresholds,
5553
}) => {
5654
const tw = useTailwind();
5755
const { trackEvent, createEventBuilder } = useAnalytics();
56+
const isEditing = Boolean(editingAlert);
5857
const [targetAmount, setTargetAmount] = useState(
5958
editingAlert ? toKeypadString(editingAlert.threshold) : KEYPAD_EMPTY,
6059
);
@@ -128,7 +127,7 @@ const AbsolutePriceAlertForm: React.FC<AbsolutePriceAlertFormProps> = ({
128127
threshold: targetPrice,
129128
recurring: isRecurring,
130129
});
131-
if (isEditing && editingAlert) {
130+
if (editingAlert) {
132131
patchAlertCache(editingAlert.id, {
133132
threshold: targetPrice,
134133
recurring: isRecurring,
@@ -175,7 +174,6 @@ const AbsolutePriceAlertForm: React.FC<AbsolutePriceAlertFormProps> = ({
175174
displayTicker,
176175
editingAlert,
177176
hasValidTarget,
178-
isEditing,
179177
isRecurring,
180178
navigateAfterSave,
181179
patchAlertCache,

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ const CreatePriceAlertView: React.FC = () => {
123123
assetId={assetId}
124124
displayTicker={displayTicker}
125125
fromManage={fromManage}
126-
isEditing={isEditing}
127126
editingAlert={editingPercentAlert}
128127
existingPercentAlerts={existingPercentAlerts}
129128
/>
@@ -134,7 +133,6 @@ const CreatePriceAlertView: React.FC = () => {
134133
currentPrice={currentPrice}
135134
currentCurrency={currentCurrency}
136135
fromManage={fromManage}
137-
isEditing={isEditing}
138136
editingAlert={editingAbsoluteAlert}
139137
existingThresholds={existingThresholds}
140138
/>

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ function WithToast({ children }: { children: React.ReactNode }) {
5151
const baseProps: React.ComponentProps<typeof PercentChangeAlertForm> = {
5252
assetId: 'eip155:1/slip44:60',
5353
displayTicker: 'ETH',
54-
isEditing: false,
5554
};
5655

5756
const editingPercentAlert: PercentChangeAlert = {
@@ -158,7 +157,6 @@ describe('PercentChangeAlertForm', () => {
158157

159158
it('prepopulates edit values and locks immutable form controls', () => {
160159
const screen = renderForm({
161-
isEditing: true,
162160
editingAlert: editingPercentAlert,
163161
existingPercentAlerts: [editingPercentAlert],
164162
});
@@ -179,7 +177,6 @@ describe('PercentChangeAlertForm', () => {
179177

180178
it('updates a percent alert after recurrence changes', async () => {
181179
const screen = renderForm({
182-
isEditing: true,
183180
editingAlert: editingPercentAlert,
184181
existingPercentAlerts: [editingPercentAlert],
185182
});

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ interface PercentChangeAlertFormProps {
4343
assetId: string;
4444
displayTicker: string;
4545
fromManage?: boolean;
46-
isEditing: boolean;
4746
editingAlert?: PercentChangeAlert;
4847
existingPercentAlerts?: PercentChangeAlert[];
4948
}
@@ -52,12 +51,12 @@ const PercentChangeAlertForm: React.FC<PercentChangeAlertFormProps> = ({
5251
assetId,
5352
displayTicker,
5453
fromManage,
55-
isEditing,
5654
editingAlert,
5755
existingPercentAlerts,
5856
}) => {
5957
const tw = useTailwind();
6058
const { trackEvent, createEventBuilder } = useAnalytics();
59+
const isEditing = Boolean(editingAlert);
6160
const [percentAmount, setPercentAmount] = useState(
6261
editingAlert ? toPercentKeypadString(editingAlert.threshold) : KEYPAD_EMPTY,
6362
);
@@ -127,7 +126,7 @@ const PercentChangeAlertForm: React.FC<PercentChangeAlertFormProps> = ({
127126
direction,
128127
recurring: isRecurring,
129128
});
130-
if (isEditing && editingAlert) {
129+
if (editingAlert) {
131130
patchAlertCache(editingAlert.id, {
132131
threshold: percentValue,
133132
recurring: isRecurring,
@@ -179,7 +178,6 @@ const PercentChangeAlertForm: React.FC<PercentChangeAlertFormProps> = ({
179178
displayTicker,
180179
editingAlert,
181180
hasValidPercent,
182-
isEditing,
183181
isRecurring,
184182
navigateAfterSave,
185183
patchAlertCache,

0 commit comments

Comments
 (0)