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

Redesign the Facility Details Page #10380

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

Conversation

AdityaJ2305
Copy link
Contributor

@AdityaJ2305 AdityaJ2305 commented Feb 3, 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 facility display with standardized organization name formatting and conditional cover photo editing.
  • Refactor

    • Streamlined the layout and rendering of organization details; removed redundant UI elements.
  • Style

    • Updated styling of facility details, including improved formatting for phone numbers and overall visual consistency.
  • Bug Fixes

    • Simplified the rendering of contact links for phone and email, improving clarity and usability.

Copy link
Contributor

coderabbitai bot commented Feb 3, 2025

Walkthrough

This pull request refactors the FacilityHome.tsx component by removing several unused UI imports, introducing a new formatValue function to standardize organization names, and updating the rendering flow for organization details. It enhances the layout for displaying facility information, including formatted phone numbers and conditional rendering for the cover photo edit button, aligning with the redesign requirements.

Changes

File Change Summary
src/components/Facility/.../FacilityHome.tsx - Removed unused imports for tooltips and dropdown menus.
- Introduced formatValue to clean organization names in parentDetails and main labels.
- Refactored renderGeoOrganizations to return an array of organization details instead of direct rendering.
- Updated card layout including conditional avatar cover photo editing and enhanced facility data display (e.g., formatted phone numbers).
src/components/Common/.../ContactLink.tsx - Removed className from <a> tag and CareIcon component.
- Adjusted text content to directly display tel or mailto values without additional styling.

Assessment against linked issues

Objective Addressed Explanation
Redesign the Facility Details Page (#10372)

Possibly related PRs

  • Fix: FacilityData not populating on Edit  #10077: The changes in the main PR are related to modifications in the FacilityHome.tsx component, specifically in the rendering logic and data handling, which aligns with the updates made in the retrieved PR that also focuses on the FacilityHome.tsx component's data fetching strategy.
  • FIX: Facility Issues: Cover Not Functioning Properly and Minor Suggestions for the Facility Page #10021: The changes in the main PR are related to the modifications in the FacilityHome.tsx file, specifically the addition of the coverImageHint constant and its usage in the AvatarEditModal, which aligns with the changes made in the retrieved PR regarding the hint prop for customizable image upload guidance.
  • Use only text for Avatar #9951: The changes in the main PR for FacilityHome.tsx involve modifications to how the name property is accessed within the Avatar component, while the retrieved PR focuses on simplifying the Avatar component's implementation and handling of the name property, indicating a direct relationship between the two.

Suggested labels

changes required, needs review

Suggested reviewers

  • rithviknishad
  • Jacobjeevan

Poem

I'm a rabbit in the code garden, hopping with glee,
Seeing refactored views as neat as can be.
With a new formatValue carrot crunchy and sweet,
And adjusted layouts making every detail complete.
I hop along, celebrating changes bold and bright!
🐰💻 Hop, hop, hoora!

Tip

🌐 Web search-backed reviews and chat
  • We have enabled web search-based reviews and chat for all users. This feature allows CodeRabbit to access the latest documentation and information on the web.
  • You can disable this feature by setting web_search: false in the knowledge_base settings.
  • Please share any feedback in the Discord discussion.

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

Deploy Preview for care-ohc ready!

Name Link
🔨 Latest commit a128218
🔍 Latest deploy log https://app.netlify.com/sites/care-ohc/deploys/67a9ab1f1c99a300083fb2bb
😎 Deploy Preview https://deploy-preview-10380--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.

@AdityaJ2305 AdityaJ2305 marked this pull request as ready for review February 4, 2025 02:56
@AdityaJ2305 AdityaJ2305 requested a review from a team as a code owner February 4, 2025 02:56
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)
src/components/Facility/FacilityHome.tsx (5)

20-20: Consider removing commented code.

The commented import of ContactLink should be removed if it's no longer needed.

-// import ContactLink from "@/components/Common/ContactLink";

66-70: Consider moving formatValue to a utility file.

The formatValue function could be useful in other components. Consider moving it to a utility file for better reusability.

Create a new file src/Utils/formatting.ts:

export const formatValue = (name: string, label: string) => {
  return name.endsWith(label)
    ? name.replace(new RegExp(`${label}$`), "").trim()
    : name;
};

207-219: Add aria-label to improve accessibility.

The background container should have an aria-label for better screen reader support.

