@@ -50,11 +50,11 @@ const Table = () => {
50
50
new Array ( questions . length ) . fill ( '' ) ;
51
51
52
52
/* If the user has previously visited the website, then an array in
53
- LocalStorage would exist of a certain length which corresponds to which
54
- questions they have/have not completed. In the event that we add new questions
55
- to the list, then we would need to resize and copy the existing 'checked'
56
- array before updating it in LocalStorage in order to transfer their saved
57
- progress. */
53
+ LocalStorage would exist of a certain length which corresponds to which
54
+ questions they have/have not completed. In the event that we add new questions
55
+ to the list, then we would need to resize and copy the existing 'checked'
56
+ array before updating it in LocalStorage in order to transfer their saved
57
+ progress. */
58
58
if ( checkedList . length !== questions . length ) {
59
59
const resizedCheckedList = new Array ( questions . length ) . fill ( false ) ;
60
60
@@ -114,6 +114,15 @@ const Table = () => {
114
114
JSON . parse ( localStorage . getItem ( 'showPatterns' ) ) || new Array ( 1 ) . fill ( true ) ,
115
115
) ;
116
116
117
+ const [ important , setImportant ] = useState (
118
+ JSON . parse ( localStorage . getItem ( 'importantProblems' ) ) ||
119
+ new Array ( questions . length ) . fill ( false ) ,
120
+ ) ;
121
+
122
+ useEffect ( ( ) => {
123
+ localStorage . setItem ( 'importantProblems' , JSON . stringify ( important ) ) ;
124
+ } , [ important ] ) ;
125
+
117
126
useEffect ( ( ) => {
118
127
window . localStorage . setItem ( 'checked' , JSON . stringify ( checked ) ) ;
119
128
} , [ checked ] ) ;
@@ -171,7 +180,7 @@ const Table = () => {
171
180
totalValue = { totalDifficultyCount . Total }
172
181
label = { ( ) =>
173
182
`${ difficultyCount . Total } /
174
- ${ totalDifficultyCount . Total } `
183
+ ${ totalDifficultyCount . Total } `
175
184
}
176
185
labelPosition = { 0 }
177
186
labelStyle = { {
@@ -481,7 +490,46 @@ const Table = () => {
481
490
} ,
482
491
Filter : SelectColumnFilter ,
483
492
} ,
493
+ /* eslint-disable react/prop-types */
484
494
{
495
+ Header : '⭐' ,
496
+ accessor : 'important' ,
497
+ disableSortBy : true ,
498
+ disableFilters : true ,
499
+ Cell : ( { row } ) => {
500
+ const id = Number ( row ?. original ?. id ) ;
501
+ if ( Number . isNaN ( id ) ) return '❌' ;
502
+
503
+ const handleKeyPress = e => {
504
+ if ( e . key === 'Enter' || e . key === ' ' ) {
505
+ const updatedImportant = [ ...important ] ;
506
+ updatedImportant [ id ] = ! updatedImportant [ id ] ;
507
+ setImportant ( updatedImportant ) ;
508
+ console . log ( 'Toggled important:' , updatedImportant ) ;
509
+ }
510
+ } ;
511
+
512
+ return (
513
+ < span
514
+ role = "button"
515
+ tabIndex = { 0 }
516
+ style = { { cursor : 'pointer' , fontSize : '1.2em' } }
517
+ onClick = { ( ) => {
518
+ console . log ( 'Star clicked!' , id ) ; // add this
519
+ const updatedImportant = [ ...important ] ;
520
+ updatedImportant [ id ] = ! updatedImportant [ id ] ;
521
+ setImportant ( updatedImportant ) ;
522
+ } }
523
+ onKeyDown = { handleKeyPress }
524
+ aria-label = "Mark as important for revision"
525
+ data-tip = "Mark as important for revision"
526
+ >
527
+ { important [ id ] ? '⭐' : '☆' }
528
+ </ span >
529
+ ) ;
530
+ } ,
531
+ } , // Optional
532
+ /* eslint-enable react/prop-types */ {
485
533
Header : 'Last Solved On' ,
486
534
accessor : 'LastSolvedOn' ,
487
535
disableSortBy : true ,
0 commit comments