Skip to content

Commit

Permalink
show validation error instead of auto amount update
Browse files Browse the repository at this point in the history
  • Loading branch information
EvgeniiaVak committed Dec 5, 2023
1 parent 3c92fe0 commit 322c545
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/app/state/orderInputSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -415,17 +415,21 @@ export const orderInputSlice = createSlice({

if (state.tab === OrderTab.MARKET) {
// MARKET
if (state.side === OrderSide.SELL) {
state.token2.amount = quote.toAmount;
} else {
state.token1.amount = quote.fromAmount;
}

// https://www.npmjs.com/package/alphadex-sdk-js#quoteresultmessages
if (quote.resultCode === 5 || quote.resultCode === 6) {
if (state.side === OrderSide.SELL) {
state.token1.amount = quote.fromAmount;
state.validationToken1.valid = false;
state.validationToken1.message = quote.resultMessageLong;
} else {
state.validationToken2.valid = false;
state.validationToken2.message = quote.resultMessageLong;
}
} else {
if (state.side === OrderSide.SELL) {
state.token2.amount = quote.toAmount;
} else {
state.token1.amount = quote.fromAmount;
}
}
} else {
Expand Down

0 comments on commit 322c545

Please sign in to comment.