File tree 1 file changed +10
-9
lines changed
1 file changed +10
-9
lines changed Original file line number Diff line number Diff line change @@ -226,16 +226,16 @@ const Table = () => {
226
226
Filter : SelectCheckedColumnFilter ,
227
227
} ,
228
228
{
229
- Header : ( ) => {
229
+ /* eslint-disable react/prop-types */
230
+ Header : ( { filteredRows } ) => {
231
+ const disableRandomQuestionButton = filteredRows . length === 0 ;
232
+
230
233
const randomQuestion = ( ) => {
231
- const filteredByCheckboxQuestions = filteredByCheckbox ( ) ;
232
- const filteredQuestions = filteredByCheckboxQuestions . length
233
- ? filteredByCheckboxQuestions
234
- : questions ;
235
- const random = Math . floor (
236
- Math . random ( ) * filteredQuestions . length ,
237
- ) ;
238
- const questionSlug = filteredQuestions [ random ] . slug ;
234
+ const random = Math . floor ( Math . random ( ) * filteredRows . length ) ;
235
+ const randomFilteredRow = filteredRows [ random ] ;
236
+ const questionSlug = randomFilteredRow . original . slug ;
237
+ /* eslint-enable react/prop-types */
238
+
239
239
window . open (
240
240
`https://leetcode.com/problems/${ questionSlug } /` ,
241
241
'_blank' ,
@@ -269,6 +269,7 @@ const Table = () => {
269
269
>
270
270
Questions{ ' ' }
271
271
< Button
272
+ disabled = { disableRandomQuestionButton }
272
273
onClick = { randomQuestion }
273
274
color = "dark"
274
275
id = "random-question-button"
You can’t perform that action at this time.
0 commit comments