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: Redesign the Open view of Department/Teams #10558

Merged

Conversation

abhimanyurajeesh
Copy link
Contributor

@abhimanyurajeesh abhimanyurajeesh commented Feb 11, 2025

Proposed Changes

Redesigned

image

Summary by CodeRabbit

  • New Features

    • Expanded facility organization categorization with additional type options.
    • Enhanced organization listings with a card-style display that highlights key details.
    • Improved the search interface by adding an icon and updating placeholder text for clarity.
    • Redesigned navigation with a breadcrumb system and tabbed layout for easier browsing.
    • Added dynamic localization for navigation items and messages.
  • Bug Fixes

    • Adjusted sorting behavior for improved user experience.
  • Refactor

    • Restructured components for better modularity and layout alignment.

@abhimanyurajeesh abhimanyurajeesh requested a review from a team as a code owner February 11, 2025 12:46
Copy link
Contributor

coderabbitai bot commented Feb 11, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

This pull request updates localization and reorganizes UI components for facility organization views. In the localization file, four new keys are added, and an existing sorting key is modified. The Facility Organization view now uses a new OrganizationCard component to display organization details. The layout component is refactored to use translation and history hooks with a revamped navigation structure, replacing breadcrumbs and a menubar with a tabbed navigation system.

Changes

File(s) Change Summary
public/locale/en.json Added new keys: facility_organization_type__dept, facility_organization_type__other, facility_organization_type__root, and facility_organization_type__team; modified SORT_OPTIONS key to remove the leading minus sign; added search_by_department_team_name and see_details keys.
src/pages/Facility/settings/organizations/FacilityOrganizationView.tsx Introduced new OrganizationCard component to modularize organization rendering; replaced inline logic with mapped components; updated pagination logic and enhanced the search input with an icon and new placeholder text.
src/pages/Facility/settings/organizations/components/FacilityOrganizationLayout.tsx Integrated useTranslation hook; updated NavItem interface (switching icon to value); replaced Menubar with a Breadcrumb component; introduced a tabbed navigation system for better user interaction.

Possibly related PRs

Suggested labels

changes required

Suggested reviewers

  • rithviknishad

Poem

I hopped through lines of code at dawn,
Adding keys for departments and teams drawn.
With OrganizationCards that shine so bright,
And tabs that guide the user’s sight.
I twitch my nose in pure delight—
This rabbit’s cheer makes code just right! 🐇
Happy hopping through the changes!


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 1347075 and ef48341.

📒 Files selected for processing (2)
  • public/locale/en.json (4 hunks)
  • src/pages/Facility/settings/organizations/FacilityOrganizationView.tsx (4 hunks)

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 Feb 11, 2025

Deploy Preview for care-ohc ready!

Name Link
🔨 Latest commit ef48341
🔍 Latest deploy log https://app.netlify.com/sites/care-ohc/deploys/67adbb3413d32800084e2478
😎 Deploy Preview https://deploy-preview-10558.preview.ohc.network
📱 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 (7)
src/pages/Facility/settings/organizations/components/FacilityOrganizationLayout.tsx (5)

53-54: Localize the titles if needed.

“Departments/Teams” and “Users” are hardcoded. If these labels need to be localized, consider using the translation function.

Also applies to: 59-59


100-110: Add type="button" to the go-back button.

Without specifying type="button", the default behavior can be type="submit" in form contexts. This is a minor improvement for clarity.

 <button
+  type="button"
   onClick={() => goBack()}
   className="mt-1 hover:underline"
   aria-label="Go back"
 >

111-127: Avoid potential side effects of reverse().

reverse() mutates the array in place. Consider using [...orgParents].reverse() to keep orgParents intact if needed elsewhere.

