Skip to content
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

Alertmessage : Alert pop up message from antd added #360 done #376

Merged
merged 5 commits into from
Oct 22, 2024

Conversation

VinayLodhi1712
Copy link
Contributor

@VinayLodhi1712 VinayLodhi1712 commented Oct 21, 2024

Alertmessage : Alert pop up message from antd added #360 done.

20241021163537.mp4

Summary by CodeRabbit

Release Notes

  • New Features

    • Enhanced user feedback in the Login and Signup components with Ant Design's messaging system for success and error notifications.
    • Detailed success and error messages now displayed with improved styling.
  • Bug Fixes

    • Corrected a typo in the error handling middleware import.
  • Dependencies

    • Updated Ant Design dependency to version 5.21.5 for improved functionality.

Copy link

vercel bot commented Oct 21, 2024

@VinayLodhi1712 is attempting to deploy a commit to the bunty's projects Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Contributor

coderabbitai bot commented Oct 21, 2024

Walkthrough

The pull request includes modifications across several files. In backend/index.js, a typo in the import statement for the error handling middleware was corrected. The frontend/package.json file saw an update to the version of the antd dependency. The Login.jsx and Signup.jsx components were significantly updated to integrate Ant Design's messaging system for user notifications, replacing previous error handling methods. These changes enhance user feedback during login and signup processes.

Changes

File Change Summary
backend/index.js Corrected typo in the import statement for error handling middleware.
frontend/package.json Updated antd dependency version from ^5.21.2 to ^5.21.5.
frontend/src/components/Pages/Login.jsx Integrated Ant Design message component for notifications; updated handleSubmit for success/error messages; added CSS import.
frontend/src/components/Pages/Signup.jsx Integrated Ant Design message component for notifications; updated validation error handling; replaced alerts with success messages.

Possibly related PRs

Suggested labels

enhancement, level2, gssoc-ext, hacktoberfest accepted

Suggested reviewers

  • RamakrushnaBiswal

🐰 In the meadow where bunnies play,
A fix was made without delay.
A message here, a message there,
Now feedback flows with style and flair!
With every login, joy will bloom,
Thanks to the changes that chase the gloom! 🌼


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

Thank you for submitting your pull request! 🙌 We'll review it as soon as possible. In the meantime, please ensure that your changes align with our CONTRIBUTING.md. If there are any specific instructions or feedback regarding your PR, we'll provide them here. Thanks again for your contribution! 😊

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Outside diff range and nitpick comments (8)
frontend/src/components/Pages/Login.css (1)

1-43: Consider making styles more reusable and consistent across components

The addition of animated feedback for success and error messages is a great enhancement to the user interface. The implementation is clean and follows CSS best practices. However, there are a few points to consider for improving the overall impact and maintainability of these styles:

  1. Reusability: These styles are in Login.css, but they might be useful for other components as well. Consider moving these styles to a more general CSS file (e.g., messages.css or feedback.css) that can be imported by multiple components.

  2. Consistency: Ensure that these styles are used consistently across all components that display success or error messages. This will provide a uniform user experience throughout the application.

  3. Theming: Instead of hardcoding colors, consider using CSS variables or a theming system. This will make it easier to maintain a consistent color scheme and support potential future features like dark mode.

To implement these suggestions, you could:

  1. Create a new file src/styles/feedback.css with these styles.
  2. Use CSS variables for colors and durations:
:root {
  --success-color: #4caf50;
  --error-color: #d32f2f;
  --animation-duration: 0.5s;
}

.success-message::after {
  background-color: var(--success-color);
  transition: width var(--animation-duration) ease-in-out;
}

.error-message::after {
  background-color: var(--error-color);
  transition: width var(--animation-duration) ease-in-out;
}
  1. Import this new CSS file in components that use these message styles.

This approach will improve maintainability and consistency across your application.

frontend/src/components/Pages/Login.jsx (2)

21-26: LGTM: Message configuration added.

