Fix/replace alert with toast notepage - #935
Open
thatperplextion wants to merge 5 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR replaces some blocking alert(...) error notifications with a reusable Toast UI in key client pages, and adds/updates JSDoc comments for several shared utilities to improve clarity and editor tooling.
Changes:
- Replaced
alert(...)usage with aToastcomponent inHomePage,ProductPage, andNotesPage. - Removed verbose client-side debug logging from
ExercisePage. - Added JSDoc documentation to several utility modules (
rewardsUtils,normalizeProduct,getAuthHeaders,formatters).
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| client/src/utils/rewardsUtils.js | Adds JSDoc documentation for reward-tier and formatting helpers. |
| client/src/utils/normalizeProduct.js | Adds JSDoc describing product ID normalization behavior. |
| client/src/utils/getAuthHeaders.js | Replaces old header comments with richer JSDoc for auth header generation. |
| client/src/utils/formatters.js | Adds JSDoc for INR currency formatter helper. |
| client/src/pages/ProductPage.jsx | Replaces multiple alert(...) error paths with Toast notifications. |
| client/src/pages/NotesPage.jsx | Replaces “empty title” alert(...) with Toast notification. |
| client/src/pages/HomePage.jsx | Replaces cart-operation alert(...) errors with Toast notifications. |
| client/src/pages/ExercisePage.jsx | Removes client-side debug logs/warns (but still contains an alert(...) in notes flow). |
Suppressed comments (1)
client/src/pages/ExercisePage.jsx:66
- This PR’s goal is to replace
alert(...)with the Toast UI, but ExercisePage still usesalert("No date selected...")inhandleExerciseSelect(line ~74). This leaves an inconsistent UX and likely misses the intended replacement for the notes flow.
setExercises(data || []);
} catch (err) {
setError(err.message || "Failed to load exercises. Please try again.");
console.error("Exercise fetch error:", err);
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+5
to
+10
| /** | ||
| * Returns authentication headers for API requests. | ||
| * In development mode, prefers a local dev token if present. | ||
| * Otherwise, uses Firebase authentication token if user is logged in. | ||
| * @returns {Promise<{Content-Type: string, Authorization?: string}>} Headers object with optional Bearer token | ||
| */ |
Comment on lines
+147
to
+148
| setToast({ message: err.message || 'Failed to add to cart', type: 'error', visible: true }); | ||
| setTimeout(() => setToast(prev => ({ ...prev, visible: false })), 3000); |
Comment on lines
+283
to
+284
| setToast({ message: err.message || 'Failed to add to cart', type: 'error', visible: true }); | ||
| setTimeout(() => setToast(prev => ({ ...prev, visible: false })), 3000); |
Comment on lines
+46
to
+47
| setToast({ message: 'Please enter a workout title.', type: 'error', visible: true }); | ||
| setTimeout(() => setToast(prev => ({ ...prev, visible: false })), 3000); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📋 What does this PR do?
A clear summary of the changes made.
🔗 Related Issue
Closes #
🧪 How was this tested?
Describe how you tested your changes (manual steps, screenshots, etc.)
📸 Screenshots (if UI changes)
Before / After screenshots if you changed any UI.
✅ Checklist