File tree Expand file tree Collapse file tree 1 file changed +36
-2
lines changed Expand file tree Collapse file tree 1 file changed +36
-2
lines changed Original file line number Diff line number Diff line change @@ -14,7 +14,12 @@ import {
1414import Toggle from 'react-toggle' ;
1515import ReactTooltip from 'react-tooltip' ;
1616import { useTable , useFilters , useSortBy } from 'react-table' ;
17- import { FaLock , FaExternalLinkAlt , FaQuestionCircle } from 'react-icons/fa' ;
17+ import {
18+ FaLock ,
19+ FaExternalLinkAlt ,
20+ FaRandom ,
21+ FaQuestionCircle ,
22+ } from 'react-icons/fa' ;
1823import {
1924 DefaultColumnFilter ,
2025 SelectDifficultyColumnFilter ,
@@ -232,7 +237,36 @@ const Table = () => {
232237 Filter : SelectCheckedColumnFilter ,
233238 } ,
234239 {
235- Header : 'Questions' ,
240+ Header : ( ) => {
241+ const randomQuestion = ( ) => {
242+ const random = Math . floor ( Math . random ( ) * questions . length ) ;
243+ const questionId = questions [ random ] . id ;
244+ const questionSlug = questions [ questionId ] . slug ;
245+ window . open (
246+ `https://leetcode.com/problems/${ questionSlug } /` ,
247+ '_blank' ,
248+ ) ;
249+ } ;
250+ return (
251+ < >
252+ < div
253+ style = { { whiteSpace : 'nowrap' , display : 'inline-block' } }
254+ >
255+ Questions{ ' ' }
256+ < Button
257+ onClick = { randomQuestion }
258+ color = "dark"
259+ id = "random-question-button"
260+ size = "sm"
261+ >
262+ < span data-tip = "Try a random question!" >
263+ < FaRandom />
264+ </ span >
265+ </ Button >
266+ </ div >
267+ </ >
268+ ) ;
269+ } ,
236270 accessor : 'questions' ,
237271 disableSortBy : true ,
238272 Cell : cellInfo => {
You can’t perform that action at this time.
0 commit comments