The Ant Design message configuration has been set up correctly with appropriate values. This aligns well with the PR objective of implementing alert pop-up messages.

Consider extracting these configuration values into constants at the top of the file for easier maintenance:

const MESSAGE_CONFIG = {
  top: 80,
  duration: 2,
  maxCount: 3,
};

// Then use it like this:
message.config(MESSAGE_CONFIG);

52-63: LGTM: Success message implemented correctly.

The success message implementation using Ant Design's message.success is well done. The custom styling enhances the visual feedback, aligning with the PR objectives.

Consider extracting the message style into a separate constant for reusability:

const MESSAGE_STYLE = {
  fontSize: '22px',
  right: '50px',
  position: 'fixed',
  paddingTop: '10px',
  paddingBottom: '10px',
};

// Then use it like this:
message.success({
  content: 'Login successful',
  className: 'success-message',
  style: MESSAGE_STYLE,
});
frontend/src/components/Pages/Signup.jsx (4)

1-2: LGTM! Consider extracting message configuration.

The integration of Ant Design's message component and its global configuration is a good improvement for consistent user feedback. However, consider extracting the message.config to a separate configuration file to maintain consistency across components.

You could create a new file, e.g., src/config/messageConfig.js:

import { message } from 'antd';

export const initializeMessageConfig = () => {
  message.config({
    top: 80,
    duration: 2,
  });
};

Then import and call this function in your app's entry point.

Also applies to: 10-14


36-70: Improved error handling. Consider extracting validation logic.

The use of message.error for displaying validation errors improves user experience by providing immediate visual feedback. The validation checks are comprehensive and the error messages are clear.

To improve maintainability, consider extracting the validation logic into a separate function:

const validateForm = (data) => {
  if (!data.email || !data.password || !data.name) {
    return 'Please fill in all fields.';
  }
  if (data.password.length < 8) {
    return 'Password must be at least 8 characters long.';
  }
  if (data.name.length < 3) {
    return 'Name must be at least 3 characters long.';
  }
  if (!data.email.includes('@')) {
    return 'Please enter a valid email address.';
  }
  return null;
};

// In handleSubmit:
const validationError = validateForm(data);
if (validationError) {
  message.error({
    content: validationError,
    style: { fontSize: '18px' },
  });
  setIsLoading(false);
  return;
}

This refactoring would make the handleSubmit function cleaner and the validation logic more reusable.


80-97: Good improvement in form submission feedback. Consider adding a loading state.

The use of message.error for unsuccessful registration and message.success for successful registration provides clear feedback to the user. The navigation to the login page after successful registration is a good user flow.

Consider adding a loading state to the submit button to provide visual feedback during the API call:

<button
  className="button-confirm w-full h-10 rounded-md border-2 border-black bg-beige text-[17px] font-semibold shadow-[4px_4px_0px_0px_black] mb-2"
  onClick={handleSubmit}
  disabled={isLoading}
>
  {isLoading ? 'Registering...' : "Let's go →"}
</button>

This change would prevent multiple submissions and provide better user feedback during the registration process.


101-104: Good error handling. Consider enhancing error logging.

The use of message.error in the catch block provides appropriate user feedback for unexpected errors. The generic error message is suitable for production use.

Consider enhancing the error logging to include more context:

catch (error) {
  console.error('Error during registration:', error);
  message.error({
    content: 'An error occurred while submitting the form.',
    style: { fontSize: '18px' },
  });
}

This change would provide more context in the error logs, making debugging easier in production environments.

README.md (1)

458-459: Fix formatting inconsistencies in the contributors table.

There are some formatting inconsistencies in the contributors table. Specifically, hard tabs have been used instead of spaces on several lines. To maintain consistency throughout the document, please replace the hard tabs with spaces.

Here's an example of how to fix this for one of the affected sections:

-		<tr>
-            <td align="center">
+        <tr>
+            <td align="center">

Please apply similar changes to all instances where hard tabs are used (lines 458-459, 468-469, 475-476, 482-483, 489-490, 496-497).

