From fd5eb5ff0f9fbb75f51df0975a3c6054b7755130 Mon Sep 17 00:00:00 2001 From: Anxo Rodriguez Date: Tue, 17 Dec 2024 20:07:18 +0000 Subject: [PATCH] feat: make it more clear there's more pages --- .../orders/OrdersUserDetailsTable/index.tsx | 65 ++++++++++++++++--- .../OrdersTableWidget/OrdersTableWithData.tsx | 4 ++ 2 files changed, 59 insertions(+), 10 deletions(-) diff --git a/apps/explorer/src/components/orders/OrdersUserDetailsTable/index.tsx b/apps/explorer/src/components/orders/OrdersUserDetailsTable/index.tsx index 14d92dd28b..e98eb57d0d 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 } @@ -87,6 +91,32 @@ const NoOrdersContainer = styled.div` padding: 2rem; ` +const HiddenOrdersLegend = styled.tr` + p { + text-align: center; + } + + &:hover, + td:hover { + background-color: ${({ theme }) => theme.paper}; + color: ${({ theme }) => theme.textSecondary1}; + } + + td { + padding: 0; + font-size: 1.2rem; + color: ${({ theme }) => theme.textSecondary1}; + + a { + text-decoration: underline; + } + + a:hover { + color: ${({ theme }) => theme.textSecondary2}; + } + } +` + const RowOrder: React.FC = ({ order, isPriceInverted, showCanceledAndExpired, showPreSigning }) => { const { creationDate, buyToken, buyAmount, sellToken, sellAmount, kind, partiallyFilled, uid, filledPercentage } = order @@ -159,7 +189,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 +197,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) @@ -231,7 +264,7 @@ const OrdersUserDetailsTable: React.FC = (props) => { } 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.

-
+ ))} + + {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 above + {tableState.hasNextPage && ( + + , or go to next page for more orders. + + )} +

+ +
)} } 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 = () => { ) : (