Skip to content

Commit

Permalink
updated ux for reset price flow (#1553)
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnDanz authored Nov 9, 2021
1 parent fb7a5e8 commit 3a443d5
Showing 1 changed file with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useState, useEffect, useMemo } from "react";
import classNames from "classnames";
import Styles, { isResetPrices } from "./market-liquidity-view.styles.less";
import Styles from "./market-liquidity-view.styles.less";
import CommonStyles from "../modal/modal.styles.less";
import ButtonStyles from "../common/buttons.styles.less";
import { useHistory, useLocation } from "react-router";
Expand Down Expand Up @@ -123,6 +123,7 @@ export const MarketLiquidityView = () => {
const [selectedAction, setSelectedAction] = useState(actionType);
useScrollToTopOnMount();
const isRemove = selectedAction === REMOVE;
const isResetPrices = selectedAction === RESET_PRICES;
const maxWhackedCollateral = market && maxWhackedCollateralAmount(market?.amm);
const shareBalance =
balances &&
Expand All @@ -144,7 +145,7 @@ export const MarketLiquidityView = () => {
};
return (
<div className={classNames(Styles.MarketLiquidityView)}>
<BackBar {...{ market, selectedAction, setSelectedAction, BackToLPPageAction, setAmount }} />
<BackBar {...{ market, selectedAction, setSelectedAction, BackToLPPageAction, setAmount, maxWhackedCollateral }} />
<MarketLink id={marketId} dontGoToMarket={false}>
<CategoryIcon {...{ categories }} />
<MarketTitleArea {...{ ...market, timeFormat }} />
Expand All @@ -155,17 +156,22 @@ export const MarketLiquidityView = () => {
);
};

const BackBar = ({ BackToLPPageAction, selectedAction, setSelectedAction, setAmount, market }) => {
const BackBar = ({ BackToLPPageAction, selectedAction, setSelectedAction, setAmount, market, maxWhackedCollateral }) => {
const isMint = selectedAction === MINT_SETS;
const isReset = selectedAction === RESET_PRICES;
const isWhacked = isMarketPoolWhacked(market.amm) || true;
const isWhacked = isMarketPoolWhacked(market.amm);
return (
<div className={Styles.BackBar}>
<button onClick={BackToLPPageAction}>{BackIcon} Back To Pools</button>
{(isWhacked || (isReset && !isWhacked)) && (
<TinyThemeButton
action={() => {
setSelectedAction(isReset ? ADD : RESET_PRICES);
if (isReset) {
setAmount("");
} else {
setAmount(maxWhackedCollateral.collateralUsd);
}
}}
text={isReset ? "Add/Remove" : "Reset Prices"}
small
Expand Down Expand Up @@ -570,6 +576,7 @@ const LiquidityForm = ({
afterSigningAction: BackToLPPageAction,
onCancel,
isMint,
isResetPrices,
});
},
targetDescription: {
Expand Down Expand Up @@ -701,6 +708,7 @@ const confirmAction = async ({
afterSigningAction = () => {},
onCancel = null,
isMint,
isResetPrices,
}) => {
const valid = checkConvertLiquidityProperties(account, market.marketId, amount, onChainFee, outcomes, cash);
if (!valid) {
Expand Down

0 comments on commit 3a443d5

Please sign in to comment.