-<div className="group rounded-3xl relative h-64 w-full bg-gradient-to-br from-emerald-400 via-emerald-500 to-emerald-600">
+<div 
+  className="group rounded-3xl relative h-64 w-full bg-gradient-to-br from-emerald-400 via-emerald-500 to-emerald-600"
+  aria-label={t("facility_header_background")}
+>

276-327: Consider extracting card components for better maintainability.

The facility details cards could be extracted into separate components to improve code organization and reusability.

Create new components:

// src/components/Facility/FacilityAddressCard.tsx
export const FacilityAddressCard = ({ 
  facilityData, 
  className 
}: { 
  facilityData: FacilityData;
  className?: string;
}) => (
  <Card className={className}>
    <CardContent>
      {/* Address content */}
    </CardContent>
  </Card>
);

// src/components/Facility/FacilityOrganizationCard.tsx
export const FacilityOrganizationCard = ({ 
  geoOrganization,
  className 
}: { 
  geoOrganization: Organization;
  className?: string;
}) => (
  <Card className={className}>
    <CardContent>
      {/* Organization content */}
    </CardContent>
  </Card>
);

Then update the main component:

-<div className="flex gap-3">
-  <Card className="basis-1/2">
-    {/* Address content */}
-  </Card>
-  <Card className="basis-1/2">
-    {/* Organization content */}
-  </Card>
-</div>
+<div className="flex gap-3">
+  <FacilityAddressCard 
+    facilityData={facilityData} 
+    className="basis-1/2" 
+  />
+  <FacilityOrganizationCard 
+    geoOrganization={facilityData.geo_organization} 
+    className="basis-1/2"
+  />
+</div>

348-348: Consider moving styles to a CSS module.

The badge styles could be moved to a CSS module for better maintainability and reuse.

Create src/components/Facility/FacilityHome.module.css:

.featureBadge {
  @apply flex items-center gap-2 rounded-md bg-blue-100 text-blue-700 hover:bg-blue-200 px-3 py-1;
}

Then update the component:

-className="flex items-center gap-2 rounded-md bg-blue-100 text-blue-700 hover:bg-blue-200 px-3 py-1"
+className={styles.featureBadge}
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 8ee64da and eb66432.

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

304-304: TODO: Implement location details.

The location details section is currently empty. Please implement the location link functionality.

Would you like me to help implement the location details section? I can provide a solution that integrates with a mapping service.

@AdityaJ2305
Copy link
Contributor Author

Hey Team, It is ready for review and testing

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

169-169: Replace hard-coded permission check

The permission check is currently hard-coded to true, which could lead to security issues.

Consider implementing proper permission validation:

- const hasPermissionToEditCoverImage = true;
+ const hasPermissionToEditCoverImage = facilityData.permissions?.canEditCoverImage || false;
🧹 Nitpick comments (3)
src/components/Facility/FacilityHome.tsx (3)

66-70: Add input validation to formatValue function

The function should handle edge cases and special characters in the label.

Consider this safer implementation:

 const formatValue = (name: string, label: string) => {
+  if (!name || !label) return name;
+  const escapedLabel = label.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
   return name.endsWith(label)
-    ? name.replace(new RegExp(`${label}$`), "").trim()
+    ? name.replace(new RegExp(`${escapedLabel}$`), "").trim()
     : name;
 };

304-304: Implement missing location details

The location details section is empty but the UI structure is in place.

Would you like me to help implement the location details section with a map integration or location link?


348-348: Use design system tokens for badge styling

The badge styling uses direct color values instead of design system tokens.

Consider using design system tokens:

- className="flex items-center gap-2 rounded-md bg-blue-100 text-blue-700 hover:bg-blue-200 px-3 py-1"
+ className="flex items-center gap-2 rounded-md bg-primary-100 text-primary-700 hover:bg-primary-200 px-3 py-1"
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between eb66432 and 5957bc7.

📒 Files selected for processing (1)
  • src/components/Facility/FacilityHome.tsx (4 hunks)

src/components/Facility/FacilityHome.tsx 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: 2

🧹 Nitpick comments (3)
src/components/Facility/FacilityHome.tsx (3)

65-69: Consider memoizing formatValue function.

Since formatValue is used in a map operation, memoizing it could improve performance for large lists.

-  const formatValue = (name: string, label: string) => {
+  const formatValue = useMemo(() => (name: string, label: string) => {
     return name.endsWith(label)
       ? name.replace(new RegExp(`${label}$`), "").trim()
       : name;
-  };
+  }, []);

307-308: Implement location details section.

The location details section is empty with a comment indicating pending implementation.

