Skip to content

Commit a0ca3f2

Browse files
committed
word requirement UX for regenerating flashcards
1 parent f0af903 commit a0ca3f2

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

src/pages/FlashcardsViewer.jsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@ function FlashcardsViewer() {
3737
console.log("Re fetched data:", noteData);
3838
currentContent = noteData.content;
3939
}
40+
41+
if (currentContent.trim().split(/\s+/).length < 70) {
42+
toast.error(
43+
"Notes must have at least 70 words! Refresh page to try again."
44+
);
45+
}
46+
4047
const generateFlashcards = httpsCallable(functions, "generateFlashcards");
4148
const results = await generateFlashcards({
4249
content: getPlainText(currentContent),
@@ -58,6 +65,10 @@ function FlashcardsViewer() {
5865
} catch (error) {
5966
if (error.code === "functions/resource-exhausted") {
6067
setShowNoUsages(true);
68+
} else if (error.code === "functions/invalid-argument") {
69+
toast.error(
70+
"Notes must have at least 70 words! Refresh page to try again."
71+
);
6172
} else {
6273
console.log("Error in flashcards viwer:", error);
6374
navigate("/");

0 commit comments

Comments
 (0)