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
This commit is contained in:
parent
3b03b16938
commit
5dda58334e
@ -83,7 +83,7 @@ const MARKET_QUERY = gql`
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
const MarketPage = ({ id }: { id?: string }) => {
|
const MarketPage = ({ id }: { id?: string }) => {
|
||||||
const { query } = useRouter();
|
const { query, push } = useRouter();
|
||||||
const { w } = useWindowSize();
|
const { w } = useWindowSize();
|
||||||
const { landingDialog, riskNoticeDialog, update } = useGlobalStore(
|
const { landingDialog, riskNoticeDialog, update } = useGlobalStore(
|
||||||
(store) => ({
|
(store) => ({
|
||||||
@ -104,6 +104,7 @@ const MarketPage = ({ id }: { id?: string }) => {
|
|||||||
const onSelect = (id: string) => {
|
const onSelect = (id: string) => {
|
||||||
if (id && id !== marketId) {
|
if (id && id !== marketId) {
|
||||||
updateStore({ marketId: id });
|
updateStore({ marketId: id });
|
||||||
|
push(`/markets/${id}`);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -167,33 +167,12 @@ export const columns = (
|
|||||||
const candlesClose = candles
|
const candlesClose = candles
|
||||||
?.map((candle) => candle?.close)
|
?.map((candle) => candle?.close)
|
||||||
.filter((c: string | undefined): c is CandleClose => !isNil(c));
|
.filter((c: string | undefined): c is CandleClose => !isNil(c));
|
||||||
const handleKeyPress = (
|
|
||||||
event: React.KeyboardEvent<HTMLAnchorElement>,
|
|
||||||
id: string
|
|
||||||
) => {
|
|
||||||
if (event.key === 'Enter' && onSelect) {
|
|
||||||
return onSelect(id);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const candleLow = candles && calcCandleLow(candles);
|
const candleLow = candles && calcCandleLow(candles);
|
||||||
const candleHigh = candles && calcCandleHigh(candles);
|
const candleHigh = candles && calcCandleHigh(candles);
|
||||||
const selectMarketColumns: Column[] = [
|
const selectMarketColumns: Column[] = [
|
||||||
{
|
{
|
||||||
kind: ColumnKind.Market,
|
kind: ColumnKind.Market,
|
||||||
value: (
|
value: market.tradableInstrument.instrument.code,
|
||||||
<Link href={`/markets/${market.id}`} passHref={true}>
|
|
||||||
{/* eslint-disable-next-line jsx-a11y/anchor-is-valid,jsx-a11y/no-static-element-interactions */}
|
|
||||||
<a
|
|
||||||
onKeyPress={(event) => handleKeyPress(event, market.id)}
|
|
||||||
onClick={() => {
|
|
||||||
onSelect(market.id);
|
|
||||||
}}
|
|
||||||
data-testid={`market-link-${market.id}`}
|
|
||||||
>
|
|
||||||
{market.tradableInstrument.instrument.code}
|
|
||||||
</a>
|
|
||||||
</Link>
|
|
||||||
),
|
|
||||||
className: cellClassNames,
|
className: cellClassNames,
|
||||||
onlyOnDetailed: false,
|
onlyOnDetailed: false,
|
||||||
},
|
},
|
||||||
|
@ -31,13 +31,21 @@ export const SelectMarketTableHeader = ({
|
|||||||
export const SelectMarketTableRow = ({
|
export const SelectMarketTableRow = ({
|
||||||
detailed = false,
|
detailed = false,
|
||||||
columns,
|
columns,
|
||||||
|
onSelect,
|
||||||
|
marketId,
|
||||||
}: {
|
}: {
|
||||||
detailed?: boolean;
|
detailed?: boolean;
|
||||||
columns: Column[];
|
columns: Column[];
|
||||||
|
onSelect: (id: string) => void;
|
||||||
|
marketId: string;
|
||||||
}) => {
|
}) => {
|
||||||
return (
|
return (
|
||||||
<tr
|
<tr
|
||||||
className={`hover:bg-neutral-200 dark:hover:bg-neutral-700 cursor-pointer relative h-[34px]`}
|
className={`hover:bg-neutral-200 dark:hover:bg-neutral-700 cursor-pointer relative h-[34px]`}
|
||||||
|
onClick={() => {
|
||||||
|
onSelect(marketId);
|
||||||
|
}}
|
||||||
|
data-testid={`market-link-${marketId}`}
|
||||||
>
|
>
|
||||||
{columns.map(({ kind, value, className, dataTestId, onlyOnDetailed }) => {
|
{columns.map(({ kind, value, className, dataTestId, onlyOnDetailed }) => {
|
||||||
if (!onlyOnDetailed || detailed === onlyOnDetailed) {
|
if (!onlyOnDetailed || detailed === onlyOnDetailed) {
|
||||||
@ -48,7 +56,6 @@ export const SelectMarketTableRow = ({
|
|||||||
</td>
|
</td>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
})}
|
})}
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -57,8 +57,10 @@ export const SelectMarketLandingTable = ({
|
|||||||
<tbody>
|
<tbody>
|
||||||
{markets?.map((market, i) => (
|
{markets?.map((market, i) => (
|
||||||
<SelectMarketTableRow
|
<SelectMarketTableRow
|
||||||
|
marketId={market.id}
|
||||||
key={i}
|
key={i}
|
||||||
detailed={false}
|
detailed={false}
|
||||||
|
onSelect={onSelect}
|
||||||
columns={columns(
|
columns={columns(
|
||||||
market,
|
market,
|
||||||
marketsData?.find(
|
marketsData?.find(
|
||||||
@ -116,8 +118,10 @@ export const SelectAllMarketsTableBody = ({
|
|||||||
<tbody className="border-b-[10px] border-transparent">
|
<tbody className="border-b-[10px] border-transparent">
|
||||||
{markets?.map((market, i) => (
|
{markets?.map((market, i) => (
|
||||||
<SelectMarketTableRow
|
<SelectMarketTableRow
|
||||||
|
marketId={market.id}
|
||||||
key={i}
|
key={i}
|
||||||
detailed={true}
|
detailed={true}
|
||||||
|
onSelect={onSelect}
|
||||||
columns={tableColumns(
|
columns={tableColumns(
|
||||||
market,
|
market,
|
||||||
marketsData?.find(
|
marketsData?.find(
|
||||||
|
Loading…
Reference in New Issue
Block a user