@@ -2,8 +2,6 @@ import React, { useContext, useEffect, useState } from 'react';
2
2
import { useTranslation } from 'react-i18next' ;
3
3
import { useLazyQuery , gql , useQuery } from '@apollo/client' ;
4
4
import { toast } from 'react-toastify' ;
5
- import * as FileSaver from 'file-saver' ;
6
- import XLSX from 'sheetjs-style' ;
7
5
import Pagination from './Pagination' ;
8
6
import PerformanceData from '../dummyData/performance.json' ;
9
7
import { TRAINEE_RATING } from '../Mutations/Ratings' ;
@@ -62,41 +60,9 @@ export const GET_RATINGS_DATA = gql`
62
60
}
63
61
` ;
64
62
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
- }
96
63
97
64
function TraineePerfomance ( ) {
98
65
const [ usedata , setUserdata ] = React . useState ( [ ] ) ;
99
- const fileName = 'userInfo' ;
100
66
const { data } = useQuery ( GET_RATINGS_DATA , { } ) ;
101
67
const { user } = useContext ( UserContext ) ;
102
68
const [ row , setRow ] = useState < rowsType > ( {
@@ -268,7 +234,7 @@ function TraineePerfomance() {
268
234
</ td >
269
235
< td className = "px-5 py-5 border-b border-gray-200 bg-white dark:bg-dark-bg text-sm" >
270
236
< 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 ) }
272
238
</ p >
273
239
</ td >
274
240
@@ -287,10 +253,6 @@ function TraineePerfomance() {
287
253
>
288
254
{ t ( 'Details' ) }
289
255
</ Button >
290
- < ExportToExcel
291
- Data = { usedata }
292
- fileName = { fileName }
293
- />
294
256
</ td >
295
257
</ tr >
296
258
) ,
0 commit comments