diff --git a/src/client/components/Library/Library.tsx b/src/client/components/Library/Library.tsx index d620f39..924f8d8 100644 --- a/src/client/components/Library/Library.tsx +++ b/src/client/components/Library/Library.tsx @@ -66,28 +66,28 @@ export const Library = (data: IComicBookLibraryProps): ReactElement => { return !value ? Wanted : null; }; - const columns = useMemo( - () => [ + const columns = [ { - Header: "Comic Metadata", + header: "Comic Metadata", + footer: 1, columns: [ { - Header: "File Details", + header: "File Details", id: "fileDetails", minWidth: 400, - accessor: "_source", - Cell: ({ value }) => { - return ; + accessorKey: "_source", + cell: info => { + return ; }, }, { - Header: "ComicInfo.xml", - accessor: "_source.sourcedMetadata.comicInfo", + header: "ComicInfo.xml", + accessorKey: "_source.sourcedMetadata.comicInfo", align: "center", minWidth: 250, - Cell: ({ value }) => - !isEmpty(value) ? ( - + cell: info => + !isEmpty(info.getValue()) ? ( + ) : ( No ComicInfo.xml ), @@ -95,34 +95,33 @@ export const Library = (data: IComicBookLibraryProps): ReactElement => { ], }, { - Header: "Additional Metadata", + header: "Additional Metadata", columns: [ { - Header: "Publisher", - accessor: + header: "Publisher", + accessorKey: "_source.sourcedMetadata.comicvine.volumeInformation.publisher", - Cell(props) { + cell: info => { return ( - !isNil(props.cell.value) && ( + !isNil(info.getValue()) && (
- {props.cell.value.name} + {info.getValue().rawFileDetails.name}
) ); }, }, { - Header: "Something", - accessor: "_source.acquisition.source.wanted", - Cell: (props) => { - return ; + header: "Something", + accessorKey: "_source.acquisition.source.wanted", + cell: info => { + !isUndefined(info.getValue()) ? + : "Nothing"; }, }, ], - }, - ], - [], - ); + } + ] // ImportStatus.propTypes = { // value: PropTypes.bool.isRequired, diff --git a/src/client/components/shared/T2Table.tsx b/src/client/components/shared/T2Table.tsx index ad8087f..5cefbd7 100644 --- a/src/client/components/shared/T2Table.tsx +++ b/src/client/components/shared/T2Table.tsx @@ -1,6 +1,11 @@ import React, { ReactElement, useState } from "react"; import PropTypes from "prop-types"; -import { useTable, usePagination, useFlexLayout } from "react-table"; +import { + ColumnDef, + flexRender, + getCoreRowModel, + useReactTable, +} from "@tanstack/react-table"; export const T2Table = (tableOptions): ReactElement => { const { rowData, columns, paginationHandlers, totalPages, rowClickHandler } = @@ -9,80 +14,48 @@ export const T2Table = (tableOptions): ReactElement => { useState(false); const togglePageSizeDropdown = () => collapsePageSizeDropdown(!isPageSizeDropdownCollapsed); - const { - getTableProps, - getTableBodyProps, - headerGroups, - prepareRow, - page, - canPreviousPage, - canNextPage, - pageOptions, - pageCount, - gotoPage, - nextPage, - previousPage, - setPageSize, - state: { pageIndex, pageSize }, - } = useTable( - { - columns, + console.log(rowData); + const table = useReactTable({ data: rowData, - manualPagination: true, - initialState: { - pageIndex: 1, - pageSize: 25, - }, - pageCount: totalPages, - }, - usePagination, - // useFlexLayout, - ); + columns, + getCoreRowModel: getCoreRowModel(), + }) + return ( <> - +
- {headerGroups.map((headerGroup, idx) => ( - - {headerGroup.headers.map((column, idx) => ( + {table.getHeaderGroups().map((headerGroup, idx) => ( + + {headerGroup.headers.map((header, idx) => ( ))} ))} - - {page.map((row, idx) => { - prepareRow(row); + + {table.getRowModel().rows.map((row, idx) => { return ( rowClickHandler(row)} > - {row.cells.map((cell, idx) => { - return ( - - ); - })} + {row.getVisibleCells().map(cell => ( + + ))} ); })} @@ -90,109 +63,7 @@ export const T2Table = (tableOptions): ReactElement => {
- {column.render("Header")} + {header.isPlaceholder + ? null + : flexRender( + header.column.columnDef.header, + header.getContext() + )}
- {cell.render("Cell")} - + {flexRender(cell.column.columnDef.cell, cell.getContext())} +
{/* pagination control */} - + ); };