Skip to content

Commit

Permalink
fix pricing carrying over from previous pair
Browse files Browse the repository at this point in the history
  • Loading branch information
EvgeniiaVak committed Dec 18, 2023
1 parent bf26448 commit debed86
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/app/components/PairSelector.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useAppSelector, useAppDispatch } from "../hooks";
import { selectPairAddress } from "../state/pairSelectorSlice";
import { orderInputSlice } from "../state/orderInputSlice";
import { useRef, useState } from "react";

interface PairInfo {
Expand All @@ -13,14 +14,17 @@ function displayName(name?: string) {
export function PairSelector() {
const pairSelector = useAppSelector((state) => state.pairSelector);
const dispatch = useAppDispatch();
const selectPair = (pairAddress: string) => {
dispatch(selectPairAddress(pairAddress));
};

const options = pairSelector.pairsList;
const id = "pairOption";

const handleChange = (val: PairInfo | null) => {
if (val == null) return;
selectPair(val["address"]);

dispatch(orderInputSlice.actions.resetNumbersInput());

const pairAddress = val["address"];
dispatch(selectPairAddress(pairAddress));
};

const [query, setQuery] = useState("");
Expand Down
12 changes: 12 additions & 0 deletions src/app/state/orderInputSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,18 @@ export const orderInputSlice = createSlice({
state.validationToken1 = initialValidationResult;
state.validationToken2 = initialValidationResult;
},
resetNumbersInput(state) {
state.token1 = initialTokenInput;
state.token2 = initialTokenInput;
state.validationToken1 = initialValidationResult;
state.validationToken2 = initialValidationResult;
state.price = 0;
state.slippage = 0.01;
state.transactionInProgress = false;
state.transactionResult = undefined;
state.quote = undefined;
state.description = undefined;
},
},

// asynchronous reducers
Expand Down

0 comments on commit debed86

Please sign in to comment.