mirror of
https://github.com/RoboSats/robosats.git
synced 2025-09-05 12:44:17 +00:00
Sort by premium when the order type is defined #2146
This commit is contained in:
@ -1,4 +1,4 @@
|
|||||||
import React, { useCallback, useContext, useEffect, useMemo, useState } from 'react';
|
import React, { useCallback, useContext, useEffect, useMemo, useState, useRef } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import {
|
import {
|
||||||
Box,
|
Box,
|
||||||
@ -774,6 +774,22 @@ const BookTable = ({
|
|||||||
: orders;
|
: orders;
|
||||||
}, [showControls, orders, fav, paymentMethods]);
|
}, [showControls, orders, fav, paymentMethods]);
|
||||||
|
|
||||||
|
const currentSortModel = useMemo(() => {
|
||||||
|
if (fav.type === 1) {
|
||||||
|
// buyer
|
||||||
|
return [{field: 'premium', sort: 'asc'}];
|
||||||
|
} else if (fav.type === 0) {
|
||||||
|
// seller
|
||||||
|
return [{field: 'premium', sort: 'desc'}];
|
||||||
|
} else {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
}, [fav]);
|
||||||
|
|
||||||
|
const prevSortModel = useRef<number | undefined>();
|
||||||
|
const sortModel = prevSortModel.current !== fav.type ? currentSortModel : undefined;
|
||||||
|
prevSortModel.current = fav.type;
|
||||||
|
|
||||||
if (!fullscreen) {
|
if (!fullscreen) {
|
||||||
return (
|
return (
|
||||||
<Paper
|
<Paper
|
||||||
@ -798,6 +814,7 @@ const BookTable = ({
|
|||||||
sx={headerStyleFix}
|
sx={headerStyleFix}
|
||||||
localeText={localeText}
|
localeText={localeText}
|
||||||
rows={filteredOrders}
|
rows={filteredOrders}
|
||||||
|
sortModel={sortModel}
|
||||||
getRowId={(params: PublicOrder) => `${String(params.coordinatorShortAlias)}/${params.id}`}
|
getRowId={(params: PublicOrder) => `${String(params.coordinatorShortAlias)}/${params.id}`}
|
||||||
loading={federation.loading}
|
loading={federation.loading}
|
||||||
columns={columns}
|
columns={columns}
|
||||||
@ -840,6 +857,7 @@ const BookTable = ({
|
|||||||
rows={filteredOrders}
|
rows={filteredOrders}
|
||||||
loading={federation.loading}
|
loading={federation.loading}
|
||||||
columns={columns}
|
columns={columns}
|
||||||
|
sortModel={sortModel}
|
||||||
hideFooter={!showFooter}
|
hideFooter={!showFooter}
|
||||||
slots={gridComponents}
|
slots={gridComponents}
|
||||||
page={page}
|
page={page}
|
||||||
|
Reference in New Issue
Block a user