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

Rm whatsapp phone number, hide email for updates #10334

Merged

Conversation

Jacobjeevan
Copy link
Contributor

@Jacobjeevan Jacobjeevan commented Jan 31, 2025

Proposed Changes

@ohcnetwork/care-fe-code-reviewers

Merge Checklist

  • Add specs that demonstrate bug / test a new feature.
  • Update product documentation.
  • Ensure that UI text is kept in I18n files.
  • Prep screenshot or demo video for changelog entry, and attach it to issue.
  • Request for Peer Reviews
  • Completion of QA

Summary by CodeRabbit

  • User Form Changes

    • Removed alternative phone number field
    • Removed WhatsApp phone number checkbox
    • Made phone number field mandatory
    • Introduced email field for non-edit modes
    • Simplified form validation and user information capture
  • Type Model Updates

    • Removed phone_number_is_whatsapp property
    • Removed alt_phone_number property
    • Updated user update model to exclude email field
  • Validation Logic Updates

    • Removed validation error message for alternate phone number during user creation
  • Data Fetching Improvements

    • Streamlined user data fetching process using useQuery hook
    • Enhanced error handling and loading state management
  • User Deletion Process

    • Implemented streamlined user deletion with useMutation hook
    • Simplified success and error handling for user deletion

@Jacobjeevan Jacobjeevan requested a review from a team as a code owner January 31, 2025 06:41
Copy link
Contributor

coderabbitai bot commented Jan 31, 2025

Walkthrough

The pull request introduces significant changes to the user form and user model types. The modifications primarily focus on simplifying the user information capture process by removing auxiliary fields like the alternative phone number and WhatsApp phone number checkbox. The phone_number field is now mandatory, and the email field has been repositioned to be more prominent in non-edit modes. These changes streamline the user creation and update workflows by reducing complexity and focusing on essential user information.

Changes

File Change Summary
src/components/Users/UserForm.tsx - Removed alt_phone_number and phone_number_is_whatsapp fields
- Made phone_number mandatory
- Updated email field rendering and validation
src/types/user/user.ts - Removed phone_number_is_whatsapp from CreateUserModel
- Removed alt_phone_number from CreateUserModel
- Updated UpdateUserModel to exclude email
cypress/pageObject/Users/UserCreation.ts - Removed validation error message for "Alternate Phone Number"
src/components/Common/UserColumns.tsx - Removed optional refetchUserData property from userChildProps type
src/components/Users/UserAvatar.tsx - Replaced custom query hook with useQuery from @tanstack/react-query and updated loading state handling
src/components/Users/UserHome.tsx - Replaced custom query hook with useQuery and simplified error handling
src/components/Users/UserSummary.tsx - Introduced useMutation for user deletion, removed refetchUserData prop

Assessment against linked issues

Objective Addressed Explanation
Hide Email ID in user update form The email ID field was not hidden in the user update form as per the requirements.
Hide Alt Phone number in user creation and updation Form

Possibly related PRs

  • User creation form bug fix #9404: The changes in UserFormValidations.tsx regarding the removal of fields from the validation schema are related to the modifications in the UserForm.tsx, which also involves changes to the validation logic for user creation.
  • Username validation added in Create user form #9835: This PR introduces username validation in the CreateUserForm, which is directly related to the changes in the UserForm.tsx that also focus on user input validation.
  • Add max phone number length to user creation form #9952: The addition of a maximum length restriction for phone numbers in the CreateUserForm is relevant to the changes in the UserForm.tsx, which also deals with user input fields.

Suggested labels

needs review, tested, P1

Suggested reviewers

  • rithviknishad

Poem

🐰 A form so clean, fields now lean
No alt numbers to be seen
WhatsApp checkbox? Gone today!
Simplicity finds its way
User details, crisp and bright 🌟


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

netlify bot commented Jan 31, 2025

Deploy Preview for care-ohc ready!

Name Link
🔨 Latest commit 01eb7cb
🔍 Latest deploy log https://app.netlify.com/sites/care-ohc/deploys/679c7fe26f40b20008069a92
😎 Deploy Preview https://deploy-preview-10334--care-ohc.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

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

