Skip to content

Commit b6d98ca

Browse files
authored
fix: remove font-awesome cdn, round the average to two decimal points (#381)
1 parent f99bec3 commit b6d98ca

File tree

2 files changed

+1
-42
lines changed

2 files changed

+1
-42
lines changed

Diff for: index.html

-3
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,6 @@
4141
rel="stylesheet"
4242
/>
4343

44-
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.1/css/all.min.css"
45-
integrity="sha512-MV7K8+y+gLIBoVD59lQIYicR65iaqukzvf/nwasF0nqhPay5w/9lJmVM2hMDcnK1OnMGCdVK+iQrJ7lzPJQd1w=="
46-
crossorigin="anonymous" referårerpolicy="no-referrer" />
4744
</head>
4845
<body class="dark:bg-dark-frame-bg">
4946
<div id="tree"></div>

Diff for: src/components/TraineePerformance.tsx

+1-39
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ import React, { useContext, useEffect, useState } from 'react';
22
import { useTranslation } from 'react-i18next';
33
import { useLazyQuery, gql, useQuery } from '@apollo/client';
44
import { toast } from 'react-toastify';
5-
import * as FileSaver from 'file-saver';
6-
import XLSX from 'sheetjs-style';
75
import Pagination from './Pagination';
86
import PerformanceData from '../dummyData/performance.json';
97
import { TRAINEE_RATING } from '../Mutations/Ratings';
@@ -62,41 +60,9 @@ export const GET_RATINGS_DATA = gql`
6260
}
6361
`;
6462

65-
export function ExportToExcel({
66-
Data,
67-
fileName,
68-
}: {
69-
Data: (string | number)[];
70-
fileName: string;
71-
}) {
72-
const { t } = useTranslation();
73-
const fileType =
74-
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8';
75-
const fileExtension = '.xlsx';
76-
// eslint-disable-next-line no-nested-ternary
77-
const exportToCSV = (Data: (string | number)[], fileName: string) => {
78-
const ws = XLSX.utils.json_to_sheet(Data);
79-
const wb = { Sheets: { data: ws }, SheetNames: ['data'] };
80-
// eslint-disable-next-line no-nested-ternary
81-
const excelBuffer = XLSX.write(wb, { bookType: 'xlsx', type: 'array' });
82-
const data = new Blob([excelBuffer], { type: fileType });
83-
(FileSaver as any).saveAs(data, fileName + fileExtension);
84-
};
85-
86-
return (
87-
<button
88-
className="btn primary sm px-4 py-1 text-sm"
89-
type="button"
90-
onClick={(e) => exportToCSV(Data, fileName)}
91-
>
92-
{t('Export')}
93-
</button>
94-
);
95-
}
9663

9764
function TraineePerfomance() {
9865
const [usedata, setUserdata] = React.useState([]);
99-
const fileName = 'userInfo';
10066
const { data } = useQuery(GET_RATINGS_DATA, {});
10167
const { user } = useContext(UserContext);
10268
const [row, setRow] = useState<rowsType>({
@@ -268,7 +234,7 @@ function TraineePerfomance() {
268234
</td>
269235
<td className="px-5 py-5 border-b border-gray-200 bg-white dark:bg-dark-bg text-sm">
270236
<p className="text-gray-900 dark:text-white whitespace-no-wrap text-center">
271-
{item.average}
237+
{item.average %1 === 0? item.average: Number(item.average).toFixed(2)}
272238
</p>
273239
</td>
274240

@@ -287,10 +253,6 @@ function TraineePerfomance() {
287253
>
288254
{t('Details')}
289255
</Button>
290-
<ExportToExcel
291-
Data={usedata}
292-
fileName={fileName}
293-
/>
294256
</td>
295257
</tr>
296258
),

0 commit comments

Comments
 (0)