Also applies to: 468-469, 475-476, 482-483, 489-490, 496-497

🧰 Tools
🪛 Markdownlint

458-458: Column: 1
Hard tabs

(MD010, no-hard-tabs)


459-459: Column: 1
Hard tabs

(MD010, no-hard-tabs)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 8fbf6c1 and 0c7608a.

📒 Files selected for processing (6)
  • README.md (1 hunks)
  • backend/index.js (1 hunks)
  • frontend/package.json (1 hunks)
  • frontend/src/components/Pages/Login.css (1 hunks)
  • frontend/src/components/Pages/Login.jsx (3 hunks)
  • frontend/src/components/Pages/Signup.jsx (2 hunks)
✅ Files skipped from review due to trivial changes (2)
  • backend/index.js
  • frontend/package.json
🧰 Additional context used
🪛 Markdownlint
README.md

458-458: Column: 1
Hard tabs

(MD010, no-hard-tabs)


459-459: Column: 1
Hard tabs

(MD010, no-hard-tabs)

🔇 Additional comments (7)
frontend/src/components/Pages/Login.css (1)

2-21: Consider adjusting animation duration and verifying color scheme

The success message animation is well-implemented using CSS best practices. However, there are two points to consider:

  1. The transition duration of 2 seconds might be too long for a small UI feedback element. Consider reducing it to 0.5-1 second for a snappier feel.

  2. The use of lightgreen for the success message underline might not be consistent with the app's color scheme.

To ensure color consistency, please run the following script to check for other color definitions in the project:

This will help identify the color palette used in the project and ensure consistency.

frontend/src/components/Pages/Login.jsx (2)

4-4: LGTM: New imports added correctly.

The Ant Design message component and Login.css imports have been added appropriately. These additions align with the PR objectives of implementing alert pop-up messages using Ant Design.

Also applies to: 8-8


66-66: LGTM: Navigation after successful login added.

The navigation to the homepage after successful login is correctly implemented. This ensures a smooth user experience by redirecting users to the appropriate page after authentication.

frontend/src/components/Pages/Signup.jsx (2)

105-107: LGTM! Good error handling practice.

Moving setIsLoading(false) to the finally block is a good practice. It ensures that the loading state is always reset, preventing the UI from being stuck in a loading state in case of errors.


Line range hint 1-214: Overall, great improvements to error handling and user feedback!

The integration of Ant Design's message component significantly enhances the user experience by providing immediate and visually consistent feedback. The error handling is more robust and user-friendly, covering various scenarios from form validation to API errors.

The changes maintain good separation of concerns and adhere to React best practices. The overall structure and logic of the Signup component remain sound, with the improvements focused on user interaction and feedback.

Consider the suggested refactorings to further improve code maintainability and reusability. Great job on enhancing this component!

README.md (2)

417-500: Contributors list updated successfully.

The changes to the contributors list have been made correctly, reflecting the new contributors to the project. This update helps in recognizing the efforts of all individuals involved in the project's development.

🧰 Tools
🪛 Markdownlint

458-458: Column: 1
Hard tabs

(MD010, no-hard-tabs)


459-459: Column: 1
Hard tabs

(MD010, no-hard-tabs)


Line range hint 1-500: README.md updates look good overall.

The changes made to the README.md file, primarily in the contributors section, are appropriate and well-implemented. The overall structure and content of the document remain intact and informative. Once the formatting inconsistencies in the contributors table are addressed, the README.md will be in excellent shape.

🧰 Tools
🪛 Markdownlint

414-414: Column: 1
Hard tabs

(MD010, no-hard-tabs)


415-415: Column: 1
Hard tabs

(MD010, no-hard-tabs)


458-458: Column: 1
Hard tabs

(MD010, no-hard-tabs)


459-459: Column: 1
Hard tabs

(MD010, no-hard-tabs)


502-502: Column: 1
Hard tabs

(MD010, no-hard-tabs)

