diff --git a/apps/admin-panel/app/customers/[customer-id]/transactions/list.tsx b/apps/admin-panel/app/customers/[customer-id]/transactions/list.tsx index 57bdb544b..17a1d4dfa 100644 --- a/apps/admin-panel/app/customers/[customer-id]/transactions/list.tsx +++ b/apps/admin-panel/app/customers/[customer-id]/transactions/list.tsx @@ -27,7 +27,13 @@ export const CustomerTransactionsTable: React.FC Transactions for this Customer {transactions.length === 0 ? ( - No data to display + +
+
+
No data to display
+
+
+
) : (
diff --git a/apps/admin-panel/components/data-table/index.tsx b/apps/admin-panel/components/data-table/index.tsx index d0dff812d..c8695bb3d 100644 --- a/apps/admin-panel/components/data-table/index.tsx +++ b/apps/admin-panel/components/data-table/index.tsx @@ -28,6 +28,8 @@ interface DataTableProps { loading?: boolean } +const DEFAULT_ROWS = 10 + const DataTable = ({ data, columns, @@ -36,12 +38,14 @@ const DataTable = ({ rowClassName, cellClassName, onRowClick, - emptyMessage = "No data to display", + emptyMessage, loading = false, }: DataTableProps) => { + const emptyRowsToFill = DEFAULT_ROWS - (data?.length || 0) + if (loading) { return ( -
+
@@ -60,11 +64,11 @@ const DataTable = ({ - {Array.from({ length: 5 }).map((_, rowIndex) => ( + {Array.from({ length: DEFAULT_ROWS }).map((_, rowIndex) => ( {columns.map((_, colIndex) => ( - + ))} @@ -75,8 +79,18 @@ const DataTable = ({ ) } + if (!data.length && emptyMessage) { + return emptyMessage + } + if (!data.length) { - return
{emptyMessage}
+ return ( +
+
+
No data to display
+
+
+ ) } return ( @@ -128,6 +142,14 @@ const DataTable = ({ ))} ))} + {emptyRowsToFill > 0 && + Array.from({ length: emptyRowsToFill }).map((_, idx) => ( + + {columns.map((_, colIndex) => ( +   + ))} + + ))}
diff --git a/apps/admin-panel/components/paginated-table/index.tsx b/apps/admin-panel/components/paginated-table/index.tsx index a409e2405..2d66fbd2a 100644 --- a/apps/admin-panel/components/paginated-table/index.tsx +++ b/apps/admin-panel/components/paginated-table/index.tsx @@ -61,7 +61,7 @@ const PaginatedTable = ({ columns, loading, data, - pageSize, + pageSize = DEFAULT_PAGESIZE, fetchMore, onSort, onFilter, @@ -113,13 +113,21 @@ const PaginatedTable = ({ } } + const emptyRowsToFill = pageSize - (displayData?.length || 0) + if (data?.edges.length === 0 && Object.keys(filterState).length === 0) { - return
No data to display
+ return ( +
+
+
No data to display
+
+
+ ) } return ( <> -
+
{showHeader && ( @@ -184,20 +192,19 @@ const PaginatedTable = ({ )} - {loading - ? // Render loading skeleton rows while keeping headers visible - Array.from({ length: displayData.length || pageSize }).map( - (_, rowIndex) => ( - - {columns.map((_, colIndex) => ( - - - - ))} - - ), - ) - : displayData.map(({ node }, idx) => ( + {loading ? ( + Array.from({ length: pageSize }).map((_, rowIndex) => ( + + {columns.map((_, colIndex) => ( + + + + ))} + + )) + ) : ( + <> + {displayData.map(({ node }, idx) => ( onClick?.(node)} @@ -215,6 +222,16 @@ const PaginatedTable = ({ ))} ))} + {emptyRowsToFill > 0 && + Array.from({ length: emptyRowsToFill }).map((_, idx) => ( + + {columns.map((_, colIndex) => ( +   + ))} + + ))} + + )}