Would you like me to help implement the location details section? I can generate a solution that integrates with mapping services or displays coordinates in a user-friendly format.


298-300: Validate phone number format.

The phone number is directly passed to ContactLink without validation. Consider adding format validation or normalization.

+const formatPhoneNumber = (phone: string) => {
+  // Remove non-numeric characters
+  const cleaned = phone.replace(/\D/g, '');
+  // Format as XXX-XXX-XXXX
+  return cleaned.replace(/(\d{3})(\d{3})(\d{4})/, '$1-$2-$3');
+};

 <ContactLink
-  tel={String(facilityData?.phone_number)}
+  tel={formatPhoneNumber(String(facilityData?.phone_number))}
 />
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 5957bc7 and b8a4f5c.

📒 Files selected for processing (2)
  • src/components/Common/ContactLink.tsx (1 hunks)
  • src/components/Facility/FacilityHome.tsx (5 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: cypress-run (1)
🔇 Additional comments (3)
src/components/Common/ContactLink.tsx (1)

10-11: LGTM! Clean and focused component.

The component follows best practices with:

  • Type-safe props using discriminated union
  • Appropriate icon selection based on contact type
  • Standard protocol formatting for href
src/components/Facility/FacilityHome.tsx (2)

53-87: Optimize repeated geo organization rendering.

The same geo organization data is rendered multiple times in the component.

This was previously flagged in an earlier review. The suggestion to memoize the rendered organizations still applies:

+ const memoizedGeoOrganizations = useMemo(
+   () => facilityData.geo_organization && renderGeoOrganizations(facilityData.geo_organization),
+   [facilityData.geo_organization]
+ );

43-51: Handle null icon case explicitly.

The function can return null when no feature is found or when the icon is undefined. Consider providing a default icon or handling the null case where this function is used.

src/components/Facility/FacilityHome.tsx Show resolved Hide resolved
src/components/Facility/FacilityHome.tsx Show resolved Hide resolved
@Jacobjeevan
Copy link
Contributor

Jacobjeevan commented Feb 4, 2025

image

Address: modify to display address + zipcode
Adjust the casing for the geo org labels so they are capitalized case.

Add top padding and maybe adjust the font size for both of the cards (address and geo).

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

168-171: ⚠️ Potential issue

Action Required: Implement proper permission checks in FacilityHome.

The current implementation relies on a hardcoded permission flag with a TODO noting that permissions should come from the backend.

🧹 Nitpick comments (2)
src/components/Facility/FacilityHome.tsx (2)

65-69: Optimize the formatValue function.

The current regex implementation recreates the pattern on each call. Consider memoizing the RegExp object or using string methods for better performance.

-    return name.endsWith(label)
-      ? name.replace(new RegExp(`${label}$`), "").trim()
-      : name;
+    return name.endsWith(label)
+      ? name.slice(0, -label.length).trim()
+      : name;

211-215: Improve image accessibility attributes.

The cover image could benefit from better accessibility attributes.

 <img
   src={facilityData.read_cover_image_url}
   alt={facilityData?.name}
+  role="img"
+  aria-label={t("facility_cover_image", { name: facilityData?.name })}
   className="h-full w-full object-cover rounded-2xl"
 />
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between b8a4f5c and 3b41b62.

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

223-227: Add alt text to Avatar component for accessibility.

The Avatar component should have an alt text to improve accessibility.


306-311: Implement the location details section.

The location details section is currently empty with a comment placeholder.

Could you clarify if this section should:

  1. Display coordinates if available in the facility data
  2. Show a map integration
  3. Be removed if not needed

277-333: Optimize repeated geo organization rendering.

The same geo organization data is rendered in two separate cards, which could impact performance and maintainability.

@AdityaJ2305
Copy link
Contributor Author

  • Address: modify to display address + zipcode Adjust the casing for the geo org labels so they are capitalized case.
  • Add top padding and maybe adjust the font size for both of the cards (address and geo).

Adjust the casing for the geo org labels so they are capitalized case.

The geo org labels are already capitalized like Ward Block Panchayat District etc. Am I misunderstanding it ? 🤔

@github-actions github-actions bot added needs-triage question Further information is requested labels Feb 4, 2025
@Jacobjeevan
Copy link
Contributor

  • Address: modify to display address + zipcode Adjust the casing for the geo org labels so they are capitalized case.
  • Add top padding and maybe adjust the font size for both of the cards (address and geo).

Adjust the casing for the geo org labels so they are capitalized case.

The geo org labels are already capitalized like Ward Block Panchayat District etc. Am I misunderstanding it ? 🤔

My bad, meant geo org values 👍

@github-actions github-actions bot added needs-triage question Further information is requested labels Feb 5, 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: 1

🔭 Outside diff range comments (1)
src/components/Facility/FacilityHome.tsx (1)

138-141: Improve error handling in image upload.

The error case only calls the error callback without providing any user feedback. Consider adding a toast notification with the error details.

         } else {
+          toast.error(t("failed_to_upload_image"));
           onError();
         }
