vega-frontend-monorepo/apps/trading/pages/markets/index.page.tsx

42 lines
943 B
TypeScript
Raw Normal View History

import { gql } from '@apollo/client';
import { PageQueryContainer } from '../../components/page-query-container';
2022-02-17 05:03:46 +00:00
import Link from 'next/link';
import { useRouter } from 'next/router';
2022-02-28 23:43:36 +00:00
import { Markets } from './__generated__/Markets';
const MARKETS_QUERY = gql`
query Markets {
markets {
id
}
}
`;
2022-02-17 05:03:46 +00:00
const Markets = () => {
const { pathname } = useRouter();
2022-02-28 23:43:36 +00:00
2022-02-17 05:03:46 +00:00
return (
<PageQueryContainer<Markets> query={MARKETS_QUERY}>
{(data) => (
<>
<h1>Markets</h1>
<ul>
{data.markets.map((m) => (
<li key={m.id}>
<Link
href={`${pathname}/${m.id}?portfolio=orders&trade=orderbook`}
passHref={true}
>
<a>View market: {m.id}</a>
</Link>
</li>
))}
</ul>
</>
2022-02-28 23:43:36 +00:00
)}
</PageQueryContainer>
2022-02-17 05:03:46 +00:00
);
};
export default Markets;