From 3e1d8f143ad65c3ace55bf7b452edf4920e94ac9 Mon Sep 17 00:00:00 2001 From: Timothy LeBon Date: Tue, 24 Aug 2021 17:27:33 +0200 Subject: [PATCH 1/2] Fix: several small PM issues (#498) * feat: various responsive fixes for home and market/auction pages * chore: several hotfixes for pm * chore: fixing broken auction close Co-authored-by: Shubhendu Shekhar <9253059+shekhar-shubhendu@users.noreply.github.com> --- src/api/utils.ts | 3 +-- .../CloseOpenMarketCard/CloseOpenMarketCard.tsx | 4 ++-- .../organisms/PortfolioSummary/PortfolioSummary.tsx | 3 ++- src/pages/AuctionPage/AuctionPage.tsx | 2 +- src/pages/CreateMarketPage/CreateMarketPage.tsx | 2 +- src/pages/MarketPage/MarketPage.tsx | 6 +++--- src/pages/PortfolioPage/PortfolioPage.tsx | 10 +++++----- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/api/utils.ts b/src/api/utils.ts index f76e529ea..7f16fed9e 100644 --- a/src/api/utils.ts +++ b/src/api/utils.ts @@ -64,13 +64,12 @@ export const getClosedMarkets = (markets: Market[]): Market[] => const byOperationGroupNumber = R.descend(R.path(['txContext', 'operationGroupNumber'])); const byContentNumber = R.descend(R.path(['txContext', 'contentNumber'])); -const byOperationNumber = R.descend(R.path(['txContext', 'operationNumber'])); // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore export const orderByTxContext = (data: T): T => // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore - R.sortWith([byOperationGroupNumber, byOperationNumber, byContentNumber])(data); + R.sortWith([byOperationGroupNumber, byContentNumber])(data); export const toMarket = async ( graphMarket: GraphMarket, diff --git a/src/design-system/organisms/CloseOpenMarketCard/CloseOpenMarketCard.tsx b/src/design-system/organisms/CloseOpenMarketCard/CloseOpenMarketCard.tsx index b69ebefa5..e4ee0270f 100644 --- a/src/design-system/organisms/CloseOpenMarketCard/CloseOpenMarketCard.tsx +++ b/src/design-system/organisms/CloseOpenMarketCard/CloseOpenMarketCard.tsx @@ -55,7 +55,7 @@ export const CloseOpenMarketCard: React.FC = ({ }); } catch (error) { logError(error); - const errorText = error?.data[1]?.with?.string || t('txFailed'); + const errorText = error?.description || error?.data?.[1]?.with?.string || t('txFailed'); addToast(errorText, { appearance: 'error', autoDismiss: true, @@ -78,7 +78,7 @@ export const CloseOpenMarketCard: React.FC = ({ }); } catch (error) { logError(error); - const errorText = error?.data[1]?.with?.string || t('txFailed'); + const errorText = error?.description || error?.data?.[1]?.with?.string || t('txFailed'); addToast(errorText, { appearance: 'error', autoDismiss: true, diff --git a/src/design-system/organisms/PortfolioSummary/PortfolioSummary.tsx b/src/design-system/organisms/PortfolioSummary/PortfolioSummary.tsx index 11548a7b9..9a49b8eaf 100644 --- a/src/design-system/organisms/PortfolioSummary/PortfolioSummary.tsx +++ b/src/design-system/organisms/PortfolioSummary/PortfolioSummary.tsx @@ -4,6 +4,7 @@ import { Grid, useTheme } from '@material-ui/core'; import { Typography } from '../../atoms/Typography'; import { PaperWrapperStyled } from '../PortfolioTable/PortfolioTable'; import { CURRENCY_SYMBOL } from '../../../globals'; +import { roundToTwo } from '../../../utils/math'; export type Position = { type?: string; @@ -26,7 +27,7 @@ export const PortfolioSummary: React.FC = ({ const totalValue = React.useMemo(() => { return positions.reduce( (prev, curr) => ({ - value: prev.value + curr.value, + value: roundToTwo(prev.value + curr.value), weekly: curr.weekly && typeof curr.weekly === 'number' ? prev.weekly ?? 0 + curr.weekly diff --git a/src/pages/AuctionPage/AuctionPage.tsx b/src/pages/AuctionPage/AuctionPage.tsx index 19ef83136..5c1cf219b 100644 --- a/src/pages/AuctionPage/AuctionPage.tsx +++ b/src/pages/AuctionPage/AuctionPage.tsx @@ -246,7 +246,7 @@ export const AuctionPageComponent: React.FC = ({ market }) => } } catch (error) { logError(error); - const errorText = error?.data[1]?.with?.string || t('txFailed'); + const errorText = error?.description || error?.data?.[1]?.with?.string || t('txFailed'); addToast(errorText, { appearance: 'error', autoDismiss: true, diff --git a/src/pages/CreateMarketPage/CreateMarketPage.tsx b/src/pages/CreateMarketPage/CreateMarketPage.tsx index f00ce48cd..fb6aad8da 100644 --- a/src/pages/CreateMarketPage/CreateMarketPage.tsx +++ b/src/pages/CreateMarketPage/CreateMarketPage.tsx @@ -188,7 +188,7 @@ const CreateMarketPageComponent: React.FC = ({ t }) => { setIconURL(''); } catch (error) { logError(error); - const errorText = error?.data[1]?.with?.string || t('txFailed'); + const errorText = error?.description || error?.data?.[1]?.with?.string || t('txFailed'); addToast(errorText, { appearance: 'error', autoDismiss: true, diff --git a/src/pages/MarketPage/MarketPage.tsx b/src/pages/MarketPage/MarketPage.tsx index c56ac45af..f9439b0a7 100644 --- a/src/pages/MarketPage/MarketPage.tsx +++ b/src/pages/MarketPage/MarketPage.tsx @@ -225,7 +225,7 @@ export const MarketPageComponent: React.FC = ({ market }) => { helpers.resetForm(); } catch (error) { logError(error); - const errorText = error?.data[1]?.with?.string || t('txFailed'); + const errorText = error?.description || error?.data?.[1]?.with?.string || t('txFailed'); addToast(errorText, { appearance: 'error', autoDismiss: true, @@ -276,7 +276,7 @@ export const MarketPageComponent: React.FC = ({ market }) => { helpers.resetForm(); } catch (error) { logError(error); - const errorText = error?.data[1]?.with?.string || t('txFailed'); + const errorText = error?.description || error?.data?.[1]?.with?.string || t('txFailed'); addToast(errorText, { appearance: 'error', autoDismiss: true, @@ -300,7 +300,7 @@ export const MarketPageComponent: React.FC = ({ market }) => { } } catch (error) { logError(error); - const errorText = error?.data?.[1]?.with?.string || t('txFailed'); + const errorText = error?.description || error?.data?.[1]?.with?.string || t('txFailed'); addToast(errorText, { appearance: 'error', autoDismiss: true, diff --git a/src/pages/PortfolioPage/PortfolioPage.tsx b/src/pages/PortfolioPage/PortfolioPage.tsx index 30c17a169..285570c8c 100644 --- a/src/pages/PortfolioPage/PortfolioPage.tsx +++ b/src/pages/PortfolioPage/PortfolioPage.tsx @@ -73,7 +73,7 @@ export const PortfolioPageComponent: React.FC = ({ t }) => { } } catch (error) { logError(error); - const errorText = error?.data?.[1]?.with?.string || t('txFailed'); + const errorText = error?.description || error?.data?.[1]?.with?.string || t('txFailed'); addToast(errorText, { appearance: 'error', autoDismiss: true, @@ -92,7 +92,7 @@ export const PortfolioPageComponent: React.FC = ({ t }) => { getMarketLocalStorage(true, marketId, 'portfolio', 'true'); } catch (error) { logError(error); - const errorText = error?.data?.[1]?.with?.string || t('txFailed'); + const errorText = error?.description || error?.data?.[1]?.with?.string || t('txFailed'); addToast(errorText, { appearance: 'error', autoDismiss: true, @@ -262,7 +262,7 @@ export const PortfolioPageComponent: React.FC = ({ t }) => { }); return MarketRowList; }, - [activeAccount, t, ledgers, getMarketLocalStorage], + [activeAccount, t, ledgers, allBets], ); const setAuctionRows = React.useCallback( @@ -290,7 +290,7 @@ export const PortfolioPageComponent: React.FC = ({ t }) => { handleClick: () => history.push(`/market/${item.marketId}/${cardLink}`), rowAction: (role === Role.participant || Role.adjudicator) && - (status === 'Active' || 'Closed') && + (status === 'Active' || status === 'Closed') && !getMarketLocalStorage(false, item.marketId, 'portfolio') && isAuctionParticipant(item.marketId, allBets) ? { @@ -310,7 +310,7 @@ export const PortfolioPageComponent: React.FC = ({ t }) => { }); return AuctionRowList; }, - [activeAccount, t, allBets, getMarketLocalStorage], + [activeAccount, t, allBets], ); useEffect(() => { From ec2d8c9431e58c5a77376c6e245018b963d72583 Mon Sep 17 00:00:00 2001 From: shekhar-shubhendu Date: Tue, 24 Aug 2021 17:29:22 +0200 Subject: [PATCH 2/2] chore: bump version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e6f3c4886..52b18d518 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "prediction-market-ui", - "version": "0.7.0", + "version": "0.7.1", "private": false, "license": "MIT", "dependencies": {