From 88c1b9143a2bacb63c8796f5b46d7c841a5196de Mon Sep 17 00:00:00 2001 From: Kanishka Date: Sun, 22 Mar 2026 20:21:52 +0530 Subject: [PATCH 1/3] Fix: price column sorting in offers table --- frontend/src/components/BookTable/index.tsx | 30 +++++++++++++++++---- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/frontend/src/components/BookTable/index.tsx b/frontend/src/components/BookTable/index.tsx index afe7963f5..bb38d85d4 100644 --- a/frontend/src/components/BookTable/index.tsx +++ b/frontend/src/components/BookTable/index.tsx @@ -386,18 +386,38 @@ const BookTable = ({ }; }, []); + const getOrderPrice = useCallback( + (row: PublicOrder): number | null => { + const limits = federation.getLimits(row.coordinatorShortAlias); + const limitPrice = limits[row.currency.toString()]?.price; + if (!limitPrice) return null; + const premium = parseFloat(row.premium); + return limitPrice * (1 + premium / 100); + }, + [federation], + ); + const priceObj = useCallback(() => { return { field: 'price', headerName: t('Price'), type: 'number', flex: 2, + sortComparator: ( + _v1: number, + _v2: number, + p1: { api: { getRow: (id: number) => PublicOrder }; id: number }, + p2: { api: { getRow: (id: number) => PublicOrder }; id: number }, + ) => { + const row1 = p1.api.getRow(p1.id); + const row2 = p2.api.getRow(p2.id); + const price1 = getOrderPrice(row1) ?? 0; + const price2 = getOrderPrice(row2) ?? 0; + return price1 - price2; + }, renderCell: (params: { row: PublicOrder }) => { const currencyCode = String(currencyDict[params.row.currency.toString()]); - const limits = federation.getLimits(params.row.coordinatorShortAlias); - const premium = parseFloat(params.row.premium); - const limitPrice = limits[params.row.currency.toString()]?.price; - const price = (limitPrice ?? 1) * (1 + premium / 100); + const price = getOrderPrice(params.row); return (
- {limitPrice ? ( + {price ? ( `${pn(Math.round(price))} ${currencyCode}/BTC` ) : ( From c4c42d0615c4cbda750a0d70a34539083ab78790 Mon Sep 17 00:00:00 2001 From: KoalaSat Date: Fri, 21 Aug 2026 08:20:45 +0000 Subject: [PATCH 2/3] Update index.tsx --- frontend/src/components/BookTable/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/components/BookTable/index.tsx b/frontend/src/components/BookTable/index.tsx index 785f09c11..eb5ca9fdd 100644 --- a/frontend/src/components/BookTable/index.tsx +++ b/frontend/src/components/BookTable/index.tsx @@ -442,7 +442,7 @@ const BookTable = ({ return price1 - price2; }, renderCell: (params: { row: PublicOrder }) => { - const currencyCode = String(currencyDict[params.row.currency ?? 0).toString()]); + const currencyCode = String(currencyDict[params.row.currency ?? 0]).toString()]); const price = getOrderPrice(params.row); return ( From 11740692f42273ed31e41ceb1ad7ca1a717b3974 Mon Sep 17 00:00:00 2001 From: Kanishka Date: Fri, 21 Aug 2026 14:54:45 +0530 Subject: [PATCH 3/3] Fix TypeScript type-check errors --- frontend/src/components/BookTable/index.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/frontend/src/components/BookTable/index.tsx b/frontend/src/components/BookTable/index.tsx index eb5ca9fdd..e1f2c7ae9 100644 --- a/frontend/src/components/BookTable/index.tsx +++ b/frontend/src/components/BookTable/index.tsx @@ -414,10 +414,10 @@ const BookTable = ({ const getOrderPrice = useCallback( (row: PublicOrder): number | null => { - const limits = federation.getLimits(row.coordinatorShortAlias); - const limitPrice = limits[row.currency.toString()]?.price; + const limits = federation.getLimits(row.coordinatorShortAlias ?? ''); + const limitPrice = limits[(row.currency ?? 0).toString()]?.price; if (!limitPrice) return null; - const premium = parseFloat(row.premium); + const premium = parseFloat(row.premium ?? '0'); return limitPrice * (1 + premium / 100); }, [federation], @@ -442,7 +442,7 @@ const BookTable = ({ return price1 - price2; }, renderCell: (params: { row: PublicOrder }) => { - const currencyCode = String(currencyDict[params.row.currency ?? 0]).toString()]); + const currencyCode = String(currencyDict[(params.row.currency ?? 0).toString()]); const price = getOrderPrice(params.row); return (