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

added a modal for sending invitation #406

Merged

Conversation

melpsh
Copy link
Contributor

@melpsh melpsh commented Jan 2, 2025

Added a new modal for sending invitation for the users

added a new modal and revoked it as a pop up

issue #404

  • I deployed the code locally.
  • I have performed a self-review of my code.
  • I have included the issue # in the PR.
  • I have labelled the PR correctly.
  • The issue I am working on is assigned to me.
  • I didn't use any hardcoded values (otherwise it will not scale, and will make it difficult to maintain consistency across the application).
  • I made sure font sizes, color choices etc are all referenced from the theme.
  • My PR is granular and targeted to one specific feature.
  • I took a screenshot or a video and attached to this PR if there is a UI change.

image

Summary by CodeRabbit

  • New Features

    • Added an InviteUserModal component for inviting team members.
    • Implemented a modal with email and role selection functionality.
    • Enhanced team management settings with user invitation capabilities.
  • Improvements

    • Integrated modal with responsive design using Material-UI components.
    • Added state management for modal visibility and invite process.

@melpsh melpsh added the frontend Frontend related tasks/issues label Jan 2, 2025
@melpsh melpsh self-assigned this Jan 2, 2025
Copy link

coderabbitai bot commented Jan 2, 2025

Walkthrough

A new InviteUserModal component has been developed to streamline the process of inviting users to a team. The modal is implemented in the Clients/src/presentation/components/Modals/InviteUser/index.tsx file and integrated into the TeamManagement component within the SettingsPage. The component provides a user-friendly interface for entering an email and selecting a role when inviting a new team member, with React hooks managing the modal's state and interaction.

Changes

File Change Summary
Clients/src/presentation/components/Modals/InviteUser/index.tsx New modal component InviteUserModal created with props for managing modal visibility and invite functionality
Clients/src/presentation/pages/SettingsPage/Team/index.tsx Added InviteUserModal to TeamManagement, introduced inviteUserModalOpen state, and implemented inviteTeamMember function

Sequence Diagram

sequenceDiagram
    participant User
    participant TeamManagement
    participant InviteUserModal
    User->>TeamManagement: Click "Invite Team Member"
    TeamManagement->>InviteUserModal: Open Modal
    User->>InviteUserModal: Enter Email
    User->>InviteUserModal: Select Role
    User->>InviteUserModal: Click "Send Invite"
    InviteUserModal->>TeamManagement: Invoke onSendInvite
    TeamManagement-->>User: Invite Processed
Loading

Possibly related PRs

  • settings modal logic #365: Directly related to the introduction of the InviteUserModal component in the TeamManagement component.

Suggested reviewers

  • gorkem-bwl
  • MuhammadKhalilzadeh

Poem

🐰 A modal springs to life with glee,
Inviting friends, so easily!
Email and role, a simple dance,
Team growth now has its perfect chance!
Hop, hop, invite – let teamwork start! 🚀


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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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

@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: 1

🧹 Nitpick comments (4)
Clients/src/presentation/components/Modals/InviteUser/index.tsx (3)

66-66: Duplicate spacing definitions.

You're defining both p: theme.spacing(4) and padding: theme.spacing(12) on line 66. The padding property overrides p. Consider removing one of them to avoid confusion and ensure consistent styling.

 sx={{
-  p: theme.spacing(4),
   padding: theme.spacing(12),
   ...
 }}

81-82: Potential for role-based instructions.

Currently, the text says "they will get access to all monitors." If different roles grant different levels of access, you may want to clarify or vary this instruction based on user role. This helps users understand each role's scope more accurately.


84-90: Enhance email validation feedback.

Consider adding more explicit validation or feedback messages to guide the user if they enter an invalid email. This will improve user experience and reduce form submission errors.

Clients/src/presentation/pages/SettingsPage/Team/index.tsx (1)

363-372: Inline arrow function usage.

Using an inline arrow function for onSendInvite is acceptable, but consider defining a named function if the logic becomes more complex (e.g., adding error handling or multiple steps). This can improve readability and reusability.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1143164 and 57a4017.

📒 Files selected for processing (2)
  • Clients/src/presentation/components/Modals/InviteUser/index.tsx (1 hunks)
  • Clients/src/presentation/pages/SettingsPage/Team/index.tsx (5 hunks)
🔇 Additional comments (6)
Clients/src/presentation/components/Modals/InviteUser/index.tsx (2)

95-108: Revisit the default role selection.

