-
-
Notifications
You must be signed in to change notification settings - Fork 0
Development #48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Development #48
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request updates error handling for API responses and strengthens password validation in the registration form. The changes standardize how error messages are extracted from API error responses across multiple components and enhance password security requirements.
Changes:
- Standardized error handling across 6 components to extract error messages from
err.response.data.errorsarray structure - Enhanced password validation regex to require 10-64 characters with at least one special character (any non-alphanumeric)
- Improved email validation regex to require minimum 2-character TLD
- Updated configuration to point to development domain
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/views/uiManagement/leads/Leads.js | Updated error handling to extract messages from errors array |
| src/views/uiManagement/categories/Categories.js | Updated error handling to extract messages from errors array |
| src/views/uiManagement/carousel/Carousel.js | Updated error handling to extract messages from errors array |
| src/views/pages/register/Register.js | Enhanced password and email validation patterns, added commented-out validator library integration |
| src/views/management/returnsAndRefunds/ReturnsAndRefunds.js | Updated error handling to extract messages from errors array |
| src/views/management/orders/Orders.js | Updated error handling to extract messages from errors array |
| src/views/management/allSellers/AllSellers.js | Updated error handling to extract messages from errors array |
| src/config/Config.js | Changed mainDomain to development environment URL |
Comments suppressed due to low confidence (2)
src/views/pages/register/Register.js:61
- The password strength calculation checks for length >= 8, but the new password format requires 10 characters minimum. This should be updated to
if (formData.password.length >= 10)to align with the updated password requirements. Additionally, the special character check on line 65 uses/[@$!%*?&]/which is more restrictive than the new regex pattern[^A-Za-z0-9]that accepts any non-alphanumeric character. Consider updating to/[^A-Za-z0-9]/for consistency.
if (formData.password.length >= 8) strength += 1
src/views/pages/register/Register.js:95
- The validation message states passwords must be at least 8 characters, but the passwordFormat regex on line 28 requires 10-64 characters. This should be updated to
if (value.length < 10) return 'Password must be at least 10 characters'and the error message on line 97 should be updated to mention the 10-64 character length requirement.
if (value.length < 8) return 'Password must be at least 8 characters'
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const emailFormat = /^[^\s@]+@[^\s@]+\.[^\s@]+$/ | ||
| const passwordFormat = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$/ | ||
| const emailFormat = /^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/i | ||
| const passwordFormat = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[^A-Za-z0-9])[\S]{10,64}$/ |
Copilot
AI
Jan 15, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The password regex uses [\S]{10,64} which allows whitespace characters at the beginning or end. Consider using [A-Za-z\d\S]{10,64} or ^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[^A-Za-z0-9]).{10,64}$ to be more explicit about what characters are allowed, since \S matches any non-whitespace including control characters.
| const passwordFormat = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[^A-Za-z0-9])[\S]{10,64}$/ | |
| const passwordFormat = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[^A-Za-z0-9])\S{10,64}$/ |
| } catch (err) { | ||
| console.error('Error fetching leads:', err) | ||
| setError(err.response?.data?.message || err.message || 'An error occurred while fetching leads.') | ||
| setError(err.response?.data?.errors && err.response.data.errors.length > 0 ? err.response.data.errors[0].message : 'An error occurred while fetching leads.') |
Copilot
AI
Jan 15, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error handling logic is duplicated across multiple files with the same verbose pattern. Consider creating a reusable helper function to extract error messages, such as getErrorMessage(err, fallback) to improve maintainability and reduce code duplication.
|
|
||
| const mainDomain = "https://kuality-dev.onrender.com/"; |
Copilot
AI
Jan 15, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The domain URL is hardcoded directly in the configuration file. For better environment management, consider using environment variables (e.g., process.env.VITE_MAIN_DOMAIN) to handle different environments (development, staging, production) without code changes.
| const mainDomain = "https://kuality-dev.onrender.com/"; | |
| const mainDomain = process.env.VITE_MAIN_DOMAIN || "https://kuality-dev.onrender.com/"; | |
| const baseUrl = process.env.VITE_BASE_URL || "https://multivendorplatform.onrender.com/"; |
No description provided.