Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions frontend/src/components/BookTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,19 @@ const BookTable = ({
: orders;
}, [showControls, orders, fav, paymentMethods]);

const sortModel = useMemo(() => {
if (fav.type === 1) {
// buyer - sort ascending to show best deals first (lowest premium)
return [{ field: 'premium', sort: 'asc' as const }];
} else if (fav.type === 0) {
// seller - sort descending to show best deals first (highest premium)
return [{ field: 'premium', sort: 'desc' as const }];
} else {
// no filter selected
return [];
}
}, [fav.type]);

if (!fullscreen) {
return (
<Paper
Expand All @@ -804,6 +817,7 @@ const BookTable = ({
sx={headerStyleFix}
localeText={localeText}
rows={filteredOrders}
sortModel={sortModel}
getRowId={(params: PublicOrder) => `${String(params.coordinatorShortAlias)}/${params.id}`}
loading={federation.loading}
columns={columns}
Expand Down Expand Up @@ -844,6 +858,7 @@ const BookTable = ({
rowHeight={3.714 * theme.typography.fontSize}
headerHeight={3.25 * theme.typography.fontSize}
rows={filteredOrders}
sortModel={sortModel}
loading={federation.loading}
columns={columns}
hideFooter={!showFooter}
Expand Down