File tree Expand file tree Collapse file tree 1 file changed +10
-9
lines changed Expand file tree Collapse file tree 1 file changed +10
-9
lines changed Original file line number Diff line number Diff line change @@ -226,16 +226,16 @@ const Table = () => {
226226 Filter : SelectCheckedColumnFilter ,
227227 } ,
228228 {
229- Header : ( ) => {
229+ /* eslint-disable react/prop-types */
230+ Header : ( { filteredRows } ) => {
231+ const disableRandomQuestionButton = filteredRows . length === 0 ;
232+
230233 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+
239239 window . open (
240240 `https://leetcode.com/problems/${ questionSlug } /` ,
241241 '_blank' ,
@@ -269,6 +269,7 @@ const Table = () => {
269269 >
270270 Questions{ ' ' }
271271 < Button
272+ disabled = { disableRandomQuestionButton }
272273 onClick = { randomQuestion }
273274 color = "dark"
274275 id = "random-question-button"
You can’t perform that action at this time.
0 commit comments