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

Care Loading icon in organization and facility users #9723

Merged
merged 12 commits into from
Jan 5, 2025

Conversation

Rishith25
Copy link
Contributor

@Rishith25 Rishith25 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

  • New Features

    • Enhanced loading states with more detailed and visually appealing skeleton screens.
    • Improved loading experience across multiple components.
    • Added dynamic translation for various text elements, enhancing localization support.
  • UI Improvements

    • Added more sophisticated loading placeholders with animated elements.
    • Refined visual feedback during data fetching.
    • Updated loading screen layouts to include additional loading indicators and improved structure.
    • Changed loading state titles for better consistency and clarity.

@Rishith25 Rishith25 requested a review from a team as a code owner January 4, 2025 04:17
Copy link
Contributor

coderabbitai bot commented Jan 4, 2025

Warning

Rate limit exceeded

@Rishith25 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 7 minutes and 54 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 5383c9f and 8a9d0aa.

📒 Files selected for processing (2)
  • public/locale/en.json (2 hunks)
  • src/pages/FacilityOrganization/FacilityOrganizationIndex.tsx (5 hunks)

Walkthrough

The pull request focuses on enhancing the loading experience across multiple components by replacing simple loading text with more sophisticated loading skeletons. The changes primarily affect three components: FacilityUsers, OrganizationLayout, and FacilityOrganizationIndex. Each component now utilizes visually appealing and animated placeholder elements to indicate loading states, incorporating Card, CardContent, and Skeleton components styled with Tailwind CSS classes for a more refined loading representation. Additionally, localization support has been improved with new keys added to the English locale file.

Changes

File Change Summary
src/components/Facility/FacilityUsers.tsx Added Card, CardContent, and Skeleton imports; replaced simple loading text with a complex loading skeleton using animated placeholder elements.
src/pages/Organization/components/OrganizationLayout.tsx Added useTranslation, Card, CardContent, and Skeleton imports; enhanced loading state with animated placeholder elements and updated error handling for organization not found.
src/pages/FacilityOrganization/FacilityOrganizationIndex.tsx Updated loading state to display six cards with refined skeleton elements; changed title from "Organizations" to "Facility Organizations" and added translation support.
public/locale/en.json Added new localization keys for organizational management and user access.

Assessment against linked issues