🧹 Nitpick comments (2)
src/components/Facility/FacilityHome.tsx (2)

65-69: Move formatValue function outside for reusability.

The formatValue function is currently nested inside renderGeoOrganizations, limiting its reusability. Consider moving it to the module level.

+const formatValue = (name: string, label: string) => {
+  return name.endsWith(label)
+    ? name.replace(new RegExp(`${label}$`), "").trim()
+    : name;
+};

const renderGeoOrganizations = (geoOrg: Organization) => {
  const orgParents: OrganizationParent[] = [];
-  const formatValue = (name: string, label: string) => {
-    return name.endsWith(label)
-      ? name.replace(new RegExp(`${label}$`), "").trim()
-      : name;
-  };

132-132: Remove arbitrary sleep delay.

The sleep(1000) seems to be an arbitrary delay. If this is meant to handle race conditions or UI feedback, consider using proper loading states instead.

-          await sleep(1000);
+          // Use loading state to handle UI feedback
+          setIsLoading(true);
           queryClient.invalidateQueries({
             queryKey: ["facility", facilityId],
           });
+          setIsLoading(false);
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 3b41b62 and d247d97.

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

168-171: Action Required: Implement proper permission checks in FacilityHome.

The current implementation relies on a hardcoded permission flag with a TODO noting that permissions should come from the backend.


223-227: Add alt text to Avatar component.


306-311: Implement location details section.

The location details section is empty with a comment placeholder. Based on the PR objectives and nihal467's comments, this should display the facility location hyperlink.

Would you like me to help implement this section?


286-293: Remove or implement commented code.

The commented-out code for rendering geo organizations suggests uncertainty about the address display implementation. Either remove the commented code or implement the feature.

✅ Verification successful

🏁 Script executed:

#!/bin/bash
# Check if geo organizations are used elsewhere in the codebase
rg "renderGeoOrganizations" --type ts --type tsx

Length of output: 76


🏁 Script executed:

#!/bin/bash
# Re-run search for "renderGeoOrganizations" across the repository,
# adding a file type for TSX files so that all instances are found.
rg "renderGeoOrganizations" --type ts --type-add 'tsx:*.tsx'

Length of output: 342


Action: Remove or fully implement the geo organizations rendering

The search confirms that renderGeoOrganizations is defined and only referenced in the commented block. This indicates that the feature isn’t active. Based on the review comment, you should either remove the commented code from src/components/Facility/FacilityHome.tsx (and potentially remove the unused function if it isn’t needed elsewhere) or complete its implementation if geo organization details should be displayed.

src/components/Facility/FacilityHome.tsx Outdated Show resolved Hide resolved
AdityaJ2305 and others added 2 commits February 5, 2025 18:04
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Copy link

github-actions bot commented Feb 5, 2025

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

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

@github-actions github-actions bot added the merge conflict pull requests with merge conflict label Feb 5, 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 (2)
src/components/Facility/FacilityHome.tsx (2)

168-171: ⚠️ Potential issue

Critical: Replace hardcoded permission with proper permission check.

The hardcoded permission flag (hasPermissionToEditCoverImage = true) could lead to unauthorized access. This needs to be replaced with a proper permission check.

Use the existing permission system:

- const hasPermissionToEditCoverImage = true;
+ const { checkPermission } = usePermissions();
+ const hasPermissionToEditCoverImage = checkPermission("FacilityEditCoverImage");

223-227: 🛠️ Refactor suggestion

Add alt text to Avatar component for accessibility.

The Avatar component should include alt text for better accessibility.

 <Avatar
   name={facilityData.name}
+  alt={`${facilityData.name} facility avatar`}
   className="h-20 w-20 rounded-md border-4 border-white shadow-lg"
 />
🧹 Nitpick comments (2)
src/components/Facility/FacilityHome.tsx (2)

65-69: Consider memoizing the formatValue function.

The formatValue function is called multiple times within the renderGeoOrganizations function. Consider memoizing it to prevent unnecessary recalculations.

+ const formatValue = useMemo(() => 
+   (name: string, label: string) => {
+     return name.endsWith(label)
+       ? name.replace(new RegExp(`${label}$`), "").trim()
+       : name;
+   },
+   []
+ );

286-292: Remove commented code.

The commented-out geo organization rendering code should be removed as it's no longer needed, given that the same information is now rendered in a separate card.

- {/* {facilityData.geo_organization &&
-   renderGeoOrganizations(
-     facilityData.geo_organization,
-   ).map((org, index) => (
-     <span key={index}>{org.value} </span>
-   ))} */}
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between d247d97 and 0e6fb45.

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

310-311: Add the location link as mentioned in PR comments.

The comment {/* Add Location Link Here */} needs to be implemented. According to the PR comments, this is being added in a different PR, but ensure it's tracked and synchronized with this design.

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

github-actions bot commented Feb 6, 2025

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

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

@github-actions github-actions bot added the merge conflict pull requests with merge conflict label Feb 6, 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/components/Facility/FacilityHome.tsx (1)

167-170: ⚠️ Potential issue

Action Required: Implement proper permission checks in FacilityHome.

The hardcoded permission flag is a security risk. Use the existing permission utilities via the usePermissions hook.

🧹 Nitpick comments (2)
src/components/Facility/FacilityHome.tsx (2)

66-70: Enhance the formatValue function with memoization and edge case handling.

The function could be optimized and made more robust:

+ const formatValue = useMemo((name: string, label: string) => {
+   if (!name || !label) return name;
+   const sanitizedLabel = label.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
    return name.endsWith(label)
-     ? name.replace(new RegExp(`${label}$`), "").trim()
+     ? name.replace(new RegExp(`${sanitizedLabel}$`), "").trim()
      : name;
+ }, []);

276-276: Enhance responsive design for mobile screens.

As per PR feedback, ensure the layout is optimized for various mobile screens:

- <div className="flex flex-col [@media(min-width:60rem)]:flex-row gap-3">
+ <div className="grid grid-cols-1 md:grid-cols-2 gap-3">
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 0e6fb45 and 11bcb61.

📒 Files selected for processing (1)
  • src/components/Facility/FacilityHome.tsx (5 hunks)
🔇 Additional comments (3)
src/components/Facility/FacilityHome.tsx (3)

222-226: Add alt text to Avatar component.

The Avatar component should have an alt text for accessibility.


285-291: Uncomment and update the address display logic.

The commented code for rendering geo organizations should be reviewed and integrated with the address display to ensure comprehensive location information.

Consider this structure:

- {/* {facilityData.geo_organization &&
-   renderGeoOrganizations(
-     facilityData.geo_organization,
-   ).map((org, index) => (
-     <span key={index}>{org.value} </span>
-   ))} */}
- {facilityData.address}
+ <div>
+   {facilityData.address}
+   {facilityData.geo_organization && (
+     <div className="mt-2 text-gray-600">
+       {renderGeoOrganizations(facilityData.geo_organization)
+         .map(org => org.value)
+         .join(", ")}
+     </div>
+   )}
+ </div>
✅ Verification successful

Address display logic update verified.
The suggested changes correctly integrate both the facility's address and its geo organization information. The new structure ensures that the address is always displayed, while geo organization values (if available) are rendered as a comma-separated list in a styled div. This matches the review comment's intent to provide comprehensive location details.

  • Address is displayed unconditionally.
  • Geo organizations are conditionally rendered with proper styling and displayed as a comma-separated list.

309-309: Add facility location hyperlink as requested.

The location link is missing as noted in the PR feedback.

@github-actions github-actions bot removed the merge conflict pull requests with merge conflict label Feb 6, 2025
@AdityaJ2305
Copy link
Contributor Author

@nihal467 , What's the update for this ?

@nihal467 For this particular Facility this is what is present for address field Screenshot 2025-02-05 at 5 30 13 PM

  • Add support to upload facility profile image
  • this needs backend support

cc: @rithviknishad @Jacobjeevan

@Jacobjeevan
Copy link
Contributor

@nihal467 , What's the update for this ?

@nihal467 For this particular Facility this is what is present for address field Screenshot 2025-02-05 at 5 30 13 PM

  • Add support to upload facility profile image
  • this needs backend support

cc: @rithviknishad @Jacobjeevan

Yea, we will add BE support; can take it up in a different PR.

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.

Redesign the Facility Details Page
3 participants