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

Fix Online Status Indicator in Organization Tab #9728

Open
wants to merge 19 commits into
base: develop
Choose a base branch
from

Conversation

JavidSumra
Copy link
Contributor

@JavidSumra JavidSumra commented Jan 4, 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

Release Notes

  • Internationalization

    • Added support for multiple languages across various components
    • Updated user interface text to be dynamically translatable
  • User Management

    • Improved user status display with new UserStatusIndicator component
    • Enhanced user role management interfaces
  • UI Improvements

    • Refined user status representation
    • Updated labels and messages for better clarity
  • Localization

    • Added new translation keys for user management and interface elements
    • Replaced hardcoded strings with translation function calls

@JavidSumra JavidSumra requested a review from a team as a code owner January 4, 2025 06:01
Copy link
Contributor

coderabbitai bot commented Jan 4, 2025

Walkthrough

This pull request introduces comprehensive internationalization (i18n) support and improves user status representation across multiple components. The changes focus on replacing hardcoded strings with translatable keys, integrating the useTranslation hook from react-i18next, and updating the UserStatusIndicator component to provide more accurate user online/offline status display. The modifications span several files in the user management and organization sections, enhancing localization and user interface consistency.

Changes

File Change Summary
src/pages/FacilityOrganization/FacilityOrganizationUsers.tsx Added i18n support, replaced Badge with UserStatusIndicator, translated text strings
src/pages/Organization/OrganizationUsers.tsx Integrated useTranslation, replaced user status display, localized text labels
src/components/ui/sidebar/facility-switcher.tsx Added translation for facility-related text
src/components/Users/UserListAndCard.tsx Refactored user status display logic, added localization
public/locale/en.json Added multiple new translation keys for user management and organization features
src/pages/FacilityOrganization/components/EditFacilityUserRoleSheet.tsx Implemented i18n for user role management
src/pages/Organization/components/EditUserRoleSheet.tsx Added translation support for user role editing

Assessment against linked issues