The dropdown starts with a disabled empty option. If a user fails to select a role, the "Send Invite" button remains disabled. This is correct behavior, but you might want to surface a more descriptive message or highlight it in the UI, ensuring the user understands why the button is disabled.


137-143: Disable button until fields are valid.

Disabling the "Send Invite" button when email or role is empty helps prevent incomplete form submissions. This is a good practice. Just ensure that if you add more fields later, you maintain a consistent validation pattern.

Clients/src/presentation/pages/SettingsPage/Team/index.tsx (4)

26-26: Appropriate import.

Importing InviteUserModal is correct. Ensure you keep imports organized if additional components are added.


81-81: Confirm usage of dashboardValues.

dashboardValues is being retrieved from context, but only vendors.length is used for table pagination. If there are other properties of dashboardValues that should be leveraged here, make sure they’re not accidentally overlooked or removed.


83-83: Descriptive naming of inviteUserModalOpen.

inviteUserModalOpen is a clear and self-explanatory name. Good job on using semantic naming for state.


247-247: Clear call-to-action label.

"Invite team member" succinctly communicates the button's purpose. Great for user clarity!

Comment on lines +148 to +151
const inviteTeamMember = () => {
console.log("Inviting team member");
setInviteUserModalOpen(true);
};
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Encapsulate inviteTeamMember logic if it grows.

Right now, logging and setting the modal open is straightforward. If you need more comprehensive logic for error handling or backend calls, consider moving it to a separate function or hooking into a context or service for maintainability.

@MuhammadKhalilzadeh
Copy link
Collaborator

@gorkemcetin
Hi boss
Any other modifications you have for this?

@gorkem-bwl
Copy link
Contributor

@melpsh can you please use our components instead of the MUI ones? The text fields don't look like they are our components.

Also can you left align this area?

image

@melpsh
Copy link
Contributor Author

melpsh commented Jan 6, 2025

image

What do you mean by left-align? @gorkem-bwl , it is already left aligned.

Copy link

@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: 1

🧹 Nitpick comments (4)
Clients/src/presentation/components/Modals/InviteUser/index.tsx (4)

34-38: Export a type for the interface.

Consider exporting InviteUserModalProps in case other components need to reference this interface for consistent type usage throughout the app.

+export interface InviteUserModalProps {
   isOpen: boolean;
   setIsOpen: (isOpen: boolean) => void;
   onSendInvite: (email: string, role: string) => void;
 }

49-70: Ensure responsive sizing with breakpoints.

You might want to explore MUI’s responsive breakpoints for the modal width, instead of a fixed 450 width, to ensure the modal scales appropriately on smaller devices.


83-92: Validate form fields before sending invites.

You can add more robust validation (e.g., checking for a properly formatted email, disallowing invalid roles) to enhance user experience and data integrity.

Also applies to: 93-103


131-151: Enable partial states for invitation.

Currently, the “Send Invite” button is disabled if either email or role is empty. Consider adding more progressive validation or inline checks to guide the user (e.g., “Please enter a valid email”).

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 57a4017 and 84ca7f8.

📒 Files selected for processing (1)
  • Clients/src/presentation/components/Modals/InviteUser/index.tsx (1 hunks)
🔇 Additional comments (4)
Clients/src/presentation/components/Modals/InviteUser/index.tsx (4)

28-32: Props interface is clearly defined. Good job!

Defining the props interface with the required fields (isOpen, setIsOpen, onSendInvite) is concise and enhances type safety. Keep it up!


72-82: Good job on descriptive text.

Your instructions for inviting a new team member are concise. This helps users understand the impact of adding a new member.


111-130: Proper design choice for the “Cancel” button.

Using a text button for a Cancel action is intuitive. The styling approach using sx is also consistent with MUI's API.


158-158: Export is well-defined.

Default export of InviteUserModal is straightforward, which simplifies imports in other files.

Comment on lines +16 to +23
import {
Button,
MenuItem,
Modal,
Stack,
Typography,
useTheme,
} from "@mui/material";
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider using your project's custom UI components instead of MUI.

Per the feedback in the PR comments, there's a preference for aligning with the existing design system by using the project's custom components. This would ensure visual consistency across the application.

@gorkem-bwl
Copy link
Contributor

What do you mean by left-align? @gorkem-bwl , it is already left aligned.

Ah ok then - I thought it's center aligned. Good to go!

@MuhammadKhalilzadeh MuhammadKhalilzadeh merged commit f2a4cb4 into bluewave-labs:master Jan 6, 2025
1 check passed
@coderabbitai coderabbitai bot mentioned this pull request Jan 8, 2025
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
frontend Frontend related tasks/issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants