Skip to content

Conversation

@Manya1103
Copy link
Collaborator

No description provided.

Copilot AI review requested due to automatic review settings January 15, 2026 14:30
@Manya1103 Manya1103 merged commit 7f0fcc3 into production Jan 15, 2026
6 checks passed
Copy link

Copilot AI left a 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.errors array 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}$/
Copy link

Copilot AI Jan 15, 2026

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.

Suggested change
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}$/

Copilot uses AI. Check for mistakes.
} 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.')
Copy link

Copilot AI Jan 15, 2026

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.

Copilot uses AI. Check for mistakes.
Comment on lines +1 to +2

const mainDomain = "https://kuality-dev.onrender.com/";
Copy link

Copilot AI Jan 15, 2026

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.

Suggested change
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/";

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants