vega-frontend-monorepo/apps/trading/components/select-market/select-market-table.tsx
m.ray 769828a39d
Fix/1763 trade futures (#1948)
* feat: #1763 display the product type in select market lists

* fix: #1763 add on top of deal ticket button notice that you are buying product type contracts

* fix: #1763 remove message above deal-ticket button

* fix: #1763 left align product type title

* fix: #1763 header align left for product type
2022-11-03 12:57:06 +00:00

66 lines
1.6 KiB
TypeScript

import classNames from 'classnames';
import { columnHeaders } from './select-market-columns';
import type { Column } from './select-market-columns';
export const SelectMarketTableHeader = ({
detailed = false,
headers = columnHeaders,
}) => {
return (
<tr className="sticky top-0 z-10 border-b border-default bg-inherit">
{headers.map(({ kind, value, className, onlyOnDetailed }) => {
const thClass = classNames(
'font-normal text-neutral-500 dark:text-neutral-400',
className
);
if (!onlyOnDetailed || detailed === onlyOnDetailed) {
return (
<th key={kind} className={thClass}>
{value}
</th>
);
}
return null;
})}
</tr>
);
};
export const SelectMarketTableRow = ({
detailed = false,
columns,
onSelect,
marketId,
}: {
detailed?: boolean;
columns: Column[];
onSelect: (id: string) => void;
marketId: string;
}) => {
return (
<tr
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 }) => {
if (!onlyOnDetailed || detailed === onlyOnDetailed) {
const tdClass = classNames(className);
return (
<td key={kind} data-testid={dataTestId} className={tdClass}>
{value}
</td>
);
}
return null;
})}
</tr>
);
};