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

Enhanced Resource Page #9743

Closed

Conversation

manmeetnagii
Copy link
Contributor

@manmeetnagii manmeetnagii commented Jan 4, 2025

Proposed Changes

@ohcnetwork/care-fe-code-reviewers

Merge Checklist

  • Add specs that demonstrate bug / test a new feature.
  • Update product documentation.
  • Ensure that UI text is kept in I18n files.
  • Prep screenshot or demo video for changelog entry, and attach it to issue.
  • Request for Peer Reviews
  • Completion of QA

Summary by CodeRabbit

Release Notes

  • New Features

    • Added a new localization key for status selection.
    • Introduced a new ResourcePage component for managing resource requests.
    • Added a new ResourceCardList component for displaying resource requests.
  • Improvements

    • Simplified resource routing.
    • Updated Kanban board layout and scrolling behavior.
    • Enhanced loading states during data fetching in the Kanban section.
    • Implemented view toggling between board and list modes for resources.
  • Localization

    • Added "Select Status" translation option.

@manmeetnagii manmeetnagii requested a review from a team as a code owner January 4, 2025 12:59
Copy link
Contributor

coderabbitai bot commented Jan 4, 2025

Walkthrough

This pull request introduces several updates to the resource management interface. Key changes include the addition of a new localization key for status selection, modifications to the resource routing configuration, the removal of certain components, and the introduction of new components such as ResourcePage and ResourceCardList. The updates aim to enhance the user interface and experience by simplifying navigation, improving layout, and providing better data presentation capabilities.

Changes

File Change Summary
public/locale/en.json Added new localization key "select_status": "Select Status"
src/Routers/routes/ResourceRoutes.tsx Removed Redirect and view-related imports; simplified routing to render ResourcePage directly
src/components/Kanban/Board.tsx Removed horizontal scroll buttons; adjusted scrollable area height; added loading placeholder
src/components/Resource/ResourcePage.tsx New component for managing resources with board/list views, filtering, and data fetching
src/components/Resource/ResourceBoard.tsx Removed file containing BoardView component
src/components/Resource/ResourceList.tsx Removed file containing ListView component
src/components/Resource/ResourceCardList.tsx New component for displaying a list of resource requests

Assessment against linked issues

