diff --git a/package-lock.json b/package-lock.json index 828a54c4e..f51c20644 100644 --- a/package-lock.json +++ b/package-lock.json @@ -23568,4 +23568,4 @@ } } } -} \ No newline at end of file +} diff --git a/src/Skeletons/SkeletonTable.tsx b/src/Skeletons/SkeletonTable.tsx new file mode 100644 index 000000000..b70e24b96 --- /dev/null +++ b/src/Skeletons/SkeletonTable.tsx @@ -0,0 +1,36 @@ +/* eslint-disable react/no-array-index-key */ +/* eslint-disable react/prop-types */ +import React from 'react'; + +interface SkeletonTableProps { + columns: Array; +} + +function SkeletonTable({ columns }: SkeletonTableProps) { + return ( + + + + {columns.map((column: any, index: React.Key | null | undefined) => ( + + ))} + + + + {[...Array(5)].map((_, rowIndex) => ( + + {columns.map((_, colIndex) => ( + + ))} + + ))} + +
+
+
+
+
+ ); +} + +export default SkeletonTable; \ No newline at end of file diff --git a/src/components/CoordinatorCard.tsx b/src/components/CoordinatorCard.tsx index 3eb33e30c..1d120123d 100644 --- a/src/components/CoordinatorCard.tsx +++ b/src/components/CoordinatorCard.tsx @@ -26,8 +26,14 @@ export const GET_TEAMS_CARDS = gql` professional_Skills } members { + id profile { name + lastName + firstName + } + status{ + status } } active @@ -141,6 +147,13 @@ function ManagerCard() { rating = 'text-red-700'; } + const activeMembers = team.members.filter( + (member: any) => member.status?.status === 'active' + ).length; + const droppedMembers = team.members.filter( + (member: any) => member.status?.status === 'drop' + ).length; + return { stylebg, stylebg1, @@ -159,8 +172,8 @@ function ManagerCard() { skills, Qty, Qnty, - active: team?.members.length, - drop: 0, + active: activeMembers, + drop: droppedMembers, }; }); @@ -168,7 +181,7 @@ function ManagerCard() {
{loading ? (
-
+
) : (
@@ -184,4 +197,4 @@ function ManagerCard() { ); } -export default ManagerCard; +export default ManagerCard; \ No newline at end of file diff --git a/src/components/InvitationTable.tsx b/src/components/InvitationTable.tsx index ad0b5a660..05c693fdf 100644 --- a/src/components/InvitationTable.tsx +++ b/src/components/InvitationTable.tsx @@ -1,13 +1,10 @@ // @ts-nocheck -import React, { useState,useEffect, useMemo } from 'react'; +import React, { useState, useEffect, useMemo } from 'react'; import { useTranslation } from 'react-i18next'; -import { - useGlobalFilter, - usePagination, - useSortBy, - useTable, -} from 'react-table'; +import { useGlobalFilter, usePagination, useSortBy, useTable } from 'react-table'; +import { toast } from 'react-toastify'; import DataPagination from './DataPagination'; +import SkeletonTable from '../Skeletons/SkeletonTable'; interface TableData { data: any[]; @@ -31,7 +28,7 @@ function DataTableStats({ data, columns, error, loading }: TableData) { { data: memoizedData, columns: memoizedColumns, - initialState: {pageIndex, pageSize: 3, globalFilter: filterInput }, + initialState: { pageIndex, pageSize: 3, globalFilter: filterInput }, }, useGlobalFilter, useSortBy, @@ -55,10 +52,17 @@ function DataTableStats({ data, columns, error, loading }: TableData) { prepareRow, state: { pageIndex: currentPageIndex, pageSize }, } = tableInstance; - + useEffect(() => { setPageIndex(currentPageIndex); }, [currentPageIndex]); + + useEffect(() => { + if (error) { + toast.error('Network error. Please, try again later.'); + } + }, [error]); + const handleFilterChange = (e) => { const value = e.target.value || ''; setGlobalFilter(value); @@ -69,96 +73,77 @@ function DataTableStats({ data, columns, error, loading }: TableData) {
- - - {headerGroups.map((headerGroup) => ( - - {headerGroup.headers.map((column) => ( - - ))} - - ))} - - - {!loading && memoizedData.length === 0 ? ( - - - - ) : ( - page.map((row) => { - prepareRow(row); - return ( - + ) : ( +
- {column.render('Header')} -
-  {' '} - {/* Non-breaking space to ensure it's not an empty tag */} -
+ + {headerGroups.map((headerGroup) => ( + + {headerGroup.headers.map((column) => ( + + ))} + + ))} + + + {memoizedData.length === 0 && ( + + - ))} - - ); - }) - )} - {loading && ( - - - - )} - {error && ( - - - - )} - {!loading && !error && data.length === 0 && ( - - {' '} - {' '} - - )} - -
+ {column.render('Header')} +
- {row.cells.map((cell) => ( - - {cell.render('Cell')} -
- Loading... -
- Error occurred -
-
- {' '} -

- {' '} - No records available{' '} -

-
{' '} -
+  {' '} + {/* Non-breaking space to ensure it's not an empty tag */} + + + )} + {memoizedData.length > 0 && + page.map((row) => { + prepareRow(row); + return ( + + {row.cells.map((cell) => ( + + {cell.render('Cell')} + + ))} + + ); + })} + {!loading && !error && data.length === 0 && ( + + +
+

+ No records available +

+
+ + + )} + + + )}
member.status?.status === 'active' + ).length; + const droppedMembers = team.members.filter( + (member: any) => member.status?.status === 'drop' + ).length; return { stylebg, @@ -155,8 +164,8 @@ function ManagerCard() { skills, Qty, Qnty, - active: team?.members.length, - drop: 0, + active: activeMembers, + drop: droppedMembers, }; }); @@ -180,4 +189,4 @@ function ManagerCard() { ); } -export default ManagerCard; +export default ManagerCard; \ No newline at end of file diff --git a/src/components/Notification.tsx b/src/components/Notification.tsx index 90e523a0d..586f4dae9 100644 --- a/src/components/Notification.tsx +++ b/src/components/Notification.tsx @@ -191,7 +191,7 @@ function Notification({ if (user.role === 'admin') { navigate('/teams'); } else { - navigate('/cards'); + navigate('/teams/cards'); } } else if (notification.type === 'cohort') { navigate('/cohorts'); diff --git a/src/components/Sidebar.tsx b/src/components/Sidebar.tsx index 52937216f..529fe1066 100644 --- a/src/components/Sidebar.tsx +++ b/src/components/Sidebar.tsx @@ -133,7 +133,7 @@ function Sidebar({ style, toggle }: { style: string; toggle: () => void }) { {/* FOR COORDINATORS */} {/* team cards */} - + @@ -196,4 +196,4 @@ function Sidebar({ style, toggle }: { style: string; toggle: () => void }) { ); } -export default Sidebar; +export default Sidebar; \ No newline at end of file diff --git a/src/components/TeamCard.tsx b/src/components/TeamCard.tsx index 7319233b1..0638754dd 100644 --- a/src/components/TeamCard.tsx +++ b/src/components/TeamCard.tsx @@ -95,7 +95,7 @@ function Card({

- {t('Week')} {week} {t('in')} {phase} + {t('Sprint')} {week} {t('in')} {phase}

@@ -154,4 +154,4 @@ function Card({ ); } -export default Card; +export default Card; \ No newline at end of file diff --git a/src/containers/DashRoutes.tsx b/src/containers/DashRoutes.tsx index 428f0ee11..67ce21213 100644 --- a/src/containers/DashRoutes.tsx +++ b/src/containers/DashRoutes.tsx @@ -126,7 +126,7 @@ function DashRoutes() { } /> } /> {/* } /> */} - } /> + } /> } /> } /> } /> @@ -161,7 +161,7 @@ function DashRoutes() { } /> } /> - } /> + } /> } /> {/* */} diff --git a/tsconfig.json b/tsconfig.json index fd689d1be..69f64a72d 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -22,6 +22,6 @@ "src/tests/About.test.tsx", "src/components/TraineeDashboardChart.tsx", "src/pages/TraineeRatingDashboard.tsx" - ], +, "src/constants/SkeletonTable.tsx" ], "exclude": ["node_modules"] }