From 5dda58334ef4b7d71bbd626f83978e70905a0dc3 Mon Sep 17 00:00:00 2001 From: "m.ray" <16125548+MadalinaRaicu@users.noreply.github.com> Date: Tue, 27 Sep 2022 14:03:58 +0100 Subject: [PATCH] fix: 1425 add link on select market table row (#1493) * fix: #1425 add link on select market table row * fix: #1425 use only on select * fix: #1425 revert withdraw manager spec --- .../trading/pages/markets/[marketId].page.tsx | 3 ++- .../lib/components/select-market-columns.tsx | 23 +------------------ .../lib/components/select-market-table.tsx | 9 +++++++- .../src/lib/components/select-market.tsx | 4 ++++ 4 files changed, 15 insertions(+), 24 deletions(-) diff --git a/apps/trading/pages/markets/[marketId].page.tsx b/apps/trading/pages/markets/[marketId].page.tsx index 989cde26f..b38b854c6 100644 --- a/apps/trading/pages/markets/[marketId].page.tsx +++ b/apps/trading/pages/markets/[marketId].page.tsx @@ -83,7 +83,7 @@ const MARKET_QUERY = gql` `; const MarketPage = ({ id }: { id?: string }) => { - const { query } = useRouter(); + const { query, push } = useRouter(); const { w } = useWindowSize(); const { landingDialog, riskNoticeDialog, update } = useGlobalStore( (store) => ({ @@ -104,6 +104,7 @@ const MarketPage = ({ id }: { id?: string }) => { const onSelect = (id: string) => { if (id && id !== marketId) { updateStore({ marketId: id }); + push(`/markets/${id}`); } }; diff --git a/libs/market-list/src/lib/components/select-market-columns.tsx b/libs/market-list/src/lib/components/select-market-columns.tsx index 7e17ec920..211b5a36d 100644 --- a/libs/market-list/src/lib/components/select-market-columns.tsx +++ b/libs/market-list/src/lib/components/select-market-columns.tsx @@ -167,33 +167,12 @@ export const columns = ( const candlesClose = candles ?.map((candle) => candle?.close) .filter((c: string | undefined): c is CandleClose => !isNil(c)); - const handleKeyPress = ( - event: React.KeyboardEvent, - id: string - ) => { - if (event.key === 'Enter' && onSelect) { - return onSelect(id); - } - }; const candleLow = candles && calcCandleLow(candles); const candleHigh = candles && calcCandleHigh(candles); const selectMarketColumns: Column[] = [ { kind: ColumnKind.Market, - value: ( - - {/* eslint-disable-next-line jsx-a11y/anchor-is-valid,jsx-a11y/no-static-element-interactions */} - handleKeyPress(event, market.id)} - onClick={() => { - onSelect(market.id); - }} - data-testid={`market-link-${market.id}`} - > - {market.tradableInstrument.instrument.code} - - - ), + value: market.tradableInstrument.instrument.code, className: cellClassNames, onlyOnDetailed: false, }, diff --git a/libs/market-list/src/lib/components/select-market-table.tsx b/libs/market-list/src/lib/components/select-market-table.tsx index 27e87ee56..455c39425 100644 --- a/libs/market-list/src/lib/components/select-market-table.tsx +++ b/libs/market-list/src/lib/components/select-market-table.tsx @@ -31,13 +31,21 @@ export const SelectMarketTableHeader = ({ export const SelectMarketTableRow = ({ detailed = false, columns, + onSelect, + marketId, }: { detailed?: boolean; columns: Column[]; + onSelect: (id: string) => void; + marketId: string; }) => { return ( { + onSelect(marketId); + }} + data-testid={`market-link-${marketId}`} > {columns.map(({ kind, value, className, dataTestId, onlyOnDetailed }) => { if (!onlyOnDetailed || detailed === onlyOnDetailed) { @@ -48,7 +56,6 @@ export const SelectMarketTableRow = ({ ); } - return null; })} diff --git a/libs/market-list/src/lib/components/select-market.tsx b/libs/market-list/src/lib/components/select-market.tsx index ce262c8af..b4812b082 100644 --- a/libs/market-list/src/lib/components/select-market.tsx +++ b/libs/market-list/src/lib/components/select-market.tsx @@ -57,8 +57,10 @@ export const SelectMarketLandingTable = ({ {markets?.map((market, i) => ( {markets?.map((market, i) => (