import { gql, useQuery } from '@apollo/client'; import AutoSizer from 'react-virtualized-auto-sizer'; import classNames from 'classnames'; import { useRouter } from 'next/router'; import React, { Children, isValidElement, ReactNode } from 'react'; import { Market, MarketVariables } from './__generated__/Market'; // Top level page query const MARKET_QUERY = gql` query Market($marketId: ID!) { market(id: $marketId) { id name trades { id price size createdAt } } } `; const MarketPage = () => { const { query } = useRouter(); const { data, loading, error } = useQuery( MARKET_QUERY, { variables: { marketId: query.marketId as string }, skip: !query.marketId, } ); if (loading || !data) { return
Loading...
; } return ( <> {error ? (
Something went wrong: {error.message}
) : (

Market: {data.market.name}

TODO: Chart TODO: Ticket
{JSON.stringify(data, null, 2)}
Orderbook TODO:
TODO: Orders TODO: Positions TODO: Collateral
)} ); }; export default MarketPage; interface GridChildProps { children: ReactNode; className?: string; } const GridChild = ({ children, className }: GridChildProps) => { const gridChildClasses = classNames('bg-white', className); return (
{({ width, height }) => (
{children}
)}
); }; interface GridTabsProps { children: ReactNode; group: string; } const GridTabs = ({ children, group }: GridTabsProps) => { const { query, asPath, replace } = useRouter(); return (
{/* the tabs */}
{Children.map(children, (child) => { if (!isValidElement(child)) return null; const isActive = query[group] === child.props.name; const buttonClass = classNames('py-4 px-12', { 'text-vega-pink': isActive, 'bg-white': isActive, }); return ( ); })}
{/* the content */}
{Children.map(children, (child) => { if (isValidElement(child) && query[group] === child.props.name) { return (
{child.props.children}
); } return null; })}
); }; interface GridTabProps { children: ReactNode; name: string; } const GridTab = ({ children }: GridTabProps) => { return
{children}
; };