🧹 Nitpick comments (1)
src/components/Users/UserForm.tsx (1)

165-165: Remove unused dependency from useEffect.

The phoneNumber variable is included in the dependency array but is not used within the effect. This could lead to unnecessary re-renders.

-  }, [phoneNumber, form, usernameInput, isEditMode]);
+  }, [form, usernameInput, isEditMode]);
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 34c7b68 and 10eafd2.

📒 Files selected for processing (2)
  • src/components/Users/UserForm.tsx (2 hunks)
  • src/types/user/user.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: cypress-run (1)
  • GitHub Check: OSSAR-Scan
🔇 Additional comments (3)
src/types/user/user.ts (1)

33-36: LGTM! The type definition change aligns with the PR objectives.

The update to exclude the email property from UpdateUserModel is consistent with the requirement to hide email for updates.

src/components/Users/UserForm.tsx (2)

489-508: LGTM! Email field implementation is correct.

The email field is properly implemented with:

  • Visibility control for non-edit mode
  • Required validation
  • Proper type and data-cy attributes

510-524: LGTM! Phone number field changes align with PR objectives.

The changes correctly:

  • Remove WhatsApp-related functionality
  • Make phone number a required field
  • Maintain proper validation

@nihal467
Copy link
Member

image

@Jacobjeevan the cards is showing updated data only after manual refresh of the page, can you fix it

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

🧹 Nitpick comments (1)
src/components/Users/UserHome.tsx (1)

56-58: Consider enhancing error handling with user feedback.

While navigating back on error is good, consider showing an error message to inform users why they're being redirected.

  if (isError) {
+   toast.error(t("error_loading_user_details"));
    goBack("/");
  }
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 605e49d and 01eb7cb.

📒 Files selected for processing (4)
  • src/components/Common/UserColumns.tsx (0 hunks)
  • src/components/Users/UserAvatar.tsx (3 hunks)
  • src/components/Users/UserHome.tsx (5 hunks)
  • src/components/Users/UserSummary.tsx (2 hunks)
💤 Files with no reviewable changes (1)
  • src/components/Common/UserColumns.tsx
🧰 Additional context used
📓 Learnings (1)
src/components/Users/UserSummary.tsx (1)
Learnt from: Jacobjeevan
PR: ohcnetwork/care_fe#9080
File: src/components/Users/UserSummary.tsx:53-71
Timestamp: 2024-11-22T12:04:39.044Z
Learning: In the `UserSummaryTab` component (`src/components/Users/UserSummary.tsx`), when there is an error during user deletion, the delete dialog is intentionally closed to prevent the user from immediately trying to delete the user again.
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: cypress-run (1)
🔇 Additional comments (5)
src/components/Users/UserAvatar.tsx (1)

30-37: LGTM! Clean migration to useQuery.

The implementation correctly uses the useQuery hook with proper query key structure and error handling.

src/components/Users/UserHome.tsx (1)

60-62: LGTM! Clean loading state handling.

The loading state check is properly implemented with a null check for userData.

src/components/Users/UserSummary.tsx (3)

41-56: LGTM! Well-structured mutation with proper error handling.

The mutation implementation correctly follows the established pattern of closing the dialog on both success and error, as per the retrieved learning.


61-63: LGTM! Clean handleSubmit implementation.

The handleSubmit function is properly simplified to use the mutation.


1-1: Verify alignment with PR objectives.

The reviewed changes focus on technical improvements (query hook migrations) but don't directly address the PR objectives of removing WhatsApp phone number and hiding email for updates. Please ensure these changes are included in other files or in a separate PR.

@nihal467
Copy link
Member

LGTM

@nihal467 nihal467 added tested reviewed reviewed by a core member and removed needs testing labels Jan 31, 2025
@rithviknishad rithviknishad merged commit b4e9216 into ohcnetwork:develop Jan 31, 2025
20 checks passed
Copy link

@Jacobjeevan Your efforts have helped advance digital healthcare and TeleICU systems. 🚀 Thank you for taking the time out to make CARE better. We hope you continue to innovate and contribute; your impact is immense! 🙌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
reviewed reviewed by a core member tested
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Hide No Update Supporting Fields in Users Form
3 participants