@@ -5,7 +5,6 @@ import { toast } from 'react-toastify';
5
5
import Pagination from './Pagination' ;
6
6
import PerformanceData from '../dummyData/performance.json' ;
7
7
import { TRAINEE_RATING } from '../Mutations/Ratings' ;
8
- import Button from './Buttons' ;
9
8
import RemarksModal from '../pages/ratings/CoordinatorRemarks' ;
10
9
import { UserContext } from '../hook/useAuth' ;
11
10
import { rowsType } from '../pages/ratings/frame' ;
@@ -63,7 +62,7 @@ export const GET_RATINGS_DATA = gql`
63
62
` ;
64
63
65
64
function TraineePerfomance ( ) {
66
- const [ usedata , setUserdata ] = React . useState ( [ ] ) ;
65
+ const [ usedata , setUserdata ] = useState ( [ ] ) ;
67
66
const { data, loading, error } = useQuery ( GET_RATINGS_DATA , { } ) ;
68
67
const { user } = useContext ( UserContext ) ;
69
68
const [ row , setRow ] = useState < rowsType > ( {
@@ -121,14 +120,11 @@ function TraineePerfomance() {
121
120
useEffect ( ( ) => {
122
121
getRatings ( {
123
122
fetchPolicy : 'network-only' ,
124
- onCompleted : /* istanbul ignore next */ ( data ) => {
125
- /* istanbul ignore next */
123
+ onCompleted : ( data ) => {
126
124
setRatings ( data ?. fetchRatingsTrainee ) ;
127
- /* istanbul ignore next */
128
125
sessionStorage . removeItem ( 'data' ) ;
129
126
} ,
130
- onError : /* istanbul ignore next */ ( error ) => {
131
- /* istanbul ignore next */
127
+ onError : ( error ) => {
132
128
toast . error ( error ?. message || 'Something went wrong' ) ;
133
129
} ,
134
130
} ) ;
@@ -152,6 +148,7 @@ function TraineePerfomance() {
152
148
const closeFeeds = ( ) => {
153
149
setToggle ( false ) ;
154
150
} ;
151
+
155
152
if ( loading ) {
156
153
return (
157
154
< >
@@ -171,6 +168,7 @@ function TraineePerfomance() {
171
168
</ >
172
169
) ;
173
170
}
171
+
174
172
if ( ratings ?. length === 0 ) {
175
173
return (
176
174
< >
@@ -240,14 +238,10 @@ function TraineePerfomance() {
240
238
< th className = "px-5 py-3 border-b-2 border-gray-200 bg-gray-100 dark:bg-neutral-600 text-center text-xs font-semibold text-gray-600 dark:text-white uppercase tracking-wider" >
241
239
{ t ( 'Average' ) }
242
240
</ th >
243
- < th className = "px-5 py-3 border-b-2 border-gray-200 bg-gray-100 dark:bg-neutral-600 text-center text-xs font-semibold text-gray-600 dark:text-white uppercase tracking-wider" >
244
- { t ( 'Actions' ) }
245
- </ th >
246
241
</ tr >
247
- { ratings ?. slice ( firstContentIndex , lastContentIndex ) . map (
248
- /* istanbul ignore next */
249
- ( item : any ) => (
250
- /* istanbul ignore next */
242
+ { ratings
243
+ ?. slice ( firstContentIndex , lastContentIndex )
244
+ . map ( ( item : any ) => (
251
245
< tr key = { item . sprint } >
252
246
< td className = "px-5 py-5 border-b border-gray-200 bg-white dark:bg-dark-bg text-sm" >
253
247
< div className = "flex justify-center items-center" >
@@ -280,29 +274,13 @@ function TraineePerfomance() {
280
274
</ td >
281
275
< td className = "px-5 py-5 border-b border-gray-200 bg-white dark:bg-dark-bg text-sm" >
282
276
< p className = "text-gray-900 dark:text-white whitespace-no-wrap text-center" >
283
- { item . average % 1 === 0 ? item . average : Number ( item . average ) . toFixed ( 2 ) }
277
+ { item . average % 1 === 0
278
+ ? item . average
279
+ : Number ( item . average ) . toFixed ( 2 ) }
284
280
</ p >
285
281
</ td >
286
-
287
- < td className = "px-0 py-5 border-b border-gray-200 bg-white dark:bg-dark-bg text-sm" >
288
- < Button
289
- variant = "primary"
290
- size = "sm"
291
- style = "px-4 py-1 text-sm"
292
- onClick = {
293
- /* istanbul ignore next */
294
- ( ) => {
295
- /* istanbul ignore next */
296
- openFeed ( item ) ;
297
- }
298
- }
299
- >
300
- { t ( 'Details' ) }
301
- </ Button >
302
- </ td >
303
282
</ tr >
304
- ) ,
305
- ) }
283
+ ) ) }
306
284
</ tbody >
307
285
</ table >
308
286
</ div >
@@ -314,50 +292,52 @@ function TraineePerfomance() {
314
292
onClick = { prevPage }
315
293
data-testid = "prev"
316
294
type = "button"
317
- className = { `page flex text-white h-12 w-12 items-center justify-center border-solid cursor-pointer bg-transparent ${ page === 1 && 'disabled'
318
- } `}
295
+ className = { `page flex text-white h-12 w-12 items-center justify-center border-solid cursor-pointer bg-transparent ${
296
+ page === 1 && 'disabled'
297
+ } `}
319
298
>
320
299
←
321
300
</ button >
322
301
< button
323
302
onClick = { ( ) => setPage ( 1 ) }
324
303
data-testid = "page1"
325
304
type = "button"
326
- className = { `page flex text-white h-12 w-12 items-center justify-center border-solid cursor-pointer bg-transparent ${ page === 1 && 'disabled'
327
- } `}
305
+ className = { `page flex text-white h-12 w-12 items-center justify-center border-solid cursor-pointer bg-transparent ${
306
+ page === 1 && 'disabled'
307
+ } `}
328
308
>
329
309
1
330
310
</ button >
331
- { /* @ts -ignore */ }
332
- { gaps . paginationGroup . map (
333
- /* istanbul ignore next */ ( el ) => (
334
- < button
335
- onClick = { /* istanbul ignore next */ ( ) => setPage ( el ) }
336
- data-testid = "page"
337
- key = { el }
338
- type = "button"
339
- className = { `page flex text-white h-12 w-12 items-center justify-center border-solid cursor-pointer bg-transparent ${ page === el ? 'active' : ''
340
- } `}
341
- >
342
- { el }
343
- </ button >
344
- ) ,
345
- ) }
311
+ { gaps . paginationGroup . map ( ( el ) => (
312
+ < button
313
+ onClick = { ( ) => setPage ( el ) }
314
+ data-testid = "page"
315
+ key = { el }
316
+ type = "button"
317
+ className = { `page flex text-white h-12 w-12 items-center justify-center border-solid cursor-pointer bg-transparent ${
318
+ page === el ? 'active' : ''
319
+ } `}
320
+ >
321
+ { el }
322
+ </ button >
323
+ ) ) }
346
324
< button
347
325
onClick = { ( ) => setPage ( totalPages ) }
348
326
data-testid = "page3"
349
327
type = "button"
350
- className = { `page flex text-white h-12 w-12 items-center justify-center border-solid cursor-pointer bg-transparent ${ page === totalPages && 'disabled'
351
- } `}
328
+ className = { `page flex text-white h-12 w-12 items-center justify-center border-solid cursor-pointer bg-transparent ${
329
+ page === totalPages && 'disabled'
330
+ } `}
352
331
>
353
332
{ totalPages }
354
333
</ button >
355
334
< button
356
335
onClick = { nextPage }
357
336
data-testid = "next"
358
337
type = "button"
359
- className = { `page flex text-white h-12 w-12 items-center justify-center border-solid cursor-pointer bg-transparent ${ page === totalPages && 'disabled'
360
- } `}
338
+ className = { `page flex text-white h-12 w-12 items-center justify-center border-solid cursor-pointer bg-transparent ${
339
+ page === totalPages && 'disabled'
340
+ } `}
361
341
>
362
342
→
363
343
</ button >
0 commit comments