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

Facility Id in User Profile for Nav User #9857

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

Conversation

Jacobjeevan
Copy link
Contributor

@Jacobjeevan Jacobjeevan commented Jan 9, 2025

Proposed Changes

  • Adding facilityId to the Nav User/Footer Profile url (if a facility is selected) to ensure availability shows up.

@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 user navigation in the sidebar to support facility-specific routing.
    • Added ability to dynamically generate navigation URLs based on selected facility.
  • Improvements

    • Updated the sidebar to conditionally pass the selected facility ID for improved context.
    • Improved URL construction in user navigation for better readability and maintainability.
    • Introduced conditional filtering for breadcrumb items based on visibility settings.

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

coderabbitai bot commented Jan 9, 2025

Walkthrough

The pull request modifies the rendering logic of the AppSidebar component to conditionally pass a selectedFacilityId prop to the FacilityNavUser component based on the facilitySidebar state. The FacilityNavUser itself has been updated to accept this new prop, allowing it to navigate dynamically to facility-specific URLs. Additionally, the UserHome component refactors the URL construction for user navigation to utilize a new variable, enhancing code readability while maintaining the same functional behavior. Changes are also made to the Breadcrumbs and PageTitle components to include a new optional hide property for breadcrumb visibility control.

Changes

File Change Summary
src/components/ui/sidebar/app-sidebar.tsx Updated FacilityNavUser component rendering to pass selectedFacilityId prop derived from selectedFacility state.
src/components/ui/sidebar/nav-user.tsx Modified function signature to accept selectedFacilityId and updated navigation logic to conditionally generate URLs.
src/components/Users/UserHome.tsx Introduced userUrl variable to simplify URL construction based on props.facilityId.
src/components/Common/Breadcrumbs.tsx Added optional hide property to replacements in BreadcrumbsProps for conditional breadcrumb visibility.
src/components/Common/PageTitle.tsx Updated crumbsReplacements in PageTitleProps to include a hide property for breadcrumb item control.

Possibly related PRs

Suggested labels

needs review, tested, changes required

Suggested reviewers

  • rithviknishad

Poem

🐰 In the sidebar, where paths intertwine,
A rabbit hops forth, with URLs that shine.
Selected facilities guide the way,
Dynamic routes brighten the day!
With every click, a new tale to tell,
Hopping through code, all is well! 🌟


📜 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 4579206 and 9299d11.

📒 Files selected for processing (3)
  • src/components/Common/Breadcrumbs.tsx (2 hunks)
  • src/components/Common/PageTitle.tsx (1 hunks)
  • src/components/Users/UserHome.tsx (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/components/Users/UserHome.tsx
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: cypress-run (1)
🔇 Additional comments (3)
src/components/Common/PageTitle.tsx (1)

14-19: LGTM! Type definition changes look good.

The addition of the optional hide property to crumbsReplacements interface is well-structured and maintains type safety.

src/components/Common/Breadcrumbs.tsx (2)

43-48: LGTM! Type definition changes look good.

The addition of the optional hide property to the replacements interface is well-structured and maintains consistency with PageTitle component.


70-70: Verify the breadcrumb filtering behavior.

The filtering logic is implemented correctly using optional chaining. However, let's verify that this change doesn't affect existing breadcrumb behavior.

Let's check for any existing usage of breadcrumb replacements that might be affected:

✅ Verification successful

Breadcrumb filtering behavior is correctly implemented

The filtering logic is type-safe, properly handles optional values, and maintains consistency across component boundaries. The implementation includes appropriate default values and proper type definitions.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for Breadcrumbs component usage with replacements prop
rg -A 3 '<Breadcrumbs.*replacements='

Length of output: 39


Script:

#!/bin/bash
# Search for any Breadcrumbs component usage
rg -l "Breadcrumbs"

# Get the full implementation of Breadcrumbs component
cat src/components/Common/Breadcrumbs.tsx

# Search for any test files related to Breadcrumbs
fd -g "*Breadcrumbs*.test.*"

Length of output: 5528


Script:

#!/bin/bash
# Check PageTitle implementation for Breadcrumbs usage
cat src/components/Common/PageTitle.tsx

Length of output: 2263


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

Deploy Preview for care-ohc ready!

Name Link
🔨 Latest commit 9299d11
🔍 Latest deploy log https://app.netlify.com/sites/care-ohc/deploys/6782223ab078e10008670c04
😎 Deploy Preview https://deploy-preview-9857--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

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

from organizations perspective, opening profile and clicking User Information tab, that redirects to facility: undefined

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

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

126-126: Consider using URL path joining utility.

While the current implementation works correctly, consider using a URL path joining utility to handle potential edge cases with slashes. This would make the code more robust against future changes.

-href={`${userUrl}/${p.toLocaleLowerCase()}`}
+import { joinPaths } from "@/Utils/url";
+href={joinPaths(userUrl, p.toLowerCase())}
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 08bb708 and 4579206.

📒 Files selected for processing (2)
  • src/components/Users/UserHome.tsx (2 hunks)
  • src/components/ui/sidebar/app-sidebar.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/components/ui/sidebar/app-sidebar.tsx
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: cypress-run (1)
  • GitHub Check: OSSAR-Scan
🔇 Additional comments (2)
src/components/Users/UserHome.tsx (2)

87-89: LGTM! Clean URL construction refactoring.

The introduction of the userUrl variable improves code readability and maintainability while correctly handling both facility-specific and general user profile URLs.


87-89: Verify URL pattern consistency across the application.

Let's ensure the new URL pattern is consistently used across related components.

Also applies to: 126-126

✅ Verification successful

URL pattern implementation is correct and consistent

The conditional URL pattern is properly implemented and consistently used across the application for user profiles, supporting both facility-scoped and global contexts.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for similar URL patterns in the codebase
echo "Searching for facility user URL patterns..."
rg -A 2 "facility/[^/]+/users/[^/]+" --type ts --type tsx

echo "Searching for FacilityNavUser usage..."
ast-grep --pattern 'FacilityNavUser $props {
  $$$
}'

Length of output: 327


Script:

#!/bin/bash
# Search for URL patterns with explicit file types
echo "Searching for facility and user URL patterns..."
rg -t typescript -t typescriptreact "(/facility/|/users/)" -B1 -A1

echo "Searching for FacilityNavUser component..."
ast-grep --pattern 'import { $$ FacilityNavUser $$ } from "$_"'

echo "Searching for FacilityNavUser usage..."
ast-grep --pattern '<FacilityNavUser $$$>'

Length of output: 501


Script:

#!/bin/bash
# Find relevant TypeScript files first
echo "Finding TypeScript files..."
fd -e ts -e tsx

echo "Searching for URL patterns..."
rg "(/facility/|/users/)" -g "*.{ts,tsx}" -B2 -A2

echo "Finding components with 'User' in the name..."
fd -e tsx -e ts | grep -i "user"

Length of output: 70881

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.

Profile Bug Possibly Connected/Related to Schedules (Availability)
2 participants