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

Add User Status: Online & Last Seen Timestamps #9781

Closed

Conversation

rajku-dev
Copy link
Contributor

@rajku-dev rajku-dev commented Jan 6, 2025

Proposed Changes

  • Fixes Profile Data Mismatch #9774
  • Extended the logic in UserStatusIndicator to include last seen minutes/hour(s)/days functionality and reuse it at other places.

BEFORE

image

AFTER

image
image
image

@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

  • Localization

    • Added new localization keys for user status messages in multiple languages (English, Hindi, Kannada, Malayalam, Marathi, Tamil)
    • New keys include "never_logged_in" and "online" translations
  • User Interface

    • Updated user status display across multiple components
    • Replaced previous online status badges with a new UserStatusIndicator component
    • Simplified user status representation in various pages
  • Code Improvements

    • Refined user status logic and display methods
    • Removed redundant code related to user online status display

@rajku-dev rajku-dev requested a review from a team as a code owner January 6, 2025 07:57
Copy link
Contributor

coderabbitai bot commented Jan 6, 2025

Warning

Rate limit exceeded

@rajku-dev has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 25 minutes and 39 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between da71f19 and 48b01a9.

📒 Files selected for processing (1)
  • src/pages/Organization/components/EditUserRoleSheet.tsx (2 hunks)

Walkthrough

The pull request introduces localization updates for user status messages across multiple language JSON files and modifies user interface components to display user status more consistently. The changes focus on adding new localization keys for "never logged in" and "online" statuses in English, Hindi, Kannada, Malayalam, Marathi, and Tamil language files. Additionally, the UserStatusIndicator component in various files has been refactored to improve the representation of user online and login status.

Changes

File Change Summary
public/locale/*.json Added localization keys: "never_logged_in" and "online" in multiple language files
src/components/Users/UserListAndCard.tsx Refactored UserStatusIndicator and getNameAndStatusCard methods to simplify user status display
src/pages/*/Users.tsx Updated to use new UserStatusIndicator component instead of previous badge implementations

Assessment against linked issues

Objective Addressed Explanation
Resolve Profile Data Mismatch [#9774]
Consistent display of last login and online status

Possibly related PRs

Suggested labels

needs review, changes required

Suggested reviewers

  • rithviknishad
  • Jacobjeevan
  • bodhish

Poem

🐰 A Rabbit's Localization Tale 🌐

In languages diverse and bright,
"Online" and "Never logged" take flight,
With status badges crisp and clear,
Our users' stories now appear!
Code hops, translation sings its art! 🚀


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 6, 2025

Deploy Preview for care-ohc ready!

Name Link
🔨 Latest commit 48b01a9
🔍 Latest deploy log https://app.netlify.com/sites/care-ohc/deploys/677b95037f2734000873db09
😎 Deploy Preview https://deploy-preview-9781--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 (3)
src/pages/FacilityOrganization/FacilityOrganizationUsers.tsx (1)

120-123: Consider semantic structuring of username and status.
Wrapping both the username and the status indicator within the same <span> may cause layout constraints if future styling or modifications are needed. Consider separate containers (e.g., a <div> or more granular <span> elements) for improved flexibility.

src/pages/FacilityOrganization/components/EditFacilityUserRoleSheet.tsx (1)

165-166: Ensure consistent labeling for user status.
Displaying "Last Login" separately from the UserStatusIndicator is clear. However, note that the UserStatusIndicator already denotes an explicit last-seen time or a "never logged in" state. Consider whether you want an additional label or if the indicator alone suffices.

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

103-138: Use a consistent date handling strategy.
Currently, toLocaleString() is used to generate a tooltip (line 104), but dayjs is used for calculating durations. To maintain a consistent user experience and localization approach, consider using dayjs for tooltip formatting as well. Also, ensure user.last_login is defined before calling any date functions.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 4318ffd and da71f19.

📒 Files selected for processing (11)
  • public/locale/en.json (2 hunks)
  • public/locale/hi.json (1 hunks)
  • public/locale/kn.json (1 hunks)
  • public/locale/ml.json (1 hunks)
  • public/locale/mr.json (1 hunks)
  • public/locale/ta.json (1 hunks)
  • src/components/Users/UserBanner.tsx (0 hunks)
  • src/components/Users/UserListAndCard.tsx (6 hunks)
  • src/pages/FacilityOrganization/FacilityOrganizationUsers.tsx (2 hunks)
  • src/pages/FacilityOrganization/components/EditFacilityUserRoleSheet.tsx (2 hunks)
  • src/pages/Organization/OrganizationUsers.tsx (2 hunks)
💤 Files with no reviewable changes (1)
  • src/components/Users/UserBanner.tsx
✅ Files skipped from review due to trivial changes (1)
  • public/locale/ta.json
🔇 Additional comments (15)
src/pages/Organization/OrganizationUsers.tsx (2)

10-10: New import looks good.
No issues with importing and using UserStatusIndicator here.


122-122: Check for null or undefined user.
Although unlikely, ensure that userRole.user is never null or undefined to avoid potential runtime errors when rendering.

src/pages/FacilityOrganization/FacilityOrganizationUsers.tsx (1)

10-10: Import statement is clear and consistent.
The UserStatusIndicator import aligns well with the rest of the project structure.

src/pages/FacilityOrganization/components/EditFacilityUserRoleSheet.tsx (1)

34-34: New import is well-integrated.
No concerns with the import usage.

src/components/Users/UserListAndCard.tsx (6)

1-1: Importing dayjs for date operations is appropriate.
This is a good fit for manipulating and formatting time.


8-9: Using the Badge component.
This import organizes user status styling in a consistent, reusable manner.


20-20: Consolidated utility imports.
No issues with importing from utils.


66-66: Function signature simplification.
Removing the cur_online parameter from getNameAndStatusCard helps reduce complexity, especially as online detection is encapsulated in UserStatusIndicator.


75-75: Usage of UserStatusIndicator in the name/status card.
Seamless integration of status within the user’s name card.


170-170: Revised getNameAndStatusCard usage.
Calling getNameAndStatusCard(user, !isLessThanXLargeScreen) clarifies which portion of the UI is displayed based on screen size. This dynamic usage is consistent with responsive design.

public/locale/mr.json (1)

96-98: LGTM! Translations are accurate and consistent.

The added translations for user status messages in Marathi are accurate and maintain consistency with other language files.

public/locale/hi.json (1)

810-813: LGTM! Translations are accurate and consistent.

The added translations for user status messages in Hindi are accurate and maintain consistency with other language files.

public/locale/kn.json (1)

811-814: LGTM! Translations are accurate and consistent.

The added translations for user status messages in Kannada are accurate and maintain consistency with other language files.

public/locale/ml.json (1)

812-813: LGTM! Proper localization of user status messages.

The Malayalam translations for "never logged in" and "online" status messages are accurate and culturally appropriate.

public/locale/en.json (1)

1202-1202: LGTM! Clear and consistent status messages.

The English translations are simple and follow the existing lowercase style convention for status messages.

Also applies to: 1291-1291

@rithviknishad
Copy link
Member

Violates translation guidelines and duplicate issue.
https://github.com/ohcnetwork/care_fe?tab=readme-ov-file#translations

@rajku-dev
Copy link
Contributor Author

Violates translation guidelines and duplicate issue. https://github.com/ohcnetwork/care_fe?tab=readme-ov-file#translations

sorry for that, should have not used i18 ally, will revert the changes if you want me to.
although it fixes the issue @rithviknishad

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.

Profile Data Mismatch
2 participants