From 1287c4454b8327b65d9c1a6f36b08fd611bb4e75 Mon Sep 17 00:00:00 2001 From: koalasat Date: Sun, 11 May 2025 16:34:45 +0200 Subject: [PATCH] Fix table --- frontend/src/components/BookTable/index.tsx | 83 +++---------------- .../components/OrderDetails/TakeButton.tsx | 2 +- 2 files changed, 14 insertions(+), 71 deletions(-) diff --git a/frontend/src/components/BookTable/index.tsx b/frontend/src/components/BookTable/index.tsx index 41daaf1b..098a2bcd 100644 --- a/frontend/src/components/BookTable/index.tsx +++ b/frontend/src/components/BookTable/index.tsx @@ -6,9 +6,6 @@ import { Dialog, Typography, Paper, - ListItemButton, - ListItemText, - ListItemAvatar, useTheme, CircularProgress, IconButton, @@ -18,7 +15,6 @@ import { } from '@mui/material'; import { DataGrid, - type GridColumnVisibilityModel, GridPagination, type GridPaginationModel, type GridColDef, @@ -97,7 +93,6 @@ const BookTable = ({ pageSize: 0, page: 0, }); - const [columnVisibilityModel, setColumnVisibilityModel] = useState({}); const [fullscreen, setFullscreen] = useState(defaultFullscreen); const [paymentMethods, setPaymentMethods] = useState([]); const [page, setPage] = useState(0); @@ -173,42 +168,6 @@ const BookTable = ({ }; }, []); - const robotObj = useCallback((width: number) => { - return { - field: 'maker_nick', - headerName: t('Robot'), - width: width * fontSize, - renderCell: (params: { row: PublicOrder }) => { - const thirdParty = thirdParties[params.row.coordinatorShortAlias]; - return ( - { - onOrderClicked(params.row.id, params.row.coordinatorShortAlias); - }} - > - - - - - - ); - }, - }; - }, []); - const robotSmallObj = useCallback((width: number) => { return { field: 'maker_nick', @@ -611,7 +570,7 @@ const BookTable = ({ priority: 1, order: 5, normal: { - width: fav.mode === 'swap' ? 9.5 : 6.5, + width: fav.mode === 'swap' ? 9.5 : 7, object: amountObj, }, }, @@ -630,6 +589,10 @@ const BookTable = ({ width: 6, object: premiumObj, }, + small: { + width: 4, + object: premiumObj, + }, }, payment_method: { priority: 4, @@ -647,10 +610,6 @@ const BookTable = ({ priority: 5, order: 1, normal: { - width: 17.14, - object: robotObj, - }, - small: { width: 5, object: robotSmallObj, }, @@ -712,8 +671,7 @@ const BookTable = ({ } { const useSmall = maxWidth < 70; const selectedColumns: object[] = []; - const columnVisibilityModel: GridColumnVisibilityModel = {}; - let width: number = 0; + let width: number = -4; for (const [key, value] of Object.entries(columnSpecs)) { // do not use col currency on swaps @@ -729,23 +687,18 @@ const BookTable = ({ if (width + colWidth < maxWidth || selectedColumns.length < 2) { width = width + colWidth; selectedColumns.push([colObject(colWidth), value.order]); - columnVisibilityModel[key] = true; - } else { - selectedColumns.push([colObject(colWidth), value.order]); - columnVisibilityModel[key] = false; } } // sort columns by column.order value - selectedColumns.sort(function (first, second) { - return first[1] - second[1]; - }); + const columns = selectedColumns + .sort(function (first, second) { + return first[1] - second[1]; + }) + .map(function (item) { + return item[0]; + }); - const columns: Array> = selectedColumns.map(function (item) { - return item[0]; - }); - - setColumnVisibilityModel(columnVisibilityModel); return { columns, width: maxWidth }; }; @@ -860,17 +813,12 @@ const BookTable = ({ /> )} `${String(params.coordinatorShortAlias)}/${params.id}`} loading={federation.loading} columns={columns} - columnVisibilityModel={columnVisibilityModel} - onColumnVisibilityModelChange={(newColumnVisibilityModel) => { - setColumnVisibilityModel(newColumnVisibilityModel); - }} page={page} onPageChange={setPage} hideFooter={!showFooter} @@ -903,7 +851,6 @@ const BookTable = ({ /> )} { - setColumnVisibilityModel(newColumnVisibilityModel); - }} page={page} onPageChange={setPage} paginationModel={paginationModel} diff --git a/frontend/src/components/OrderDetails/TakeButton.tsx b/frontend/src/components/OrderDetails/TakeButton.tsx index abbf4457..81c54c96 100644 --- a/frontend/src/components/OrderDetails/TakeButton.tsx +++ b/frontend/src/components/OrderDetails/TakeButton.tsx @@ -208,7 +208,7 @@ const TakeButton = ({ alignItems='flex-start' justifyContent='space-evenly' > - +