Objective Addressed Explanation
Consistent Board/List switch button design [#9677] The PR does not address the design consistency of the Board/List switch button as specified.

Possibly related PRs

Suggested labels

needs review, tested, changes required

Suggested reviewers

  • Jacobjeevan
  • rithviknishad

Poem

🐰 A rabbit's tale of code so bright,
Resources dancing left and right,
Boards and lists in harmony sing,
With locales that make interfaces swing!
Code refactored, smooth and clean,
A digital garden, freshly green! 🌱


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 5f7aeb8
🔍 Latest deploy log https://app.netlify.com/sites/care-ohc/deploys/677a9910fb02be0008d64a55
😎 Deploy Preview https://deploy-preview-9743--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
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/Resource/ResourcePage.tsx (4)

67-76: Consider handling API errors gracefully.

In your call to useTanStackQueryInstead, consider adding error handling or fallback UI for when the API fails. This helps prevent potential crashes or unhelpful blank screens in production.


220-258: Remove unnecessary Fragment.

According to the static analysis hint, using a Fragment <></> here may be redundant if it only wraps a single JSX element or if it can be replaced by a simple element.

-        <>
+        <React.Fragment>
  <div className="flex lg:flex-row flex-col w-full justify-end gap-2">
    ...
  </div>
-        </>
+        </React.Fragment>
🧰 Tools
🪛 Biome (1.9.4)

[error] 220-258: Avoid using unnecessary Fragment.

A fragment is redundant if it contains only one child, or if it is the child of a html element, and is not a keyed fragment.
Unsafe fix: Remove the Fragment

(lint/complexity/noUselessFragments)


307-353: Optimize repetitive export calls.

You have multiple export actions for CSV files in both the main Export button and each Kanban column. Consider abstracting this logic into a small utility function to avoid duplication and enhance maintainability.


379-422: Provide a more user-friendly loading state for the list view.

When loading is true, the page replaces the list with a generic “Loading” indicator. If this state might persist for a while (e.g., slow API), consider a more informative or skeleton-based UI to improve user experience.

src/components/Kanban/Board.tsx (1)

38-38: Consider keyboard accessibility.

This container is scrollable horizontally, so consider adding accessible means (e.g., keyboard arrows or focus/scroll events) and visible scrollbars for keyboard-only users.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 68c4c3d and af7a267.

📒 Files selected for processing (4)
  • public/locale/en.json (1 hunks)
  • src/Routers/routes/ResourceRoutes.tsx (1 hunks)
  • src/components/Kanban/Board.tsx (3 hunks)
  • src/components/Resource/ResourcePage.tsx (1 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
src/components/Resource/ResourcePage.tsx

[error] 220-258: Avoid using unnecessary Fragment.

A fragment is redundant if it contains only one child, or if it is the child of a html element, and is not a keyed fragment.
Unsafe fix: Remove the Fragment

(lint/complexity/noUselessFragments)

🔇 Additional comments (6)
src/components/Resource/ResourcePage.tsx (1)

263-285: Ensure consistent naming for “completed” vs “active” statuses.

Currently, boardFilter toggles between ACTIVE and COMPLETED. Double-check that these arrays and labels match any existing enums or server-defined statuses for clarity and consistency.

src/Routers/routes/ResourceRoutes.tsx (2)

3-3: Confirm correct import path.

ResourcePage is imported from @/components/Resource/ResourcePage. Verify that the path remains consistent if file locations or naming conventions change.


8-8: Straightforward route definition.

This route cleanly replaces the prior dynamic view approach. Looks good!

src/components/Kanban/Board.tsx (2)

137-137: Clarify updated height value.

Switching from calc(100vh - 200px) to calc(100vh - 340px) significantly changes the scrollable space. Double-check that all elements remain visible on smaller screens or constrained layouts.


169-169: Good use of Draggable placeholder.

Using provided.placeholder ensures proper spacing for drag-and-drop items. Nice job.

public/locale/en.json (1)

1593-1593: Localized status selection key addition.

The new "select_status": "Select Status" key helps keep user-facing text in I18n files, improving maintainability. Great addition!

@manmeetnagii
Copy link
Contributor Author

@Jacobjeevan review please

Copy link
Member

Choose a reason for hiding this comment

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

this file can be deleted as it's no longer used right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it is used in resource list view, instead of this resourceBoard.tsx and resourceList.tsx can be deleted as it's not used anywhere

Comment on lines -15 to -16
"/resource/board": () => <BoardView />,
"/resource/list": () => <ListView />,
Copy link
Member

Choose a reason for hiding this comment

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

these components can be deleted too right since it's no longer used?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes this can be deleted

{t("resource")}
</div>
<div className="col-span-1 hidden text-left uppercase sm:hidden md:hidden lg:block">
{t("LOG_UPDATE_FIELD_LABEL__patient_category")}
Copy link
Member

Choose a reason for hiding this comment

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

we no longer have things like "log updates" these days.

{t("LOG_UPDATE_FIELD_LABEL__action")}
</div>
</div>
<div>{showResourceCardList(data?.results || [])}</div>
Copy link
Member

Choose a reason for hiding this comment

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

make it a component instead of a function

Copy link
Contributor Author

Choose a reason for hiding this comment

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

in a same file or different file?

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 (5)
src/components/Resource/ResourceCardList.tsx (3)

25-28: Avoid using array index as the key.

Using the index as a React list key can lead to unexpected behavior if the order of items changes. Assign a reliable, unique identifier from resource (e.g., resource.id) as the key.

-  return data.map((resource: ResourceRequest, i) => (
-    <div key={i} ...
+  return data.map((resource: ResourceRequest) => (
+    <div key={resource.id} ...

37-49: Consolidate status checks for readability and maintainability.

You display two different dt/Chip blocks based on the resource.status. Consider merging them into a single logic block or helper function to reduce duplication and make maintenance easier, especially as more statuses are added.

Also applies to: 51-69


125-129: Parameterize the resource link.

Currently, the resource details page is hard-coded as href={/resource/${resource.id}}, which is fine, but consider using a route generation utility or typed route definitions (if available in your codebase) for cleaner and safer path construction.

src/components/Resource/ResourcePage.tsx (2)

88-127: Remove redundant fragment as flagged by static analysis.

Wrapping this single <div> or set of elements in an empty fragment is unnecessary. Replace with a direct element or restructure it to remove the fragment.

🧰 Tools
🪛 Biome (1.9.4)

[error] 94-126: Avoid using unnecessary Fragment.

A fragment is redundant if it contains only one child, or if it is the child of a html element, and is not a keyed fragment.
Unsafe fix: Remove the Fragment

(lint/complexity/noUselessFragments)


129-226: Split the board view logic into smaller components.

This block of code handles filter UI, rendering, and complex Kanban board logic in one place. Splitting it into subcomponents (e.g., BoardFilters, BoardView) improves readability, testability, and maintainability.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between af7a267 and 5f7aeb8.

📒 Files selected for processing (5)
  • public/locale/en.json (1 hunks)
  • src/components/Resource/ResourceBoard.tsx (0 hunks)
  • src/components/Resource/ResourceCardList.tsx (1 hunks)
  • src/components/Resource/ResourceList.tsx (0 hunks)
  • src/components/Resource/ResourcePage.tsx (1 hunks)
💤 Files with no reviewable changes (2)
  • src/components/Resource/ResourceList.tsx
  • src/components/Resource/ResourceBoard.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • public/locale/en.json
🧰 Additional context used
🪛 Biome (1.9.4)
src/components/Resource/ResourcePage.tsx

[error] 94-126: Avoid using unnecessary Fragment.

A fragment is redundant if it contains only one child, or if it is the child of a html element, and is not a keyed fragment.
Unsafe fix: Remove the Fragment

(lint/complexity/noUselessFragments)

🔇 Additional comments (2)
src/components/Resource/ResourceCardList.tsx (1)

17-23: Guard against undefined data.

If data could be undefined (e.g., during a loading state), accessing data.length or mapping over it would throw an error. Consider ensuring data defaults to an empty array or adding a defensive check for cases when data is undefined.

src/components/Resource/ResourcePage.tsx (1)

272-272: Revisit potentially obsolete label.

The key LOG_UPDATE_FIELD_LABEL__patient_category may not align with current naming conventions. This label also appears to be inconsistent with the rest of the text keys. Confirm that your i18n files still reference this key, or rename it to match standard labeling.

Comment on lines +247 to +265
{loading ? (
<Loading />
) : (
<div className="w-full flex flex-col">
<div className="-mb-4 mr-2 mt-4 flex justify-end">
<BadgesList {...{ appliedFilters, FilterBadges }} />

<button
className="text-xs hover:text-blue-800 w-[90px]"
onClick={() => refetch()}
>
<CareIcon
icon="l-refresh"
className="mr-1"
aria-hidden="true"
/>
{t("refresh_list")}
</button>
</div>
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Ensure consistent loading and refresh behavior.

While rendering a loading spinner and providing a refresh button is helpful, ensure the user sees error feedback if data fetching fails. Currently, there's no coverage for request failure or partial data states.

Comment on lines +79 to +85
const exportAction = async () => {
const { data } = await request(routes.downloadResourceRequests, {
query: { ...appliedFilters, csv: true },
});
return data ?? null;
};

Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add error handling for export requests.

The exportAction function assumes the response is valid without handling errors. A request failure would cause an unhandled exception or user confusion. Consider handling errors and providing user feedback on failure.

 const exportAction = async () => {
   try {
     const { data } = await request(routes.downloadResourceRequests, {
       query: { ...appliedFilters, csv: true },
     });
     return data ?? null;
   } catch (error) {
+    // show a toast or a user-friendly message
+    console.error("Export request failed", error);
+    return null;
   }
 };
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const exportAction = async () => {
const { data } = await request(routes.downloadResourceRequests, {
query: { ...appliedFilters, csv: true },
});
return data ?? null;
};
const exportAction = async () => {
try {
const { data } = await request(routes.downloadResourceRequests, {
query: { ...appliedFilters, csv: true },
});
return data ?? null;
} catch (error) {
// show a toast or a user-friendly message
console.error("Export request failed", error);
return null;
}
};

@manmeetnagii
Copy link
Contributor Author

@rithviknishad changes done

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

github-actions bot commented Jan 5, 2025

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


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

@manmeetnagii manmeetnagii deleted the enhanced-resource-page branch January 5, 2025 17:03
@manmeetnagii
Copy link
Contributor Author

creating a new PR

@rithviknishad
Copy link
Member

why was this closed?

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

Successfully merging this pull request may close these issues.

Enhancement: Consistent design of Board/List switch button in Resources and Appointment pages
2 participants