Skip to content

Commit

Permalink
Ft trainee dashboard (#252)
Browse files Browse the repository at this point in the history
* trainee dashboard redsign

* trainee dashboard redsign

* trainee dashboard re-design

* trainee dashboard re-design

* rebase develop

* finished trainee dashboard
  • Loading branch information
Luciefifi authored Sep 20, 2023
1 parent bca3ed2 commit 8d5cb83
Show file tree
Hide file tree
Showing 15 changed files with 19,434 additions and 76 deletions.
18,317 changes: 18,316 additions & 1 deletion package-lock.json

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion src/Mutations/Ratings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ export const ADD_RATING = gql`
email
}
sprint
phase
cohort {
name
id
Expand Down Expand Up @@ -301,6 +302,8 @@ export const TRAINEE_RATING = gql`
email
}
sprint
phase
sprint
quantity
quantityRemark
quality
Expand All @@ -309,6 +312,7 @@ export const TRAINEE_RATING = gql`
professionalRemark
average
cohort {
name
phase {
name
}
Expand Down Expand Up @@ -376,7 +380,7 @@ export const GET_ALL_TRAINEES = gql`
team {
name
cohort {
endDate
endDateb
startDate
phase {
name
Expand Down
2 changes: 1 addition & 1 deletion src/components/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -209,4 +209,4 @@ function Sidebar({ style, toggle }: { style: string; toggle: () => void }) {
);
}

export default Sidebar;
export default Sidebar;
51 changes: 51 additions & 0 deletions src/components/TraineeDashboardChart.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/* eslint-disable react/function-component-definition */
/* eslint-disable import/no-extraneous-dependencies */


import React from 'react';
import { LineChart, Line, CartesianGrid, XAxis, YAxis, Tooltip, Legend } from 'recharts';

interface TableRow {
sprint: number;
quality: number;
quantity: number;
professionalism: number;
attendance: number;
comment: string;
}

interface TraineeChartProps {
barChartData: TableRow[];
}

const TraineeChart: React.FC<TraineeChartProps> = ({ barChartData }) => {
const chartData = barChartData
.map((entry) => ({
name: entry.sprint,
Professionalism: entry.professionalism,
Quality: entry.quality,
Quantity: entry.quantity,
}))
.sort((a, b) => a.name - b.name);

const xAxisTickValues = chartData.map((entry) => entry.name);

return (
<div className='Trainee-chart'>
<LineChart width={1150} height={220} data={chartData}>
<Line type="monotone" dataKey="Professionalism" stroke="#1b5e20" strokeWidth={2} dot={false} />
<Line type="monotone" dataKey="Quality" stroke="#8667f2" strokeWidth={2} dot={false} />
<Line type="monotone" dataKey="Quantity" stroke="#b5a72a" strokeWidth={2} dot={false} />
<CartesianGrid stroke="#ccc" />
<XAxis dataKey="name" />
<YAxis />
<Tooltip />
<Legend iconType='circle' iconSize={10} />
</LineChart>
</div>
);
};

export default TraineeChart;


134 changes: 134 additions & 0 deletions src/components/TraineeTable.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@

/* eslint-disable react/button-has-type */
// @ts-nocheck
import React from 'react';
import { useTranslation } from 'react-i18next';
import {
useGlobalFilter,
usePagination,
useSortBy,
useTable,
} from 'react-table';
import Pagination from '../components/Pagination';
import DataPagination from './DataPagination';

interface TableData {
data: any[];
columns: any;
title: string;
loading?: boolean;
}

function Table({ data, columns, title, loading }: TableData) {
// const sortedData = React.useMemo(() => [...data], []);
const sortedColumns = React.useMemo(() => [...columns], [columns]);
const sortedData = data;
// const sortedColumns = columns;
const TableInstance = useTable(
{ data: sortedData, columns: sortedColumns, initialState: { pageSize: 5 } },

useGlobalFilter,
useSortBy,
usePagination,
);
const { t } = useTranslation();

const {
getTableProps,
getTableBodyProps,
page,
headerGroups,
prepareRow,
nextPage,
canPreviousPage,
previousPage,
canNextPage,
gotoPage,
pageCount,
setPageSize,
pageOptions,
state,
} = TableInstance;
// @ts-ignore
const { globalFilter, pageIndex, pageSize } = state;

return (
<div className=" shadow-lg py-6 w-[100%] mb-10 ">
<div style={{ overflowX: 'auto' }}>
<table className=" leading-3 rounded-full w-[100%]" {...getTableProps()}>
<thead>
{headerGroups.map((headerGroup) => (
<tr {...headerGroup.getHeaderGroupProps()}>
{headerGroup.headers.map((column) => (
<th
className={
column.isSorted ? 'sort-asc ' : 'bg-[#B8CDBA] p-4 '
}
{...column.getHeaderProps(column.getSortByToggleProps())}
>
{column.render('Header')}
</th>
))}
</tr>
))}
</thead>
<tbody {...getTableBodyProps()}>
{page.map((row) => {
prepareRow(row);

// eslint-disable-next-line operator-linebreak
const rowTheme =
row.index % 2 !== 0
? 'bg-[#f5f8ff] dark:bg-dark-bg'
: 'bg-white dark:bg-dark-bg';

return (
<tr className={` ${rowTheme} `} {...row.getRowProps()}>
{row.cells.map((cell) => (
<td className="border py-2 px-24" {...cell.getCellProps()}>
{cell.render('Cell')}
</td>
))}
</tr>
);
})}
{loading && (
<tr>
<td
colSpan={columns.length || 100}
style={{ textAlign: 'center' }}
>
loading...
</td>
</tr>
)}
</tbody>
</table>

<DataPagination
pageOptions={pageOptions}
canNextPage={canNextPage}
gotoPage={gotoPage}
columnLength={columns.length}
canPreviousPage={canPreviousPage}
pageSize={pageSize}
setPageSize={setPageSize}
previousPage={previousPage}
nextPage={nextPage}
pageCount={pageCount}
pageIndex={pageIndex}
/>
</div>
</div>
);
}

export default Table;








2 changes: 1 addition & 1 deletion src/components/TraineesChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,4 @@ const TraineeChart: React.FC<TraineeChartProps> = ({ barChartData }) => {
);
};

export default TraineeChart;
export default TraineeChart;
Loading

1 comment on commit 8d5cb83

@vercel
Copy link

@vercel vercel bot commented on 8d5cb83 Sep 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

metron-devpulse – ./

metron-devpulse-git-develop-metron.vercel.app
metron-devpulse.vercel.app
metron-devpulse-metron.vercel.app

Please sign in to comment.