Objective Addressed Explanation
Fix incorrect online status display [#9726]

Possibly related PRs

Suggested labels

tested, reviewed, good to merge

Suggested reviewers

  • rithviknishad
  • Jacobjeevan

Poem

🐰 A rabbit's tale of code so bright,
Translations dancing with pure delight
Users' status now crystal clear
No more confusion, no more fear
Internationalization takes its flight! 🌍✨


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

Deploy Preview for care-ohc ready!

Name Link
🔨 Latest commit 06b5c15
🔍 Latest deploy log https://app.netlify.com/sites/care-ohc/deploys/677e921034e9150008ef08d0
😎 Deploy Preview https://deploy-preview-9728--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
Member

@bodhish bodhish left a comment

Choose a reason for hiding this comment

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

Move all strings in this page to I18n

@JavidSumra JavidSumra requested a review from bodhish January 6, 2025 05:59
Copy link
Member

@rithviknishad rithviknishad left a comment

Choose a reason for hiding this comment

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

@JavidSumra ensure one's done in #9781 is also handled in this

@github-actions github-actions bot added the merge conflict pull requests with merge conflict label Jan 6, 2025
Copy link

github-actions bot commented Jan 6, 2025

👋 Hi, @JavidSumra,
Conflicts have been detected against the base branch. Please rebase your branch against the base branch.


This message is automatically generated by prince-chrismc/label-merge-conflicts-action so don't hesitate to report issues/improvements there.

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 (7)
src/pages/Organization/OrganizationUsers.tsx (1)

132-132: [Localize Role Label]
Using t("role") is consistent with your new i18n approach. Check for uniform capitalization and usage across all locale JSON entries.

src/pages/Organization/components/EditUserRoleSheet.tsx (2)

35-35: [UserStatusIndicator Import]
Importing UserStatusIndicator centralizes status renders. Confirm if any older status code remains for cleanup.


127-127: [Localize Description]
{t("update_user_role_organization")} is consistent. Confirm the translation entry is short and descriptive to maintain clarity.

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

169-172: [Refactor Last Login to Status Indicator]
UserStatusIndicator usage matches other components. This aggregated approach provides a single source for user status logic.

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

103-138: [Core Logic for UserStatusIndicator]
This block properly categorizes three states: online, last seen, or never logged in. The usage of dayjs is more reliable than manual date arithmetic. Validate large time spans (weeks/months) to ensure accurate status display.

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

122-127: Consider improving the spacing between username and status indicator.

The current implementation uses an arbitrary mx-2 margin on the username span. Consider using a more semantic approach to handle the spacing between elements.

-<span className="text-sm text-gray-500">
-  <span className="mx-2">
-    {userRole.user.username}
-  </span>
-  <UserStatusIndicator user={userRole.user} />
-</span>
+<span className="text-sm text-gray-500 flex items-center gap-2">
+  <span>{userRole.user.username}</span>
+  <UserStatusIndicator user={userRole.user} />
+</span>

Line range hint 106-170: Consider adding ARIA labels for better accessibility.

The user cards could benefit from improved accessibility. Consider adding appropriate ARIA labels to help screen readers better convey the user information.

-<Card key={userRole.id} className="h-full">
+<Card 
+  key={userRole.id} 
+  className="h-full"
+  aria-label={`User card for ${userRole.user.first_name} ${userRole.user.last_name}`}
+>
   <CardContent className="p-4 sm:p-6">
     {/* ... */}
-    <div className="grid grid-cols-2 gap-4 text-sm">
+    <div 
+      className="grid grid-cols-2 gap-4 text-sm"
+      role="list"
+      aria-label="User details"
+    >
       <div>
-        <div className="text-gray-500">{t("role")}</div>
+        <div className="text-gray-500" role="term">{t("role")}</div>
         <div className="font-medium truncate">
           {userRole.role.name}
         </div>
       </div>
       <div>
-        <div className="text-gray-500">{t("phone_number")}</div>
+        <div className="text-gray-500" role="term">{t("phone_number")}</div>
         <div className="font-medium truncate">
           {userRole.user.phone_number}
         </div>
       </div>
     </div>
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 04af21c and 747d6b0.

📒 Files selected for processing (8)
  • public/locale/en.json (12 hunks)
  • src/components/Users/UserListAndCard.tsx (9 hunks)
  • src/components/ui/sidebar/facility-switcher.tsx (4 hunks)
  • src/pages/FacilityOrganization/FacilityOrganizationUsers.tsx (6 hunks)
  • src/pages/FacilityOrganization/components/EditFacilityUserRoleSheet.tsx (9 hunks)
  • src/pages/Organization/OrganizationUsers.tsx (6 hunks)
  • src/pages/Organization/components/EditUserRoleSheet.tsx (9 hunks)
  • src/types/notes/messages.ts (0 hunks)
💤 Files with no reviewable changes (1)
  • src/types/notes/messages.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/components/ui/sidebar/facility-switcher.tsx
  • public/locale/en.json
🔇 Additional comments (54)
src/pages/Organization/OrganizationUsers.tsx (8)

3-3: [Use i18n Hook Effectively]
The addition of the useTranslation import is correct. It aligns with the new usage of localized strings, ensuring that the module can leverage language translation throughout the component.


11-11: [Proper Component Import]
Importing UserStatusIndicator from @/components/Users/UserListAndCard is consistent with the PR objective of unifying user status display logic. Ensure that you remove any leftover references to outdated status indicators, if present.


32-32: [Initialize Translation Hook]
Initializing the translation hook right before usage is a good practice. Verify that the translation keys ("users", "no_users_found", etc.) are duly added in the locale JSON files to prevent runtime fallbacks.


75-75: [Replace Hardcoded "Users" with i18n Key]
Using t("users") aligns with the updated translations across the application.


101-101: [Replace Hardcoded "No users found." with i18n Key]
The updated t("no_users_found") improves localization. Confirm that your translation files contain the "no_users_found" key to fully localize this text.


124-124: [Use Centralized User Status Indicator]
Replacing any ad-hoc status badges with the UserStatusIndicator promotes consistency. This is beneficial for maintainability and can unify status checks in one place.


138-138: [Localize Phone Number Label]
Using t("phone_number") ensures consistency in labeling across locales.


159-159: [Localize "More Details" Button Label]
Switching to t("more_details") is a good follow-up for complete translation coverage.

src/pages/Organization/components/EditUserRoleSheet.tsx (17)

3-3: [Import i18n Hook for Translations]
Introducing the useTranslation import is appropriate for localized strings in this component.


57-57: [Declare Translation Hook]
Defines t, enabling translation strings. Ensure all relevant text is wrapped with t(...).


75-75: [Status Toast Message i18n]
toast.success(t("user_role_update_success")) helps localize success feedback. Confirm the translation key is present in all required languages to avoid missing translations.


95-95: [User Removal Toast i18n]
toast.success(t("user_removed_success")) is consistent. Double-check if the user removal scenario has negative tests in place to confirm the error handling.


108-108: [Error Toast Localization]
toast.error(t("select_diff_role")) is correctly localized. Ensure tests cover this specific scenario of selecting the same role.


121-121: [Localize Edit Role Trigger]
{ t("edit_role") } ensures the button text is translatable.


125-125: [Localize Sheet Title]
<SheetTitle>{t("edit_user_role")}</SheetTitle> aligns the heading with the new translation approach.


150-150: [Localize "Username"]
{t("username")}—this is straightforward. Confirm the correct string is used in non-English locales.


154-156: [Localize "Current Role"]
{t("current_role")} ensures the property reflection is localized.


160-163: [Show Last Login with Status Indicator]
Replacing a textual last login with the UserStatusIndicator clarifies the user's online/offline or last-seen status. This is a cohesive approach used across the codebase.


169-171: [Localize Select Role Prompt]
{t("select_new_role")} and the placeholder {t("select_role")} guarantee the new role selection stays consistent with your localization.


199-199: [Localize Update Role Button]
Ensure "update_role" is tested. The button label is part of the critical user flow.


205-205: [Localize Remove User Button]
{t("remove_user")}—consistent with the action’s meaning.


211-211: [Localize Remove Dialog Title]
{t("remove_user_organization")} clarifies the remove action context in multi-lingual environments.


214-215: [Warn Before Removing User]
${t("remove_user_warn_1")} ... {t("remove_user_warn_2")} properly localizes the cautionary statement. Check for placeholders if the text needs to be combined in i18n strings for grammar nuances in certain languages.


219-219: [Localize Dialog Cancel Button]
{t("cancel")} is consistent.


224-224: [Localize Dialog Confirm Button]
{t("remove")} is consistent with the remove action.

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

3-3: [Add i18n Hook for Facility Organization]
useTranslation import ensures that this component can properly localize strings.


35-35: [Centralize User Status]
UserStatusIndicator usage unifies status display with the organization pages. This fosters consistency.


58-58: [Initialize Translation Hook for Roles]
const { t } = useTranslation(); sets up translation usage across success/error notifications.


80-80: [Localize Update Role Success Message]
toast.success(t("user_role_update_success")) preserves user engagement with a localized success message.


104-104: [Localize User Removal Success Message]
toast.success(t("user_removed_success")) is consistent with the approach in other components.


117-117: [Localize Error Toast]
toast.error(t("select_diff_role")) covers the scenario of re-selecting the same role.


130-130: [Localize Default Trigger Text]
{t("edit_role")} ensures text within the facility organization also follows the new i18n standard.


134-136: [Sheet Title and Description Localization]
{t("edit_user_role")} and {t("update_user_role_organization")} improve clarity for various locales.


159-159: [Localize Username Label]
{t("username")}—makes the label consistent with the rest of the app.


163-165: [Localize Current Role Label]
Transitioning from hardcoded text to t("current_role") is consistent with the i18n approach.


177-179: [Localize New Role Prompt]
{t("select_new_role")} and placeholder {t("select_role")} unify the user role selection across multiple facility-level contexts.


207-207: [Localize Update Role Button]
{t("update_role")} is consistent with the standard for these forms.


213-213: [Localize Remove User Button]
{t("remove_user")}—ensures uniformity across the entire application.


219-219: [Localize Remove User Organization Title]
{t("remove_user_organization")} clarifies the intent in a multi-lingual environment.


222-223: [Localize Combined Warning Text]
Similar to the EditUserRoleSheet, verify that the concatenation of t("remove_user_warn_1") and t("remove_user_warn_2") works as intended in all target languages.


227-227: [Localize Cancel Button]
{t("cancel")} is consistent.


232-232: [Localize Final Remove Button]
{t("remove")} keeps language usage consistent.

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

1-1: [Import Day.js for Last Login Calculations]
The addition of dayjs enables robust date/time calculations for the user’s last login status. Confirm that dayjs is in your dependencies.


8-9: [Use Existing Badge Component]
Replacing inline or custom status styling with the Badge component ensures consistent visuals for status indicators.


20-20: [Utility Methods for UserStatus]
formatName and isUserOnline provide a clean abstraction. Verify isUserOnline uses the correct threshold for user inactivity.


66-66: [Redefined getNameAndStatusCard Signature]
Removing the cur_online parameter simplifies usage. Ensure all calling sites are updated accordingly.


75-75: [Inline Status Indicator]
Embedding <UserStatusIndicator user={user} /> within the card layout clarifies the user’s current state visually.


170-170: [Conditional Rendering for Different Screen Sizes]
getNameAndStatusCard(user, !isLessThanXLargeScreen) is a neat approach to adapt the UI. Confirm it results in an expected layout on all breakpoints.


309-309: [Localize Tab "Card" Label]
<span>{t("card")}</span> ensures the tab label is translatable.


319-319: [Localize Tab "List" Label]
<span>{t("list")}</span> is consistent with the rest of the i18n tab usage.


342-342: [Localize "No Users Found"]
Switching to t("no_users_found") ensures that the empty state message is translatable.

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

3-3: LGTM! Import statements are well-organized.

The new imports for internationalization and the UserStatusIndicator component are properly organized and align with the PR's objective.

Also applies to: 11-11


32-32: LGTM! Proper i18n initialization.

The useTranslation hook is correctly initialized and the t function is consistently used throughout the component.


75-75: Verify translation keys in locale files.

Please ensure that all translation keys are defined in the locale files:

  • users
  • no_users_found
  • role
  • phone_number
  • more_details

Also applies to: 102-102, 134-134, 140-140, 162-162

@github-actions github-actions bot removed the merge conflict pull requests with merge conflict label Jan 6, 2025
src/pages/Organization/components/EditUserRoleSheet.tsx Outdated Show resolved Hide resolved
src/components/Users/UserListAndCard.tsx Outdated Show resolved Hide resolved
public/locale/en.json Outdated Show resolved Hide resolved
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 (2)
src/components/Users/UserListAndCard.tsx (2)

102-104: Enhance date localization in the title attribute.

The title attribute should use a localized date format for better internationalization support.

-      title={`${new Date(user.last_login).toLocaleString()}`}
+      title={new Date(user.last_login).toLocaleDateString(undefined, {
+        year: 'numeric',
+        month: 'long',
+        day: 'numeric',
+        hour: '2-digit',
+        minute: '2-digit'
+      })}

107-122: Improve accessibility and maintainability of status indicators.

Consider the following improvements:

  1. Add aria-label for screen readers
  2. Move color classes to Badge variants for better maintainability
-        <Badge variant="secondary" className="bg-green-100 whitespace-nowrap">
+        <Badge 
+          variant="online" 
+          className="whitespace-nowrap"
+          aria-label={t("user_status_online")}
+        >

You'll need to define these variants in your Badge component:

// in Badge.tsx
const variants = {
  online: "bg-green-100",
  away: "bg-yellow-100",
  offline: "bg-gray-100",
  // ... other variants
}
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 747d6b0 and 3f6ce52.

📒 Files selected for processing (5)
  • public/locale/en.json (11 hunks)
  • src/components/Users/UserListAndCard.tsx (9 hunks)
  • src/pages/FacilityOrganization/FacilityOrganizationUsers.tsx (6 hunks)
  • src/pages/FacilityOrganization/components/EditFacilityUserRoleSheet.tsx (10 hunks)
  • src/pages/Organization/components/EditUserRoleSheet.tsx (10 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
  • src/pages/FacilityOrganization/components/EditFacilityUserRoleSheet.tsx
  • src/pages/FacilityOrganization/FacilityOrganizationUsers.tsx
  • src/pages/Organization/components/EditUserRoleSheet.tsx
  • public/locale/en.json
🔇 Additional comments (4)
src/components/Users/UserListAndCard.tsx (4)

7-7: LGTM! Good use of existing utilities.

The imports are appropriate for the changes, and I appreciate that you're using the existing relativeTime utility as suggested in previous reviews.

Also applies to: 19-19


65-65: LGTM! Good separation of concerns.

The removal of the cur_online parameter and delegation to UserStatusIndicator improves code organization and maintainability.

Also applies to: 74-74


295-295: LGTM! Good internationalization coverage.

All user-facing strings are properly internationalized using the translation function.

Also applies to: 305-305, 328-328


106-123: Verify the status indicator states match the requirements.

The implementation handles all user states appropriately:

  • Online: Current user or recently active users
  • Away: Users with last login timestamp
  • Offline: Users who never logged in

Please verify that these states align with the product requirements from issue #9726.

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 (5)
public/locale/en.json (5)

357-357: Consider using i18next time formatting

The keys "ago" and "last_seen" are used for displaying time-based information. Consider using i18next's built-in date/time formatting features instead of concatenating strings.

-  "ago": "ago",
-  "last_seen": "Last seen",
+  // Remove these keys and use i18next's built-in date formatting:
+  // t('{{date, ago}}') or t('{{date, fromNow}}')

Reference: https://www.i18next.com/translation-function/formatting#date-formatting

Also applies to: 1112-1118


487-487: Clarify the context for the generic "card" key

The key "card" seems too generic and might lead to confusion. Consider using a more specific key name that indicates its context and usage.

-  "card": "Card",
+  "user_card": "Card",  // if used in user context
+  "facility_card": "Card",  // if used in facility context

657-657: Ensure consistent casing in role management keys

The role management related keys follow a good naming pattern. However, some keys use different casing styles (e.g., "current_role" vs "userRole").

Consider standardizing the casing:

   "current_role": "Current Role",
   "edit_role": "Edit Role",
   "edit_user_role": "Edit User Role",
   "select_diff_role": "Please select a different role",
   "select_facility": "Select Facility",
   "select_new_role": "Select New Role",
   "update_role": "Update Role",
   "update_user_role_organization": "Update the role for this user in the organization",

Also applies to: 764-766, 1636-1638, 1646-1646, 1832-1836


1539-1540: Add placeholder markers in user removal messages

The user removal confirmation message contains hardcoded placeholders. Consider using i18next's standardized placeholder syntax.

-  "remove_user_warn": "Are you sure you want to remove {{firstName}} {{lastName}} from this organization? This action cannot be undone.",
+  "remove_user_warn": "Are you sure you want to remove %(firstName)s %(lastName)s from this organization? This action cannot be undone.",

Reference: https://www.i18next.com/translation-function/formatting#string-formatting


1866-1867: Consider adding more context to success messages

The success messages for user operations are good but could be more specific about what role or organization was involved.

-  "user_removed_success": "User removed from organization successfully",
-  "user_role_update_success": "User role updated successfully",
+  "user_removed_success": "User removed from {{organizationName}} successfully",
+  "user_role_update_success": "User role updated to {{roleName}} successfully",
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 3f6ce52 and feddb1c.

📒 Files selected for processing (1)
  • public/locale/en.json (11 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: cypress-run (1)

Copy link
Contributor

@Jacobjeevan Jacobjeevan left a comment

Choose a reason for hiding this comment

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

Conditionally approving.

LGTM

src/components/Users/UserListAndCard.tsx Outdated Show resolved Hide resolved
Copy link

github-actions bot commented Jan 8, 2025

👋 Hi, @JavidSumra,
Conflicts have been detected against the base branch. Please rebase your branch against the base branch.


This message is automatically generated by prince-chrismc/label-merge-conflicts-action so don't hesitate to report issues/improvements there.

@github-actions github-actions bot added the merge conflict pull requests with merge conflict label Jan 8, 2025
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 comments (1)
src/components/Users/UserListAndCard.tsx (1)

Line range hint 92-101: Fix type definition inconsistency in UserStatusIndicator.

The className prop is defined in the type but not used in the function parameters. This could lead to TypeScript errors.

Apply this diff to fix the inconsistency:

export const UserStatusIndicator = ({
  user,
  addPadding = false,
}: {
  user: UserBase;
-  className?: string;
  addPadding?: boolean;
}) => {
🧹 Nitpick comments (2)
public/locale/en.json (1)

357-357: Consider implementing plural forms for time-based translations.

The "ago" translation should follow i18next plural guidelines to handle different time units correctly.

Consider implementing plural forms like this:

-  "ago": "ago",
+  "ago_one": "{{count}} {{unit}} ago",
+  "ago_other": "{{count}} {{unit}}s ago"

This allows for proper pluralization: "1 minute ago" vs "2 minutes ago".

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

102-124: Improve date format in the title attribute.

While the status indicator implementation looks good, the raw date string in the title attribute could be formatted for better readability.

Apply this diff to improve the date format:

-      title={`${new Date(user.last_login).toLocaleString()}`}
+      title={new Date(user.last_login).toLocaleDateString(undefined, {
+        weekday: 'long',
+        year: 'numeric',
+        month: 'long',
+        day: 'numeric',
+        hour: '2-digit',
+        minute: '2-digit'
+      })}
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between feddb1c and c1fdfe4.

📒 Files selected for processing (2)
  • public/locale/en.json (11 hunks)
  • src/components/Users/UserListAndCard.tsx (9 hunks)
🔇 Additional comments (5)
public/locale/en.json (1)

487-487: LGTM! The new translations follow i18n best practices.

The added translations:

  • Follow consistent naming conventions
  • Use proper capitalization for UI display
  • Correctly implement template variables where needed

Also applies to: 657-657, 1113-1113, 1539-1540, 1636-1636, 1638-1638

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

7-7: LGTM! Import changes are well-aligned with the implementation.

The addition of the Badge component and relativeTime util follows the recommendations from previous reviews.

Also applies to: 19-19


65-65: LGTM! Function signature update for getNameAndStatusCard.

The removal of the cur_online parameter simplifies the interface as the online status is now handled within the UserStatusIndicator component.

Also applies to: 91-91


295-295: LGTM! Comprehensive i18n implementation.

All user-facing strings have been properly internationalized using consistent translation keys.

Also applies to: 305-305, 328-328


74-74: Verify consistent usage of UserStatusIndicator across the codebase.

The implementation looks good, but let's verify that all instances of user status display have been updated to use this component.

Run this script to check for any remaining direct Badge usage for user status:

Also applies to: 74-74

✅ Verification successful

Implementation is consistent across the codebase

The UserStatusIndicator component is properly used in all relevant locations where user status is displayed. No legacy Badge implementations for user status were found.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for direct Badge usage with online/offline related text
rg -l "Badge.*online|Badge.*offline" --type ts --type tsx

# Search for UserStatusIndicator usage
rg -l "UserStatusIndicator" --type ts --type tsx

Length of output: 164


Script:

#!/bin/bash
# Search for Badge usage with online/offline context
rg -A 3 "Badge.*(?i:online|offline)" "*.{ts,tsx}"

# Search for UserStatusIndicator usage
rg -A 2 "UserStatusIndicator" "*.{ts,tsx}"

# Also search for any status-related Badge components
rg -A 3 "Badge.*status" "*.{ts,tsx}"

Length of output: 286


Script:

#!/bin/bash
# Search for Badge usage with online/offline context
rg -A 3 '<Badge.*(?i:online|offline)'

# Search for UserStatusIndicator component usage
rg -A 2 '<UserStatusIndicator'

# Search for status-related Badge components
rg -A 3 '<Badge.*status'

Length of output: 3063

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 (2)
src/components/Users/UserListAndCard.tsx (1)

103-105: Consider formatting the hover timestamp.

The raw timestamp in the title attribute could be more user-friendly.

-      title={`${new Date(user.last_login).toLocaleString()}`}
+      title={new Date(user.last_login).toLocaleDateString(undefined, {
+        weekday: 'long',
+        year: 'numeric',
+        month: 'long',
+        day: 'numeric',
+        hour: '2-digit',
+        minute: '2-digit'
+      })}
public/locale/en.json (1)

659-659: Consider adding plural forms for role-related translations

The role-related translations should follow i18next plural guidelines as mentioned in the past review comments.

Consider updating the translations to support plural forms:

-  "current_role": "Current Role",
+  "current_role_one": "Current Role",
+  "current_role_other": "Current Roles",

Also applies to: 767-769

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between c1fdfe4 and 06b5c15.

📒 Files selected for processing (2)
  • public/locale/en.json (11 hunks)
  • src/components/Users/UserListAndCard.tsx (9 hunks)
🔇 Additional comments (9)
src/components/Users/UserListAndCard.tsx (4)

7-7: LGTM! Good use of existing utilities.

The imports are well-organized, and I appreciate the reuse of the existing relativeTime utility as suggested in the previous review.

Also applies to: 19-19


107-124: Well-structured status indicator implementation!

The Badge-based status indicators are well-implemented with:

  • Clear visual states (green/yellow/gray)
  • Consistent structure across all states
  • Proper i18n support
  • Responsive to the previous review feedback about removing "last seen" text

65-65: Good function signature simplification!

The removal of the cur_online parameter and integration with the new UserStatusIndicator component improves code maintainability.

Also applies to: 74-74


296-296: Complete i18n implementation!

All user-facing strings have been properly internationalized using the translation function.

Also applies to: 306-306, 329-329

public/locale/en.json (5)

357-357: LGTM: Time-related translation key

The translation key "ago": "ago" follows the common pattern for time-related suffixes.


488-488: LGTM: UI element translation key

The translation key "card": "Card" follows proper capitalization for UI elements.


1117-1117: LGTM: User activity translations

The translations for user activity status ("last_login" and "never_logged_in") are consistent and properly formatted.

Also applies to: 1231-1231


1544-1545: Verify string interpolation in warning message

The warning message uses proper string interpolation with {{firstName}} and {{lastName}} variables.

Let's verify that these variables are properly passed from the code:

✅ Verification successful

String interpolation verified successfully

The warning message variables are properly passed from both EditUserRoleSheet and EditFacilityUserRoleSheet components, with correct mapping of first_name and last_name to the translation placeholders.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for usage of the translation key to verify variable passing
rg "remove_user_warn" -A 3

Length of output: 1285


1642-1644: Ensure consistency in role-related messages

The role update messages maintain consistency in terminology using "role" and proper sentence casing.

Let's verify the consistency of role-related messages across the codebase:

Also applies to: 1652-1652, 1838-1838, 1842-1842, 1872-1873

✅ Verification successful

Role-related messages maintain consistent terminology and casing

All role-related messages in the codebase consistently use:

  • The term "role" throughout
  • Proper sentence casing for all words
  • Clear, action-oriented phrasing
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for all role-related translation keys to verify consistency
rg '"select_.*role"|"update_.*role"|"edit_.*role"'

Length of output: 1883

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge conflict pull requests with merge conflict needs testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

User List in Organization Displays Incorrect Online Status for All Users
4 participants