diff --git a/frontend/src/pages/Flashcards.jsx b/frontend/src/pages/Flashcards.jsx new file mode 100644 index 0000000..cde6c8d --- /dev/null +++ b/frontend/src/pages/Flashcards.jsx @@ -0,0 +1,39 @@ +import {useState} from 'react' +import {Link, useLocation} from 'react-router-dom' + +function Flashcards(){ + const location =useLocation() + const savedWords = location.state?.savedWords || [] + const sourceLanguage = location.state?.sourceLanguage + const [currentIndex, setCurrentIndex] = useState(0) + const [isFlipped, setIsFlipped] = useState(false) + + + if(savedWords.length === 0){ + return ( +
+

No saved words yet

+

+ Save words during a lesson before starting flashcard review. +

+ + Choose a song + +
+ ) + } + const currentWord = savedWords[currentIndex] + function handleNext(){ + setCurrentIndex((previousIndex - 1) => + previousIndex === savedWords.length - 1 ? 0: previousIndex + 1 + ) + setIsFlipped(false) + } + function handlePrevious(){ + setCurrentIndex((previousIndex) => + previousIndex === 0 ? savedWords.length - 1 : previousIndex - 1 + ) + setIsFlipped(false) + } + +} \ No newline at end of file