From fe125aa0d6aaef880313580b98368e49a0cffcfe Mon Sep 17 00:00:00 2001 From: Gloria Niyonkuru Sinseswa <85382004+GSinseswa721@users.noreply.github.com> Date: Wed, 30 Oct 2024 12:34:50 +0200 Subject: [PATCH] fix(#605):table responsiveness (#611) Co-authored-by: niyobertin --- src/components/DataTable.tsx | 53 ++++++++++++++++-------------------- src/pages/invitation.tsx | 22 +++++++-------- 2 files changed, 34 insertions(+), 41 deletions(-) diff --git a/src/components/DataTable.tsx b/src/components/DataTable.tsx index 9b7af95cd..d99c38696 100644 --- a/src/components/DataTable.tsx +++ b/src/components/DataTable.tsx @@ -55,9 +55,11 @@ function DataTable({ data, columns, title, loading, className }: TableData) { prepareRow, state: { pageIndex: currentPageIndex, pageSize }, } = tableInstance; + useEffect(() => { setPageIndex(currentPageIndex); }, [currentPageIndex]); + const handleFilterChange = (e) => { const value = e.target.value || ''; setGlobalFilter(value); @@ -66,42 +68,37 @@ function DataTable({ data, columns, title, loading, className }: TableData) { return (
-
+
-

+

{t(title)}

-
- +
+
- {headerGroups.map((headerGroup, index) => ( - - {headerGroup.headers.map((column, colIndex) => ( + {headerGroups.map((headerGroup) => ( + + {headerGroup.headers.map((column) => ( ))} @@ -112,7 +109,6 @@ function DataTable({ data, columns, title, loading, className }: TableData) { !loading && page.map((row) => { prepareRow(row); - // console.log(row.getRowProps()); return ( {row.cells.map((cell) => ( @@ -137,11 +133,8 @@ function DataTable({ data, columns, title, loading, className }: TableData) { }) ) : ( - @@ -151,7 +144,7 @@ function DataTable({ data, columns, title, loading, className }: TableData) { @@ -160,7 +153,7 @@ function DataTable({ data, columns, title, loading, className }: TableData) {
{column.render('Header')} - - {/* // {column.isSorted ? (column.isSortedDesc ? ' ▼' : ' ▲') : ''} */} -
{cell.render('Cell')}
-

+

+

No records available

Loading...
-
+
{ if (isSearching && searchData?.getInvitations) { invitation = searchData.getInvitations.invitations.find( - (inv) => inv.id === selectedInvitationId + (inv: { id: string; }) => inv.id === selectedInvitationId ); } else if (isFiltering && filterData?.filterInvitations) { invitation = filterData.filterInvitations.invitations.find( - (inv) => inv.id === selectedInvitationId + (inv: { id: string; }) => inv.id === selectedInvitationId ); } else if (data && data.getAllInvitations) { invitation = data.getAllInvitations.invitations.find( - (inv) => inv.id === selectedInvitationId + (inv: { id: string; }) => inv.id === selectedInvitationId ); } @@ -412,20 +412,20 @@ useEffect(() => { { id: "email", header: t('email'), - accessor: (row) => row.email, - cell: (info) =>
{info.getValue()}
, + accessor: (row: { email: any; }) => row.email, + cell: (info: { getValue: () => string | number | boolean | React.ReactElement> | Iterable | React.ReactPortal | Iterable | null | undefined; }) =>
{info.getValue()}
, }, { id: "role", header: t('role'), - accessor: (row) => row.role, - cell: (info) =>
{info.getValue()}
, + accessor: (row: { role: any; }) => row.role, + cell: (info: { getValue: () => string | number | boolean | React.ReactElement> | Iterable | React.ReactPortal | Iterable | null | undefined; }) =>
{info.getValue()}
, }, { id: "Status", header: t('Status'), - accessor: (row) => row.Status, - cell: (info) =>
{info.getValue()}
, + accessor: (row: { Status: any; }) => row.Status, + cell: (info: { getValue: () => string | number | boolean | React.ReactElement> | Iterable | React.ReactPortal | Iterable | null | undefined; }) =>
{info.getValue()}
, }, { id: "Action", @@ -572,7 +572,7 @@ const currentInvitationsTotal = isSearching && searchData?.getInvitations : data?.getAllInvitations?.totalInvitations; if (currentInvitations && currentInvitations.length > 0) { - currentInvitations.forEach((invitation) => { + currentInvitations.forEach((invitation: { invitees: any[]; status: string; id: any; }) => { invitation.invitees?.forEach((invitee: any) => { let entry: any = {}; entry.email = invitee.email;