Comment on lines 23 to 42
/* Error message line animation */
.error-message::after {
content: '';
display: block;
width: 0;
height: 4px;
background-color: red;
position: absolute;
bottom: -4px;
left: 0;
transition: width 2s ease-in-out;
}

.error-message.ant-message-error {
position: relative;
}

.error-message.ant-message-error::after {
width: 100%; /* This will animate to 100% width */
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Improve accessibility and handle potential multi-line content

The error message styles are consistent with the success message implementation, which is good for maintainability. However, there are two areas for improvement:

  1. Accessibility: The use of pure red for the error message underline might not meet accessibility standards for color contrast. Consider using a darker shade of red that meets WCAG 2.1 Level AA standards.

  2. Multi-line content: The current absolute positioning of the underline might not work well with multi-line error messages. Consider using a different approach, such as a border-bottom or a flexible pseudo-element.

Here's a suggested improvement for the error message styles:

.error-message {
  position: relative;
  border-bottom: 4px solid transparent;
  transition: border-color 0.5s ease-in-out;
}

.error-message.ant-message-error {
  border-color: #d32f2f; /* A darker, more accessible red */
}

This approach uses a border instead of a pseudo-element, which will work better with multi-line content and allows for an easier color change for accessibility.

Comment on lines +68 to +80
// Show error message if login fails with a red line below
message.error({
content: 'Something went wrong while logging in.',
className: 'error-message', // Add custom class for styling
style: {
fontSize: '18px',
right: '50px', // Position it on the right side
position: 'fixed', // Fix it to the viewport
paddingTop: '10px', // Add padding to move the text down
paddingBottom: '10px', // Padding for balance
},
});
setError('An error occurred. Please try again.');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Inconsistent Error Handling Across Components

Error handling implementations using message.error vary between components:

  • Signup.jsx and Login.jsx apply custom styles for enhanced user feedback.
  • Admin.jsx uses default styling without customizations.

Consider standardizing the error handling approach and extracting common styles into a shared constant to ensure consistency and maintainability across the codebase.

🔗 Analysis chain

LGTM with suggestions: Error message implemented correctly.

The error message implementation using Ant Design's message.error is well done. The custom styling enhances the visual feedback, aligning with the PR objectives.

  1. Consider extracting the message style into a separate constant for reusability, similar to the success message suggestion.

  2. The error state is still being set alongside the new message implementation. Consider if this dual approach is necessary:

setError('An error occurred. Please try again.');

If the Ant Design message is sufficient for user feedback, you might be able to remove the error state and its related UI elements for a more streamlined approach.

To ensure consistency across the application, let's check if other components are using a similar approach for error handling:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for similar error handling patterns in other components
rg -A 5 "message.error" src/components

Length of output: 93


Script:

#!/bin/bash
# Search for "message.error" patterns across the entire repository
rg "message.error" --context 5

Length of output: 6362


Script:

#!/bin/bash
# Search for "message.error" patterns within the frontend/src/components directory
rg "message.error" frontend/src/components --context 5

Length of output: 6386

backend/index.js Show resolved Hide resolved
@@ -0,0 +1,43 @@

/* Success message line animation */

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't use css files use tailwinf instead @VinayLodhi1712

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

import Cookies from 'js-cookie';
import { FaEye } from 'react-icons/fa';
import { FaEyeSlash } from 'react-icons/fa6';

import "./Login.css";
const Login = () => {
Copy link
Owner

@RamakrushnaBiswal RamakrushnaBiswal Oct 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@VinayLodhi1712 here also

@VinayLodhi1712
Copy link
Contributor Author

@RamakrushnaBiswal Sir now you can check plz.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (4)
frontend/src/components/Pages/Login.jsx (4)

20-25: LGTM: Message configuration enhances user experience.

The configuration for the Ant Design message component is well-implemented, setting appropriate values for positioning, duration, and maximum count of messages. This enhances the user experience by controlling message appearance and behavior.

Consider extracting this configuration into a separate constant or utility file if it's used across multiple components. This would improve maintainability and ensure consistency throughout the application.


51-62: LGTM: Success message implemented with custom styling.

The success message implementation using Ant Design's message.success is well done. The custom styling enhances the visual feedback, aligning with the PR objectives.

Consider extracting the message style into a separate constant or utility function for reusability. This would help maintain consistency across components and make future style updates easier. For example:

const getMessageStyle = (fontSize = '22px') => ({
  fontSize,
  right: '50px',
  position: 'fixed',
  paddingTop: '10px',
  paddingBottom: '10px',
});

// Usage
message.success({
  content: 'Login successful',
  className: 'success-message',
  style: getMessageStyle(),
});

67-79: LGTM with suggestions: Error message implemented correctly.

The error message implementation using Ant Design's message.error is well done. The custom styling enhances the visual feedback, aligning with the PR objectives.

  1. Consider using the same styling approach suggested for the success message to maintain consistency and improve maintainability.

  2. The error state is still being set alongside the new message implementation:

setError('An error occurred. Please try again.');

If the Ant Design message is sufficient for user feedback, you might be able to remove the error state and its related UI elements for a more streamlined approach. Please review if this dual approach is necessary or if it can be simplified.


Inconsistent Error Handling Implementation Across Components

The use of message.error varies between components, leading to inconsistent user feedback:

  • frontend/src/components/Pages/Admin.jsx

    • message.error('Error adding event'); (No additional styling)
  • frontend/src/components/Pages/Signup.jsx

    • message.error({ content: 'Please fill in all fields.', style: { fontSize: '18px' } }); (Custom styling)
  • frontend/src/components/Pages/Login.jsx

    • message.error({ content: 'Something went wrong while logging in.', className: 'error-message', style: { fontSize: '18px', right: '50px' } }); (Custom styling and class)

To ensure a consistent user experience and maintainability, consider standardizing the error handling approach across all components. This may involve:

  • Defining a shared utility for configuring and displaying error messages.
  • Establishing consistent styling guidelines for all message.error usages.
  • Refactoring existing components to adhere to the standardized approach.
🔗 Analysis chain

Line range hint 1-190: Overall implementation looks good, consider application-wide consistency.

The changes to the Login component successfully implement Ant Design's message system for user notifications, improving the user experience and aligning with the PR objectives. The core functionality of the component remains intact while enhancing feedback mechanisms.

To ensure consistency across the application, let's verify if other components are using a similar approach for error handling:

Based on the results of this search, consider standardizing the error handling approach across all components in the application. This may involve:

  1. Using consistent styling for messages.
  2. Deciding on a uniform approach to error state management alongside Ant Design messages.
  3. Potentially creating a shared utility for message configuration and styling.

These steps will enhance maintainability and provide a consistent user experience throughout the application.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for similar error handling patterns in other components
rg -A 5 "message.error" frontend/src/components

Length of output: 3424

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 0c7608a and 054b7ce.

📒 Files selected for processing (1)
  • frontend/src/components/Pages/Login.jsx (3 hunks)
🧰 Additional context used
🔇 Additional comments (1)
frontend/src/components/Pages/Login.jsx (1)

4-4: LGTM: Ant Design message component imported correctly.

The import statement for the Ant Design message component is correctly added, which is necessary for the new messaging functionality implemented in this file.

Copy link

vercel bot commented Oct 22, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
play-cafe ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 22, 2024 2:51pm

@RamakrushnaBiswal RamakrushnaBiswal merged commit c371df6 into RamakrushnaBiswal:main Oct 22, 2024
4 checks passed
@RamakrushnaBiswal RamakrushnaBiswal added good first issue Good for newcomers level1 for 10 points gssoc-ext gssoc-extd program hacktoberfest accepted hacktoberfest-accepted repo labels Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers gssoc-ext gssoc-extd program hacktoberfest accepted hacktoberfest-accepted repo level1 for 10 points
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants