From 188a0f35c66a6df5953f174e44775869ec718537 Mon Sep 17 00:00:00 2001 From: aadarsh214 Date: Fri, 29 Nov 2024 23:58:54 +0530 Subject: [PATCH 1/2] nothing changed --- src/components/TestSeriesCoderpadHome.jsx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/components/TestSeriesCoderpadHome.jsx b/src/components/TestSeriesCoderpadHome.jsx index 38fdcd0..7b8d17f 100644 --- a/src/components/TestSeriesCoderpadHome.jsx +++ b/src/components/TestSeriesCoderpadHome.jsx @@ -335,8 +335,7 @@ const normalizeDifficulty = (difficulty) => { route = '/pyQuiz' } - window.open(`${route}?questionID=${quizID}&userID=${userID}`, '_blank'); - + navigateTo(`${route}?questionID=${quizID}&userID=${userID}`) } const toggleQuestionExpansion = (quizId) => { @@ -595,7 +594,7 @@ const normalizeDifficulty = (difficulty) => { onClick={() => handleStartQuiz(quiz._id, user?.id, quiz.question_text)} className="bg-teal-600 hover:bg-teal-700 text-white mt-2 md:mt-0 px-6 py-2 rounded" > - Solve + Start Quiz From e37e8c022de82e72514f9b805a61e94fb40591a7 Mon Sep 17 00:00:00 2001 From: aadarsh214 Date: Sat, 30 Nov 2024 01:32:18 +0530 Subject: [PATCH 2/2] fixed the full layout --- src/components/TestSeriesCoderpadHome.jsx | 606 +++++++++++----------- 1 file changed, 297 insertions(+), 309 deletions(-) diff --git a/src/components/TestSeriesCoderpadHome.jsx b/src/components/TestSeriesCoderpadHome.jsx index 7b8d17f..bfd1821 100644 --- a/src/components/TestSeriesCoderpadHome.jsx +++ b/src/components/TestSeriesCoderpadHome.jsx @@ -5,7 +5,7 @@ import axios from 'axios' import queryString from 'query-string' import { useNavigate } from 'react-router-dom' import { useUser, SignInButton, UserButton } from '@clerk/clerk-react' -import { Video, FileText, ChevronDown, X, ArrowLeft, Search, Filter, Moon, Sun, Bookmark, BookmarkCheck, Loader2, ChevronLeft, ChevronRight } from 'lucide-react' +import { Video, FileText, ChevronDown, X, ArrowLeft, Search, Filter, Moon, Sun, Bookmark, BookmarkCheck, Loader2, ChevronLeft, ChevronRight, Star } from 'lucide-react' import ReactPlayer from 'react-player/youtube' import { Button } from "./ui/button" import { Input } from "./ui/input" @@ -35,7 +35,6 @@ import { export default function QuizApp() { const { isLoaded, isSignedIn, user } = useUser() - const navigateTo = useNavigate() const [quizzes, setQuizzes] = useState([]) const [isDarkMode, setIsDarkMode] = useState(false) @@ -43,7 +42,7 @@ export default function QuizApp() { const [selectedCompanies, setSelectedCompanies] = useState([]) const [selectedSubtopics, setSelectedSubtopics] = useState([]) const [expandedQuestions, setExpandedQuestions] = useState({}) - const [difficulties] = useState(['Easy', 'Medium', 'Hard']) + const [difficulties] = useState(['Easy', 'Medium', 'Advamce']) const [companies] = useState(['Amazon', 'Google', 'Microsoft', 'Facebook', 'Apple']) const [subtopics, setSubtopics] = useState([]) const [searchTerm, setSearchTerm] = useState('') @@ -82,8 +81,6 @@ export default function QuizApp() { useEffect(() => { if (isLoaded && isSignedIn) { setUserID(user.id) - // console.log('user id -> '+user.id) - // console.log( 'userinfo -> '+ user.emailAddress+' '+user.fullName+' '+user.id ) } }, [isLoaded, isSignedIn, user]) @@ -217,29 +214,28 @@ export default function QuizApp() { } } } -const normalizeDifficulty = (difficulty) => { - if (!difficulty) { - // Handle null, undefined, or other falsy values - return 'easy'; // Default value - } - const normalized = difficulty.toLowerCase(); - if (normalized === 'advance' || normalized === 'advanced') { - return 'hard'; - } + const normalizeDifficulty = (difficulty) => { + if (!difficulty) { + return 'easy' + } - return normalized; -}; + const normalized = difficulty.toLowerCase() + if (normalized === 'advance' || normalized === 'advanced') { + return 'advance' + } + + return normalized + } - const getDifficultyStyle = (difficulty) => { const normalizedDifficulty = normalizeDifficulty(difficulty) switch (normalizedDifficulty) { case 'easy': - return 'bg-teal-100 text-teal-800 dark:bg-teal-900 dark:text-teal-300' + return 'bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-300' case 'medium': return 'bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-300' - case 'hard': + case 'advance': case 'advance': return 'bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-300' default: @@ -347,335 +343,327 @@ const normalizeDifficulty = (difficulty) => { return question.substring(0, maxLength) + '...' } - const FilterContent = () => ( - <> - - - Search - - - updateFilters('search', e.target.value)} - className="mb-4" - /> -
- updateFilters('bookmarked', checked)} - /> - -
-
-
- - - - Difficulty - - - {['Easy', 'Medium', 'Advance'].map((difficulty) => ( -
- { - updateFilters('difficulties', checked - ? [...filters.difficulties, difficulty.toLowerCase()] - : filters.difficulties -.filter(d => d !== difficulty.toLowerCase()) - ) - }} - /> - -
- ))} -
-
- - - - Subtopics - - - - {availableSubtopics.map((subtopic) => ( -
- { - updateFilters('subtopics', checked - ? [...filters.subtopics, subtopic] - : filters.subtopics.filter(s => s !== subtopic) - ) - }} - /> - -
- ))} -
-
-
- - - - Companies - - - - {availableCompanies.map((company) => ( -
- { - updateFilters('companies', checked - ? [...filters.companies, company] - : filters.companies.filter(c => c !== company) - ) - }} - /> - -
- ))} -
-
-
- - ) - return ( -
-
+
+ {/* Header */} +
- - - Quiz App Logo -
+
+ + Quiz App Logo +
+ +
{isLoaded && isSignedIn ? ( ) : ( - - + + )}
-
+
+ {/* Sidebar */} + + + {/* Mobile Filter Button */} - - + Filters -

+ Apply filters to narrow down the questions. -

+
- +
+ {/* Mobile filters content - same as sidebar */} +
+

STATUS

+
+ + +
+
+
+

DIFFICULTY

+
+ {['Easy', 'Medium', 'advance'].map((difficulty) => ( + + ))} +
+
+
+

SUBTOPICS

+ + {availableSubtopics.map((subtopic) => ( + + ))} + +
+
+

COMPANIES

+ + {availableCompanies.map((company) => ( + + ))} + +
+
- - - - - - {isLoading ? ( -
- {[...Array(5)].map((_, index) => ( - - - -
- - -
-
- - - - - -
- ))} -
- ) : ( - <> - {quizzes.map((quiz, index) => ( - - -
-
-
- -
- + {/* Main Content */} +
+ {/* Search Bar */} +
+ updateFilters('search', e.target.value)} + className={`max-w ${isDarkMode ? 'bg-[#2f2f2f] border-[#3f3f3f]' : 'bg-white border-gray-200'}`} + /> +
+ + {/* Questions List */} + +
+ {isLoading ? ( +
+ {[...Array(5)].map((_, index) => ( + + ))} +
+ ) : ( + <> + {quizzes.map((quiz, index) => ( +
+
+
+

+ {removeQuizTypePrefix(quiz.question_text)} +

+
+ + {quiz.difficulty} + + + Max Score: {quiz.max_score || 10} + + + Success Rate: {quiz.success_rate || '90.00'}% +
-
- - {quiz.difficulty} - - {quiz.table_names && quiz.table_names.map(table => ( - {table} - ))} +
+ +
-
- - - - - Scenario - Solution - - -
- - - -
- - - - - - - Text Solution - - {quiz.query} - - - - - -
-
- - - - ))} -
- - - Page {paginationInfo.currentPage} of {paginationInfo.totalPages} - - -
- - )} - + ))} + + {/* Pagination */} +
+ + + Page {paginationInfo.currentPage} of {paginationInfo.totalPages} + + +
+ + )} +
+ +
+ {/* Video Solution Dialog */}