diff --git a/apps/explorer/src/components/common/Tabs/Tabs.tsx b/apps/explorer/src/components/common/Tabs/Tabs.tsx index 26de10ba31..9413ff2e3b 100644 --- a/apps/explorer/src/components/common/Tabs/Tabs.tsx +++ b/apps/explorer/src/components/common/Tabs/Tabs.tsx @@ -42,7 +42,7 @@ export interface Props { readonly tabTheme: TabTheme readonly selectedTab?: TabId readonly extra?: TabBarExtraContent - readonly extraPosition?: 'top' | 'bottom' + readonly extraPosition?: 'top' | 'bottom' | 'both' readonly updateSelectedTab?: (activeId: TabId) => void } @@ -129,10 +129,10 @@ const Tabs: React.FC = (props) => { tabTheme={tabTheme} /> ))} - {extraPosition === 'top' && } + {['top', 'both'].includes(extraPosition) && } - {extraPosition === 'bottom' && } + {['bottom', 'both'].includes(extraPosition) && } ) } diff --git a/apps/explorer/src/components/orders/OrdersUserDetailsTable/index.tsx b/apps/explorer/src/components/orders/OrdersUserDetailsTable/index.tsx index 14d92dd28b..0efd2ec7e8 100644 --- a/apps/explorer/src/components/orders/OrdersUserDetailsTable/index.tsx +++ b/apps/explorer/src/components/orders/OrdersUserDetailsTable/index.tsx @@ -26,6 +26,8 @@ import { ToggleFilter } from './ToggleFilter' import { SimpleTable, SimpleTableProps } from '../../common/SimpleTable' import { StatusLabel } from '../StatusLabel' import { UnsignedOrderWarning } from '../UnsignedOrderWarning' +import { TableState } from '../../../explorer/components/TokensTableWidget/useTable' +import { Command } from '@cowprotocol/types' const EXPIRED_CANCELED_STATES: OrderStatus[] = ['cancelled', 'cancelling', 'expired'] @@ -53,6 +55,8 @@ const Wrapper = styled.div` export type Props = SimpleTableProps & { orders: Order[] | undefined + tableState: TableState + handleNextPage: Command messageWhenEmpty?: string | React.ReactNode } @@ -68,23 +72,48 @@ interface RowProps { const FilterRow = styled.tr` background-color: ${({ theme }) => theme.background}; - th { + @media (max-width: 1155px) { + div:first-child { + max-width: 90vw; + } + } + + td { + padding: 2rem; text-align: right; padding-right: 10px; - + max-width: 100%; & > * { margin-left: 10px; } } + + p { + word-wrap: break-word; + white-space: normal; + } ` -const NoOrdersContainer = styled.div` +const Filters = styled.div` display: flex; - flex-wrap: wrap; - align-items: center; justify-content: center; - flex-direction: column; - padding: 2rem; + flex-wrap: wrap; + flex-direction: row; + gap: 1rem; +` + +const HiddenOrdersLegend = styled.div` + p { + text-align: center; + } + + a { + text-decoration: underline; + } + + a:hover { + color: ${({ theme }) => theme.textSecondary2}; + } ` const RowOrder: React.FC = ({ order, isPriceInverted, showCanceledAndExpired, showPreSigning }) => { @@ -159,7 +188,7 @@ const RowOrder: React.FC = ({ order, isPriceInverted, showCanceledAndE } const OrdersUserDetailsTable: React.FC = (props) => { - const { orders, messageWhenEmpty } = props + const { orders, messageWhenEmpty, tableState, handleNextPage } = props const [isPriceInverted, setIsPriceInverted] = useState(false) const [showCanceledAndExpired, setShowCanceledAndExpired] = useState(false) const [showPreSigning, setShowPreSigning] = useState(false) @@ -167,8 +196,11 @@ const OrdersUserDetailsTable: React.FC = (props) => { const canceledAndExpiredCount = orders?.filter(isExpiredOrCanceled).length || 0 const preSigningCount = orders?.filter((order) => order.status === 'signing').length || 0 const showFilter = canceledAndExpiredCount > 0 || preSigningCount > 0 - const areOrdersAllHidden = - orders?.length === (showPreSigning ? 0 : preSigningCount) + (showCanceledAndExpired ? 0 : canceledAndExpiredCount) + + const hiddenOrdersCount = + (showPreSigning ? 0 : preSigningCount) + (showCanceledAndExpired ? 0 : canceledAndExpiredCount) + + const areOrdersAllHidden = orders?.length === hiddenOrdersCount const invertLimitPrice = (): void => { setIsPriceInverted((previousValue) => !previousValue) @@ -182,31 +214,6 @@ const OrdersUserDetailsTable: React.FC = (props) => { - {showFilter && ( - - - {canceledAndExpiredCount > 0 && ( - setShowCanceledAndExpired((previousValue) => !previousValue)} - label={(showCanceledAndExpired ? 'Hide' : 'Show') + ' canceled/expired'} - count={canceledAndExpiredCount} - /> - )} - {preSigningCount > 0 && ( - <> - setShowPreSigning((previousValue) => !previousValue)} - label={(showPreSigning ? 'Hide' : 'Show') + ' unsigned'} - count={preSigningCount} - /> - {showPreSigning && } - - )} - - - )} {!areOrdersAllHidden && ( @@ -227,11 +234,20 @@ const OrdersUserDetailsTable: React.FC = (props) => { Status )} + {showPreSigning && ( + + +
+ +
+ +
+ )} } body={ <> - {!areOrdersAllHidden ? ( + {!areOrdersAllHidden && orders.map((item) => ( = (props) => { showCanceledAndExpired={showCanceledAndExpired} showPreSigning={showPreSigning} /> - )) - ) : ( - -

No orders found.

-

You can toggle the filters to show the {orders.length} hidden orders.

-
+ ))} + + {showFilter && ( + + +
+ + {hiddenOrdersCount > 0 ? ( + <> +

+ Showing {orders.length - hiddenOrdersCount} out of {orders.length} orders for the current + page. +

+

+ {hiddenOrdersCount} orders are hidden, you can make them visible using the filters below + {tableState.hasNextPage ? ( + + , or go to next page for more orders. + + ) : ( + '.' + )} +

+ + ) : ( +

Showing all {orders.length} orders for the current page.

+ )} +
+ + {canceledAndExpiredCount > 0 && ( + setShowCanceledAndExpired((previousValue) => !previousValue)} + label={(showCanceledAndExpired ? 'Hide' : 'Show') + ' canceled/expired'} + count={canceledAndExpiredCount} + /> + )} + {preSigningCount > 0 && ( + <> + setShowPreSigning((previousValue) => !previousValue)} + label={(showPreSigning ? 'Hide' : 'Show') + ' unsigned'} + count={preSigningCount} + /> + + )} + +
+ +
)} } diff --git a/apps/explorer/src/explorer/components/OrdersTableWidget/OrdersTableWithData.tsx b/apps/explorer/src/explorer/components/OrdersTableWidget/OrdersTableWithData.tsx index 69bfaad2c1..bec399a58a 100644 --- a/apps/explorer/src/explorer/components/OrdersTableWidget/OrdersTableWithData.tsx +++ b/apps/explorer/src/explorer/components/OrdersTableWidget/OrdersTableWithData.tsx @@ -12,6 +12,8 @@ export const OrdersTableWithData: React.FC = () => { const { data: orders, addressAccountParams: { ownerAddress, networkId }, + tableState, + handleNextPage, } = useContext(OrdersTableContext) const isFirstRender = useFirstRender() const [isFirstLoading, setIsFirstLoading] = useState(true) @@ -46,6 +48,8 @@ export const OrdersTableWithData: React.FC = () => { ) : ( = ({ ownerAddress, networkId }) => { > {error && } - + ) } diff --git a/apps/explorer/src/explorer/components/common/ExplorerTabs/ExplorerTabs.tsx b/apps/explorer/src/explorer/components/common/ExplorerTabs/ExplorerTabs.tsx index cd5f1c712f..9e791b962b 100644 --- a/apps/explorer/src/explorer/components/common/ExplorerTabs/ExplorerTabs.tsx +++ b/apps/explorer/src/explorer/components/common/ExplorerTabs/ExplorerTabs.tsx @@ -5,11 +5,7 @@ import { Media } from '@cowprotocol/ui' import styled from 'styled-components/macro' import { DARK_COLOURS } from 'theme' -import Tabs, { - getTabTheme, - Props as TabsProps, - IndicatorTabSize, -} from '../../../../components/common/Tabs/Tabs' +import Tabs, { getTabTheme, Props as TabsProps, IndicatorTabSize } from '../../../../components/common/Tabs/Tabs' const StyledTabs = styled.div` display: flex; @@ -56,7 +52,7 @@ const tabCustomThemeConfig = getTabTheme({ indicatorTabSize: IndicatorTabSize.big, }) -type ExplorerTabsProps = Omit & { extraPosition?: 'top' | 'bottom' } +type ExplorerTabsProps = Omit & { extraPosition?: 'top' | 'bottom' | 'both' } const ExplorerTabs: React.FC = (props) => { return (