-{orgParents.reverse().map((parent) => (
+[...orgParents].reverse().map((parent) => (

129-140: Use fallback for unknown organization types.

When displaying {t(\facility_organization_type__${org.org_type}`)}, add a fallback for unrecognized org_type` keys to prevent undefined translations.


141-167: Remove one of the conflicting props on Tabs.

Defining both defaultValue and value can be redundant if you’re fully controlling the Tabs with value.

src/pages/Facility/settings/organizations/FacilityOrganizationView.tsx (2)

28-33: Consider typing org_type as an enum or union.

Defining org_type as a union type or enum can help catch invalid values at compile time.


35-92: Optimize sub-organization count retrieval.

Using limit: 1 to fetch only the count is clever, but consider a dedicated endpoint or HEAD request if performance is a concern. Also, “Department inside” / “Team inside” are partially untranslated strings.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between af4e4c1 and 07d7764.

📒 Files selected for processing (3)
  • public/locale/en.json (3 hunks)
  • src/pages/Facility/settings/organizations/FacilityOrganizationView.tsx (5 hunks)
  • src/pages/Facility/settings/organizations/components/FacilityOrganizationLayout.tsx (5 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Test
  • GitHub Check: cypress-run (1)
🔇 Additional comments (14)
src/pages/Facility/settings/organizations/components/FacilityOrganizationLayout.tsx (5)

3-3: Imports look good.

These newly introduced imports and references are straightforward and appear to be used correctly.

Also applies to: 5-5, 7-7, 15-15, 20-20


37-37: Double-check references from icon to value.

Ensure all components referencing the old icon property are updated to use the new value string property to prevent runtime issues.


47-48: Usage of translation and custom navigation is fine.

The integration of useTranslation for localization and useAppHistory for navigation is implemented correctly.


63-64: Good approach to default the active tab.

The logic cleanly defaults to "departments" if the current path is not found in navItems.


85-85: No meaningful changes detected.

src/pages/Facility/settings/organizations/FacilityOrganizationView.tsx (8)

15-15: Imports look consistent.


94-94: Export signature is reasonable.


95-99: Mismatch between limit: 15 and limit = 12.

Using two different limits (15 in useFilters, 12 in local variable) could cause confusion in pagination or unexpected data size. Verify the intended approach.


129-130: Minor spacing style.


131-146: Search input approach looks good.

The placeholder is translated. Changes to searchQuery are tracked properly, resetting the page for new searches.


163-163: Structural enhancement.

This additional div wrapper organizes the layout more clearly.


166-170: Use of OrganizationCard is consistent.


182-182: Pagination usage is aligned with the rest of the structure.

public/locale/en.json (1)

996-999: New and modified keys are aligned with code usage.

These translations match the dynamic keys and search placeholders used in the components.

Also applies to: 1890-1890, 1919-1919

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 (6)
src/pages/Facility/settings/organizations/FacilityOrganizationView.tsx (3)

28-33: Consider using a union type for org_type.

The org_type field could be more strictly typed using a union type to prevent invalid values.

-  org_type: string;
+  org_type: 'dept' | 'team';

35-35: Remove unused facilityId prop.

The facilityId prop is destructured but never used in the component.

-function OrganizationCard({ org }: { org: Organization; facilityId: string }) {
+function OrganizationCard({ org }: { org: Organization }) {

52-62: Remove commented code.

The commented badge code should be removed if it's no longer needed. If it's for future implementation, consider creating a TODO issue to track it.

src/pages/Facility/settings/organizations/components/FacilityOrganizationLayout.tsx (3)

90-97: Consider memoizing parent organization calculation.

The parent organization calculation could be memoized to prevent unnecessary recalculations on re-renders.

Consider using useMemo:

-  const orgParents: FacilityOrganizationParent[] = [];
-  let currentParent = org.parent;
-  while (currentParent) {
-    if (currentParent.id) {
-      orgParents.push(currentParent);
-    }
-    currentParent = currentParent.parent;
-  }
+  const orgParents = useMemo(() => {
+    const parents: FacilityOrganizationParent[] = [];
+    let currentParent = org.parent;
+    while (currentParent) {
+      if (currentParent.id) {
+        parents.push(currentParent);
+      }
+      currentParent = currentParent.parent;
+    }
+    return parents;
+  }, [org.parent]);

101-109: Enhance back button accessibility.

While the back button implementation is good, it could benefit from improved accessibility.

Consider these improvements:

-      <button
-        onClick={() => goBack()}
-        className="mt-1 hover:underline"
-        aria-label="Go back"
-      >
+      <button
+        onClick={() => goBack()}
+        className="mt-1 hover:underline inline-flex items-center gap-1"
+        aria-label="Go back to previous page"
+        type="button"
+      >

148-165: Enhance tab navigation accessibility.

The tab navigation could benefit from ARIA attributes for better screen reader support.

Consider these improvements:

       <Tabs
         defaultValue={currentTab}
         className="w-full mt-2"
         value={currentTab}
+        aria-label="Organization navigation"
       >
         <TabsList className="w-full justify-start border-b border-gray-300 bg-transparent p-0 h-auto rounded-none">
           {navItems.map((item) => (
             <Link key={item.path} href={item.path}>
               <TabsTrigger
                 value={item.value}
                 className="border-b-2 border-transparent px-2 py-2 text-gray-600 hover:text-gray-900 data-[state=active]:text-primary-800  data-[state=active]:border-primary-700 data-[state=active]:bg-transparent data-[state=active]:shadow-none rounded-none"
+                aria-label={`View ${item.title.toLowerCase()}`}
               >
                 {item.title}
               </TabsTrigger>
             </Link>
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 07d7764 and f84896b.

📒 Files selected for processing (2)
  • src/pages/Facility/settings/organizations/FacilityOrganizationView.tsx (5 hunks)
  • src/pages/Facility/settings/organizations/components/FacilityOrganizationLayout.tsx (5 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: Redirect rules - care-ohc
  • GitHub Check: Header rules - care-ohc
  • GitHub Check: Pages changed - care-ohc
  • GitHub Check: OSSAR-Scan
  • GitHub Check: cypress-run (1)
🔇 Additional comments (5)
src/pages/Facility/settings/organizations/FacilityOrganizationView.tsx (1)

77-83: Resolve inconsistent pagination limit values.

There are two different limit values being used:

  • useFilters hook uses a limit of 15
  • The component uses a hardcoded limit of 12 for the grid layout

Consider using a single consistent value or document why different values are needed.

src/pages/Facility/settings/organizations/components/FacilityOrganizationLayout.tsx (4)

35-39: LGTM! Interface update improves type safety.

The change from icon to value in the NavItem interface better represents the semantic meaning of the navigation items and aligns with the new tabbed navigation structure.


46-48: LGTM! Proper hook initialization.

The addition of translation and history hooks enhances the component's functionality with internationalization support and navigation capabilities.


50-64: Verify edge case handling in tab detection.

While the navigation setup looks good, consider what happens when the path doesn't match any navItem path. Currently, it defaults to "departments", but this might not always be the desired behavior.

Consider adding error boundaries or explicit handling for unknown paths:

-  const currentTab =
-    navItems.find((item) => item.path === path)?.value || "departments";
+  const currentTab = (() => {
+    const found = navItems.find((item) => item.path === path)?.value;
+    if (!found) {
+      console.warn(`No matching tab found for path: ${path}`);
+      return "departments";
+    }
+    return found;
+  })();

73-84: LGTM! Comprehensive loading state implementation.

The loading state provides good visual feedback with appropriate skeleton components and proper layout structure.

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

🧹 Nitpick comments (1)
src/pages/Facility/settings/organizations/components/FacilityOrganizationLayout.tsx (1)

103-110: Enhance back button accessibility.

While the back button has an aria-label, it should be wrapped in a proper semantic element for better accessibility.

-        <button
+        <button
+          type="button"
           onClick={() => goBack()}
-          className="mt-1 hover:underline"
+          className="mt-1 hover:underline inline-flex items-center gap-1"
           aria-label="Go back"
         >
           <CareIcon icon="l-arrow-left" className="h-4 w-4 text-gray-600" />
           <span className="text-sm text-gray-600">Back</span>
         </button>
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between f84896b and 00c41ed.

📒 Files selected for processing (1)
  • src/pages/Facility/settings/organizations/components/FacilityOrganizationLayout.tsx (5 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: Redirect rules - care-ohc
  • GitHub Check: Header rules - care-ohc
  • GitHub Check: Pages changed - care-ohc
  • GitHub Check: Test
  • GitHub Check: cypress-run (1)
  • GitHub Check: OSSAR-Scan
  • GitHub Check: CodeQL-Build
🔇 Additional comments (3)
src/pages/Facility/settings/organizations/components/FacilityOrganizationLayout.tsx (3)

1-40: LGTM! Well-organized imports and clean interface update.

The imports are logically grouped, and the NavItem interface update from icon to value aligns well with the new tabbed navigation approach.


47-66: LGTM! Clean hook implementation and navigation setup.

The translation and history hooks are well-integrated, and the navigation items are properly structured with a clean currentTab calculation that handles the default case.


154-171: LGTM! Clean tabbed navigation implementation.

The tabbed navigation is well-implemented with proper styling for active and hover states, and the Link wrapping of TabsTrigger provides good user experience.

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

Conflicts have been detected against the base branch. Please merge the base branch into your branch.
cc: @abhimanyurajeesh

See: https://docs.ohc.network/docs/contributing#how-to-resolve-merge-conflicts

@rithviknishad
Copy link
Member

@abhimanyurajeesh resolve conflicts as well; we've removed support for page level breadcrumbs;

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

♻️ Duplicate comments (1)
src/pages/Facility/settings/organizations/components/FacilityOrganizationLayout.tsx (1)

116-127: ⚠️ Potential issue

Fix key prop in breadcrumb mapping.

The fragment and breadcrumb items need proper key props to avoid React warnings and potential reconciliation issues.

-            {orgParents.reverse().map((parent) => (
-              <>
-                <BreadcrumbItem key={parent.id}>
+            {orgParents.reverse().map((parent) => (
+              <React.Fragment key={parent.id}>
+                <BreadcrumbItem>
                   <BreadcrumbLink>
                     <Link href={`${parent.id}`}>{parent.name}</Link>
                   </BreadcrumbLink>
                 </BreadcrumbItem>
-                <BreadcrumbItem key={`ellipsis-${parent.id}`}>
+                <BreadcrumbItem>
                   <BreadcrumbSeparator />
                 </BreadcrumbItem>
-              </>
+              </React.Fragment>
             ))}
🧹 Nitpick comments (1)
src/pages/Facility/settings/organizations/FacilityOrganizationView.tsx (1)

52-62: Remove commented code for sub-organization counts.

The commented code for displaying sub-organization counts should either be implemented or removed to maintain code cleanliness.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 00c41ed and b8f1855.

📒 Files selected for processing (3)
  • public/locale/en.json (4 hunks)
  • src/pages/Facility/settings/organizations/FacilityOrganizationView.tsx (4 hunks)
  • src/pages/Facility/settings/organizations/components/FacilityOrganizationLayout.tsx (5 hunks)
🔇 Additional comments (5)
src/pages/Facility/settings/organizations/components/FacilityOrganizationLayout.tsx (2)

103-136: Well-structured responsive navigation layout.

The navigation layout with back button, breadcrumbs and responsive design provides good user experience and follows best practices.


155-172: Clean tab-based navigation implementation.

The tabbed navigation using shadcn UI components is well implemented with proper state management and routing.

src/pages/Facility/settings/organizations/FacilityOrganizationView.tsx (2)

77-81: Well-implemented pagination with proper caching.

The pagination implementation using useFilters hook with proper cache blacklisting and results per page handling is well done.

Also applies to: 89-91


109-125: Clean search implementation with proper UX.

The search functionality with icon, proper placeholder text, and debounced API calls provides a good user experience.

public/locale/en.json (1)

997-1000: Well-structured localization keys for organization types.

The new localization keys follow consistent naming patterns and provide clear translations for different organization types.

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

🔭 Outside diff range comments (1)
src/pages/Facility/settings/organizations/components/FacilityOrganizationLayout.tsx (1)

103-199: ⚠️ Potential issue

Fix JSX syntax errors.

There are several syntax errors in the JSX structure:

  1. Missing closing tag for the div at line 104
  2. Fragment has no corresponding closing tag

Apply this diff to fix the syntax:

-    <>
+    <div className="space-y-4">
       <div className="md:px-6 py-2 flex items-center gap-2 mx-auto max-w-4xl">
         {/* ... */}
+      </div>
       <Page title={`${org.name} `}>
         {/* ... */}
       </Page>
-    </>
+    </div>
🧰 Tools
🪛 Biome (1.9.4)

[error] 137-137: Expected corresponding JSX closing tag for 'Page'.

Opening tag

closing tag

(parse)

🪛 GitHub Check: cypress-run (1)

[failure] 104-104:
JSX element 'div' has no corresponding closing tag.


[failure] 199-199:
Identifier expected.

🪛 GitHub Actions: Lint Code Base

[error] 199-199: Parsing error: Identifier expected

🧹 Nitpick comments (2)
src/pages/Facility/settings/organizations/components/FacilityOrganizationLayout.tsx (2)

66-67: Simplify currentTab calculation.

The currentTab logic can be simplified using optional chaining and nullish coalescing.

-  const currentTab =
-    navItems.find((item) => item.path === path)?.value || "departments";
+  const currentTab = navItems.find((item) => item.path === path)?.value ?? "departments";

89-91: Enhance error message with more context.

Consider providing more descriptive error messages to help users understand why the organization wasn't found.

-    return <div>{t("not_found")}</div>;
+    return <div>{t("organization_not_found", { id })}</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 b8f1855 and 2f7e3f7.

📒 Files selected for processing (2)
  • public/locale/en.json (4 hunks)
  • src/pages/Facility/settings/organizations/components/FacilityOrganizationLayout.tsx (6 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • public/locale/en.json
🧰 Additional context used
🪛 GitHub Check: cypress-run (1)
src/pages/Facility/settings/organizations/components/FacilityOrganizationLayout.tsx

[failure] 104-104:
JSX element 'div' has no corresponding closing tag.


[failure] 199-199:
Identifier expected.

🪛 GitHub Actions: Lint Code Base
src/pages/Facility/settings/organizations/components/FacilityOrganizationLayout.tsx

[error] 199-199: Parsing error: Identifier expected

🪛 GitHub Actions: Cypress Tests
src/pages/Facility/settings/organizations/components/FacilityOrganizationLayout.tsx

[error] 102-102: JSX fragment has no corresponding closing tag.


[warning] Importing JSON modules is an experimental feature and might change at any time.

🔇 Additional comments (2)
src/pages/Facility/settings/organizations/components/FacilityOrganizationLayout.tsx (2)

44-52: LGTM! Good improvements to navigation and i18n support.

The addition of translation and history hooks enhances the component's functionality.


117-128: Fix key prop in breadcrumb mapping.

The fragment and breadcrumb items need proper key props to avoid React warnings and potential reconciliation issues.

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/Facility/settings/organizations/components/FacilityOrganizationLayout.tsx (1)

137-176: Consider removing redundant "defaultValue" from Tabs.
When combined with the controlled value prop, defaultValue is usually unnecessary.

Below is a diff to omit defaultValue:

-<Tabs
-  defaultValue={currentTab}
-  className="w-full mt-2"
-  value={currentTab}
->
+<Tabs className="w-full mt-2" value={currentTab}>
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 2f7e3f7 and fc51a03.

📒 Files selected for processing (1)
  • src/pages/Facility/settings/organizations/components/FacilityOrganizationLayout.tsx (5 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: Redirect rules - care-ohc
  • GitHub Check: Header rules - care-ohc
  • GitHub Check: Pages changed - care-ohc
  • GitHub Check: Test
  • GitHub Check: CodeQL-Build
  • GitHub Check: OSSAR-Scan
  • GitHub Check: cypress-run (1)
🔇 Additional comments (9)
src/pages/Facility/settings/organizations/components/FacilityOrganizationLayout.tsx (9)

3-17: All newly introduced imports are well-integrated.
No issues found; this is a neat addition that leverages your UI library and i18n effectively.


22-22: Use of custom history hook looks good.
This provides a more streamlined approach to navigation and fosters code consistency.


49-50: Proper integration of i18n and custom goBack.
This seamlessly ties into your existing application hooks.


55-61: Good use of i18n for nav item titles.
This keeps the UI text dynamic and localized.


65-67: Fallback logic is straightforward.
Ensuring a default tab if path matching fails is a clean approach.


89-89: Appropriate not-found UI message.
Presenting a localized fallback helps users understand the missing data state.


103-112: Back button integration is user-friendly.
A clear and intuitive navigation element.


116-127: Fragment key usage repeats a past concern.
As previously noted, unkeyed fragments with keyed children may cause React warnings or reconciliation issues.


37-41: Verify removal of the old “icon” property references.
Replacing icon with value in NavItem may break any old references that still expect an icon property.

Below is a script to locate potential leftover references to icon in .ts and .tsx files:

✅ Verification successful

🏁 Script executed:

#!/bin/bash
# Description: Find any references to the old "icon" property that might be left behind.

rg --type ts --type tsx 'icon\s*:' 

Length of output: 64


Below is an updated shell script that explicitly searches both .ts and .tsx files so we can verify that no lingering references to the old icon property remain:

Please run this script and inspect the output. If nothing is returned, it confirms that all references to the removed icon property have been cleared. Otherwise, any output will need further manual review to ensure that legacy references are updated.


🏁 Script executed:

[run_scripts]
#!/bin/bash
# Locate any references to the old "icon" property in both .ts and .tsx files.
rg --glob "*.{ts,tsx}" 'icon\s*:'

Length of output: 5243


Confirmation of NavItem Update in FacilityOrganizationLayout

  • The FacilityOrganizationLayout.tsx file now defines NavItem with a value property in place of icon.
  • The updated search found several occurrences of icon: across the codebase; however, none of these are within the context of the NavItem interface used by FacilityOrganizationLayout.
  • References to icon seen in files like src/common/constants.tsx, sidebar components, and others appear to serve different purposes and are not related to the navigation items in FacilityOrganizationLayout.

Based on the evidence, the removal and replacement in FacilityOrganizationLayout are correct and isolated from other valid uses of the icon property.

@rithviknishad rithviknishad removed changes required merge conflict pull requests with merge conflict labels Feb 12, 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

♻️ Duplicate comments (1)
src/pages/Facility/settings/organizations/components/FacilityOrganizationLayout.tsx (1)

116-127: ⚠️ Potential issue

Fix key prop in breadcrumb mapping.

The fragment and breadcrumb items need proper key props to avoid React warnings and potential reconciliation issues.

-            {orgParents.reverse().map((parent) => (
-              <>
-                <BreadcrumbItem key={parent.id}>
+            {orgParents.reverse().map((parent) => (
+              <React.Fragment key={parent.id}>
+                <BreadcrumbItem>
                   <BreadcrumbLink>
                     <Link href={parent.id}>{parent.name}</Link>
                   </BreadcrumbLink>
                 </BreadcrumbItem>
-                <BreadcrumbItem key={`ellipsis-${parent.id}`}>
+                <BreadcrumbItem>
                   <BreadcrumbSeparator />
                 </BreadcrumbItem>
-              </>
+              </React.Fragment>
             ))}
🧹 Nitpick comments (4)
src/pages/Facility/settings/organizations/FacilityOrganizationView.tsx (2)

29-34: Remove unused prop facilityId.

The facilityId prop is declared in the component's props interface but is not used within the component.

 function OrganizationCard({
   org,
 }: {
   org: FacilityOrganization;
-  facilityId: string;
 }) {

51-61: Clean up commented code for sub-organization counts.

The commented code suggests an incomplete feature for displaying sub-organization counts. Either implement the feature or remove the commented code to maintain code cleanliness.

Would you like me to help implement the sub-organization count feature? This would involve:

  1. Adding a query to fetch sub-organization counts
  2. Implementing the loading state
  3. Displaying the count in the Badge component
src/pages/Facility/settings/organizations/components/FacilityOrganizationLayout.tsx (2)

65-66: Enhance tab value fallback logic.

The current implementation uses a hardcoded fallback value which could cause issues if 'departments' is not a valid value. Consider using the first nav item's value as the default.

-  const currentTab =
-    navItems.find((item) => item.path === path)?.value || "departments";
+  const currentTab =
+    navItems.find((item) => item.path === path)?.value || navItems[0]?.value || "departments";

88-90: Enhance error state UX.

The current error state could be more informative and user-friendly.

-    return <div>{t("not_found")}</div>;
+    return (
+      <div className="flex flex-col items-center justify-center p-6">
+        <CareIcon icon="l-exclamation-circle" className="h-12 w-12 text-gray-400" />
+        <p className="mt-2 text-lg font-medium">{t("not_found")}</p>
+        <Button
+          onClick={() => goBack()}
+          variant="ghost"
+          size="sm"
+          className="mt-4"
+        >
+          {t("back_to_previous_page")}
+        </Button>
+      </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 fc51a03 and 3e027d3.

📒 Files selected for processing (2)
  • src/pages/Facility/settings/organizations/FacilityOrganizationView.tsx (4 hunks)
  • src/pages/Facility/settings/organizations/components/FacilityOrganizationLayout.tsx (5 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: cypress-run (1)
🔇 Additional comments (6)
src/pages/Facility/settings/organizations/FacilityOrganizationView.tsx (3)

74-101: Well-implemented search and pagination!

The component demonstrates good practices:

  • Proper use of useFilters hook for pagination
  • Debounced search implementation
  • Clean query parameter handling

105-131: Great UI improvements!

The search and layout implementation shows attention to detail:

  • Intuitive search input with icon
  • Responsive layout with proper spacing
  • Clean flex-based alignment

139-162: Well-structured pagination implementation!

The pagination implementation is clean and user-friendly:

  • Shows only when needed (count > resultsPerPage)
  • Proper handling of empty states
  • Clean integration with the OrganizationCard component
src/pages/Facility/settings/organizations/components/FacilityOrganizationLayout.tsx (3)

37-41: Verify NavItem interface consistency across codebase.

The NavItem interface has been updated to use value instead of icon. This change was previously flagged as inconsistent with the organization layout implementation.

#!/bin/bash
# Search for other NavItem interface definitions
rg "interface NavItem" -A 5 --type typescript

48-50: LGTM! Proper hook initialization.

The hooks are correctly initialized and follow React best practices.


155-172: LGTM! Well-implemented tabs navigation.

The tabs implementation is clean, accessible, and follows best practices:

  • Uses proper ARIA attributes through shadcn components
  • Handles navigation correctly with Link components
  • Maintains consistent styling

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.

LGTM, minor comments.

Follow up on (different issue):

Keep dept on top level highlighted:

image

Reset search on nav:

image

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

♻️ Duplicate comments (2)
src/pages/Facility/settings/organizations/components/FacilityOrganizationLayout.tsx (2)

32-36: ⚠️ Potential issue

Maintain consistency in NavItem interface across layouts.

The NavItem interface has been modified to use value instead of icon, which differs from the organization layout implementation. This inconsistency was previously flagged and needs to be addressed.

Consider one of these approaches:

  1. Align both interfaces by updating the organization layout to use value
  2. Create separate interfaces with distinct names to avoid confusion

101-115: ⚠️ Potential issue

Fix React key prop issues in breadcrumb mapping.

The breadcrumb implementation still has key prop issues that need to be addressed:

  1. Using fragment without key
  2. Redundant key props on BreadcrumbItem

Apply this fix:

-              {orgParents.reverse().map((parent) => (
-                <>
-                  <BreadcrumbItem key={parent.id}>
+              {orgParents.reverse().map((parent) => (
+                <React.Fragment key={parent.id}>
+                  <BreadcrumbItem>
                     <BreadcrumbLink
                       asChild
                       className="text-sm text-gray-900 hover:underline hover:underline-offset-2"
                     >
                       <Link href={parent.id}>{parent.name}</Link>
                     </BreadcrumbLink>
                   </BreadcrumbItem>
-                  <BreadcrumbItem key={`ellipsis-${parent.id}`}>
+                  <BreadcrumbItem>
                     <BreadcrumbSeparator />
                   </BreadcrumbItem>
-                </>
+                </React.Fragment>
               ))}
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between d641feb and 1347075.

📒 Files selected for processing (2)
  • src/pages/Facility/settings/organizations/FacilityOrganizationView.tsx (4 hunks)
  • src/pages/Facility/settings/organizations/components/FacilityOrganizationLayout.tsx (5 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: cypress-run (1)
🔇 Additional comments (5)
src/pages/Facility/settings/organizations/FacilityOrganizationView.tsx (2)

74-101: Well-structured implementation with proper pagination and search!

The component effectively uses:

  • useFilters hook for pagination
  • Debounced query for search
  • Proper state management

105-131: Clean and responsive layout implementation!

The search and create organization components are well-organized with proper responsive behavior and accessibility features:

  • Search icon placement
  • Responsive grid
  • Clear visual hierarchy
src/pages/Facility/settings/organizations/components/FacilityOrganizationLayout.tsx (3)

43-60: Well-implemented i18n and navigation setup!

The translation integration and tab navigation logic are well-structured. The fallback to "departments" provides good defensive programming.


62-84: Good implementation of data fetching and loading states!

The use of React Query with skeleton loading states provides excellent user feedback, and the error message is properly internationalized.


125-163: Clean and accessible layout implementation!

The page layout with tabs follows good UI practices:

  • Proper use of Badge component for organization type
  • Accessible tab implementation
  • Consistent styling with the design system

@Jacobjeevan Jacobjeevan merged commit 2c7e95f into ohcnetwork:develop Feb 13, 2025
8 of 11 checks passed
Copy link

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

Successfully merging this pull request may close these issues.

3 participants