Objective Addressed Explanation
Replace loading text with care loading icon [#9714]

Possibly related PRs

Suggested labels

tested, needs review

Suggested reviewers

  • rithviknishad
  • bodhish
  • Jacobjeevan

Poem

🐰 Loading, loading, oh so bright,
Skeleton cards dance with delight!
No more text that simply waits,
Animated placeholders seal our fates.
A rabbit's touch of UI grace! 🎨


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 8a9d0aa
🔍 Latest deploy log https://app.netlify.com/sites/care-ohc/deploys/677ad3c913d7960008a7bbf3
😎 Deploy Preview https://deploy-preview-9723--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.

@bodhish
Copy link
Member

bodhish commented Jan 4, 2025

Use skelton loading for loading instead of using the care logo one;

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/Facility/FacilityUsers.tsx (1)

35-77: Avoid repeated inline skeleton code across multiple components.
You’ve implemented a robust skeleton UI, but consider extracting this skeleton layout into a shared component to promote reusability and simplify maintenance.

src/pages/Organization/components/OrganizationLayout.tsx (1)

80-116: Leverage a unified skeleton component to reduce duplication.
The inline skeleton code is well-structured but repeated patterns in multiple files can be centralized into a shared skeleton component for better maintainability and consistency.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 927969e and 0d7d20f.

📒 Files selected for processing (3)
  • src/components/Facility/FacilityUsers.tsx (2 hunks)
  • src/pages/FacilityOrganization/FacilityOrganizationIndex.tsx (1 hunks)
  • src/pages/Organization/components/OrganizationLayout.tsx (2 hunks)
🔇 Additional comments (3)
src/pages/FacilityOrganization/FacilityOrganizationIndex.tsx (1)

39-60: Use of skeleton UI is consistent and clear.
The loading skeleton placeholders are well-structured, and the use of Array.from({ length: 6 }) to render multiple cards seems appropriate for providing a fluid user experience during data fetching.

src/components/Facility/FacilityUsers.tsx (1)

15-15: Check import path consistency.
This new import statement for Card and CardContent is correct, but ensure it remains consistent with other UI components across the codebase.

src/pages/Organization/components/OrganizationLayout.tsx (1)

13-13: Correct import usage for new loading skeleton approach.
The import path for Card and CardContent aligns with the updated skeleton-based loading pattern introduced in multiple files.

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.

instead of reinventing things, let's use shadcn's skeleton instead

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

Line range hint 141-150: Add missing key prop to fragment in map function.

The fragment within the map function is missing a key prop, which could cause React warnings about unique keys.

Apply this fix:

- <>
+ <React.Fragment key={`parent-group-${parent.id}`}>
    <BreadcrumbItem key={parent.id}>
      <BreadcrumbLink href={`${baseUrl}/${parent.id}`}>
        {parent.name}
      </BreadcrumbLink>
    </BreadcrumbItem>
    <BreadcrumbItem key={`ellipsis-${parent.id}`}>
      <BreadcrumbSeparator />
    </BreadcrumbItem>
- </>
+ </React.Fragment>
🧹 Nitpick comments (2)
src/components/Facility/FacilityUsers.tsx (1)

36-78: Great implementation of skeleton loading state!

The skeleton loader implementation is well-structured and provides an excellent visual representation of the loading state. The layout closely mirrors the actual content structure, which will create a smooth transition when data loads.

Positive aspects:

  • Responsive grid layout using Tailwind classes
  • Proper spacing and hierarchy in the skeleton UI
  • Consistent use of skeleton sizes matching content

Consider extracting this skeleton loader into a separate component if it's used across multiple pages, promoting reusability and maintainability.

src/pages/Organization/components/OrganizationLayout.tsx (1)

81-113: Great implementation of skeleton loading state with minor improvements needed.

The skeleton loader implementation effectively represents the loading state with a well-structured layout. However, there are a couple of improvements needed:

  1. The fragment within the map function in the breadcrumb section (line 141-150) is missing a key prop, which could cause React warnings.
  2. Consider extracting the skeleton card structure into a shared component since it's similar to the one in FacilityUsers.tsx.

Extract the repeated skeleton card structure into a shared component:

// src/components/Common/SkeletonCard.tsx
export const SkeletonCard = () => (
  <Card>
    <CardContent className="p-6">
      <div className="flex space-x-4">
        <div className="flex-1 space-y-4">
          <Skeleton className="h-6 w-1/2" />
          <div className="flex space-x-4">
            <Skeleton className="h-4 w-1/3" />
            <Skeleton className="h-4 w-1/3" />
          </div>
        </div>
        <div className="flex-1 flex items-center justify-center">
          <Skeleton className="h-6 w-1/2" />
        </div>
      </div>
    </CardContent>
  </Card>
);

Then use it in both components:

- <Card key={i}>
-   <CardContent className="p-6">
-     {/* ... skeleton structure ... */}
-   </CardContent>
- </Card>
+ <SkeletonCard key={i} />
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between a1688f8 and 3e52ea6.

📒 Files selected for processing (3)
  • src/components/Facility/FacilityUsers.tsx (2 hunks)
  • src/pages/FacilityOrganization/FacilityOrganizationIndex.tsx (1 hunks)
  • src/pages/Organization/components/OrganizationLayout.tsx (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/pages/FacilityOrganization/FacilityOrganizationIndex.tsx
🔇 Additional comments (2)
src/components/Facility/FacilityUsers.tsx (1)

15-16: LGTM! Clean imports added for new UI components.

The new imports are properly organized and use relative paths correctly.

src/pages/Organization/components/OrganizationLayout.tsx (1)

13-13: LGTM! Clean imports added for UI components.

The new imports are properly organized using absolute paths, consistent with the project structure.

Also applies to: 15-15

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/Facility/FacilityUsers.tsx (2)

53-76: Consider adding aria attributes for accessibility

While the skeleton UI looks great, it's important to ensure it's accessible to screen readers.

Add appropriate ARIA attributes to improve accessibility:

-        <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-2 gap-4">
+        <div 
+          className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-2 gap-4"
+          role="status"
+          aria-label={t("loading_users")}
+        >
           {Array.from({ length: 6 }).map((_, i) => (
-            <Card key={i}>
+            <Card key={i} aria-hidden="true">

54-54: Consider memoizing the skeleton array

The array creation in the map function could be moved outside the component to avoid unnecessary recreations during renders.

+const SKELETON_ARRAY = Array.from({ length: 6 });
+
 export default function FacilityUsers(props: { facilityId: number }) {
   // ...
-          {Array.from({ length: 6 }).map((_, i) => (
+          {SKELETON_ARRAY.map((_, i) => (
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 3e52ea6 and 02621fb.

📒 Files selected for processing (1)
  • src/components/Facility/FacilityUsers.tsx (2 hunks)
🔇 Additional comments (2)
src/components/Facility/FacilityUsers.tsx (2)

7-8: LGTM! Proper use of absolute imports

The new imports follow the recommended pattern of using absolute imports and are organized logically.


36-78: Great implementation of skeleton loading!

The skeleton loading implementation provides an excellent visual representation of the content structure, which is a significant improvement over a simple loading icon. This aligns well with the suggestion from the PR comments and follows modern UX patterns.

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.

changes for the issue lgtm, but merge checklist not followed.
add i18n for all texts in the files that were changed

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

83-115: Consider using constants for skeleton counts.

The skeleton loading UI is well-implemented, but the magic numbers (6 cards, 4 navigation items) should be extracted into named constants for better maintainability.

+const SKELETON_NAVIGATION_ITEMS = 4;
+const SKELETON_CARDS = 6;

 if (isLoading) {
   return (
     <div className="p-4">
       <Skeleton className="h-8 w-48 mb-4" />
       <Skeleton className="h-4 w-24 mb-4" />
       <div className="flex space-x-4 mb-4">
-        {[...Array(4)].map((_, index) => (
+        {[...Array(SKELETON_NAVIGATION_ITEMS)].map((_, index) => (
           <Skeleton key={index} className="h-8 w-24" />
         ))}
       </div>
       <Skeleton className="h-6 w-40 mb-4" />
       <Skeleton className="h-8 w-1/4 mb-4" />
       <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
-        {Array.from({ length: 6 }).map((_, i) => (
+        {Array.from({ length: SKELETON_CARDS }).map((_, i) => (
           <Card key={i}>
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 02621fb and 90482ce.

📒 Files selected for processing (3)
  • public/locale/en.json (1 hunks)
  • src/pages/FacilityOrganization/FacilityOrganizationIndex.tsx (5 hunks)
  • src/pages/Organization/components/OrganizationLayout.tsx (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/pages/FacilityOrganization/FacilityOrganizationIndex.tsx
🔇 Additional comments (4)
src/pages/Organization/components/OrganizationLayout.tsx (3)

3-3: LGTM! Clean import organization.

The new imports are well-organized and properly grouped with related components.

Also applies to: 14-14, 16-16


46-46: LGTM! Proper i18n hook usage.

The translation hook is correctly initialized at the component level.


119-119: LGTM! Proper i18n implementation for error message.

The error message is correctly internationalized using the translation function.

public/locale/en.json (1)

1298-1303: LGTM! Well-structured translation keys.

The new organization-related translation keys are:

  • Consistently named following the established pattern
  • Provide clear and meaningful messages
  • Cover all necessary UI text from the component changes

@Rishith25
Copy link
Contributor Author

@rithviknishad Can you assign story points for this

@rithviknishad
Copy link
Member

resolve conflicts btw

@Rishith25
Copy link
Contributor Author

@rithviknishad Resolved the merge conflicts

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

1299-1304: LGTM with minor suggestions for consistency!

The new organization-related translations are well-written and informative. Consider these minor improvements for consistency:

  1. Make organization_facility more descriptive, e.g., "Facility Organization Management" instead of "Facility Organizations"
  2. Add a period to organization_not_found to match other similar messages, i.e., "No Organizations Found."
-  "organization_facility": "Facility Organizations",
+  "organization_facility": "Facility Organization Management",
-  "organization_not_found": "No Organizations Found",
+  "organization_not_found": "No Organizations Found.",
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 90482ce and 5383c9f.

📒 Files selected for processing (3)
  • public/locale/en.json (1 hunks)
  • src/pages/FacilityOrganization/FacilityOrganizationIndex.tsx (5 hunks)
  • src/pages/Organization/components/OrganizationLayout.tsx (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/pages/FacilityOrganization/FacilityOrganizationIndex.tsx
  • src/pages/Organization/components/OrganizationLayout.tsx

public/locale/en.json Outdated Show resolved Hide resolved
public/locale/en.json Outdated Show resolved Hide resolved
public/locale/en.json Outdated Show resolved Hide resolved
@rithviknishad rithviknishad merged commit f1d433b into ohcnetwork:develop Jan 5, 2025
16 of 17 checks passed
Copy link

github-actions bot commented Jan 5, 2025

@Rishith25 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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Replace loading text with care loading icon
3 participants