From 8b82a2664d6e5adc4fc1d30f788a73d6fdb038b9 Mon Sep 17 00:00:00 2001 From: idsulik <3595194+idsulik@users.noreply.github.com> Date: Sat, 2 Dec 2023 16:52:01 +0200 Subject: [PATCH 001/106] Fixed randomQuestions - now it uses filtered questions (#295) --- src/components/Table/index.js | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/components/Table/index.js b/src/components/Table/index.js index 9679a24f..537e5c8d 100644 --- a/src/components/Table/index.js +++ b/src/components/Table/index.js @@ -226,16 +226,16 @@ const Table = () => { Filter: SelectCheckedColumnFilter, }, { - Header: () => { + /* eslint-disable react/prop-types */ + Header: ({ filteredRows }) => { + const disableRandomQuestionButton = filteredRows.length === 0; + const randomQuestion = () => { - const filteredByCheckboxQuestions = filteredByCheckbox(); - const filteredQuestions = filteredByCheckboxQuestions.length - ? filteredByCheckboxQuestions - : questions; - const random = Math.floor( - Math.random() * filteredQuestions.length, - ); - const questionSlug = filteredQuestions[random].slug; + const random = Math.floor(Math.random() * filteredRows.length); + const randomFilteredRow = filteredRows[random]; + const questionSlug = randomFilteredRow.original.slug; + /* eslint-enable react/prop-types */ + window.open( `https://leetcode.com/problems/${questionSlug}/`, '_blank', @@ -269,6 +269,7 @@ const Table = () => { > Questions{' '}