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

Enhancement: Update the button layout in Assets Page #9392

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

Conversation

manmeetnagii
Copy link
Contributor

@manmeetnagii manmeetnagii commented Dec 12, 2024

Proposed Changes

Summary by CodeRabbit

  • New Features

    • Enhanced search functionality with support for multiple fields including name, qr_code_id, and serial_number.
    • Improved layout for search and export options in the AssetsList component.
    • Updated button components in the FiltersSlideover and Export components for a more consistent user interface.
  • Bug Fixes

    • Adjusted rendering logic for better responsiveness during data fetching.

@manmeetnagii manmeetnagii requested a review from a team as a code owner December 12, 2024 09:04
Copy link
Contributor

coderabbitai bot commented Dec 12, 2024

Walkthrough

The changes in the AssetsList component enhance search functionality and improve the user interface layout. A new import for SearchByMultipleFields is added, and the configuration of the useFilters hook is updated to support additional search parameters. The layout of buttons and search elements is refined for better organization while maintaining responsiveness. Minor adjustments are made to existing components without altering their core functionality.

Changes

File Path Change Summary
src/components/Assets/AssetsList.tsx - Added import for SearchByMultipleFields.
- Updated useFilters configuration.
- Modified cacheBlacklist.
- Enhanced params object with new properties.
- Defined searchOptions array for search criteria.
- Adjusted rendering logic for SearchByMultipleFields.
- Refined layout for buttons and search functionalities.
- Retained FacilitiesSelectDialogue and AssetImportModal with minor prop adjustments.
src/CAREUI/interactive/FiltersSlideover.tsx - Replaced ButtonV2 with Button in AdvancedFilterButton and FiltersSlideover.
- Updated button properties and styling.
src/components/Common/Export.tsx - Replaced ButtonV2 with Button in ExportMenu and ExportButton.
- Modified class names for DropdownMenu to enhance visual consistency.

Assessment against linked issues

Objective Addressed Explanation
Update the button layout in Assets Page (9349)
Preserve the present mobile view (9349)

Suggested labels

needs review, tested

Suggested reviewers

  • rithviknishad
  • Jacobjeevan

Poem

In the land of assets, we hop with glee,
Searching by fields, as easy as can be!
Buttons aligned, a neat little row,
With every click, our joy will grow!
So let’s celebrate, with a bounce and a cheer,
For the changes are here, let’s spread the good cheer! 🐇✨

Tip

CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command @coderabbitai generate docstrings to have CodeRabbit automatically generate docstrings for your pull request. This feature will be included in our Pro Plan when released.


📜 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 e011a76 and c7a2a4d.

📒 Files selected for processing (1)
  • src/components/Common/Export.tsx (5 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/components/Common/Export.tsx

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 Dec 12, 2024

Deploy Preview for care-ohc ready!

Name Link
🔨 Latest commit c7a2a4d
🔍 Latest deploy log https://app.netlify.com/sites/care-ohc/deploys/675e857eb2a3aa0008a30153
😎 Deploy Preview https://deploy-preview-9392--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

🧹 Outside diff range and nitpick comments (2)
src/components/Assets/AssetsList.tsx (2)

190-215: Consider documenting keyboard shortcuts

The search configuration is well-structured with keyboard shortcuts for better accessibility. Consider adding documentation or tooltips to inform users about these shortcuts (n: Name, p: Serial Number, u: QR Code ID).

 const searchOptions = [
   {
     key: "name",
     label: "Name",
     type: "text" as const,
-    placeholder: "Search by Name",
+    placeholder: "Search by Name (Alt+N)",
     value: qParams.name || undefined,
     shortcutKey: "n",
   },
   {
     key: "serial_number",
     label: "Serial Number",
     type: "text" as const,
-    placeholder: "Search by Serial Number",
+    placeholder: "Search by Serial Number (Alt+P)",
     value: qParams.serial_number || undefined,
     shortcutKey: "p",
   },
   {
     key: "asset_qr_id",
     label: "QR Code ID",
     type: "text" as const,
-    placeholder: "Search by QR Code ID",
+    placeholder: "Search by QR Code ID (Alt+U)",
     value: qParams.qr_code_id || undefined,
     shortcutKey: "u",
   },
 ];

388-440: Consider improving menu accessibility

The Export Menu could benefit from ARIA labels for better screen reader support.

 <ExportMenu
+  aria-label="Import and export assets menu"
   label={
     importAssetModalOpen ? "Importing..." : "Import/Export"
   }
   exportItems={[
     {
       label: "Import Assets",
+      options: {
+        ...options,
+        "aria-label": "Import assets from file",
+      },
     },
     {
       label: "Export Assets (JSON)",
+      options: {
+        ...options,
+        "aria-label": "Export assets as JSON file",
+      },
     },
     {
       label: "Export Assets (CSV)",
+      options: {
+        ...options,
+        "aria-label": "Export assets as CSV file",
+      },
     },
   ]}
 />
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 1fb976b and e662368.

📒 Files selected for processing (1)
  • src/components/Assets/AssetsList.tsx (6 hunks)
🔇 Additional comments (3)
src/components/Assets/AssetsList.tsx (3)

31-31: LGTM: Search functionality improvements

The changes enhance the search capabilities by introducing the SearchByMultipleFields component and properly configuring the cache exclusions for search fields.

Also applies to: 42-42, 45-45


Line range hint 352-443: LGTM: Improved button layout and responsiveness

The reorganization of buttons and search elements improves the UI with better spacing and responsive behavior.


447-462: LGTM: Search integration

The integration of the search component with the count block provides a clean and functional layout.

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.

LGTM, but let's switch to using Button instead of ButtonV2 in the entire AssetList.tsx file too. We are moving away to using shadcn UI components in all new files changed.

Button: https://github.com/ohcnetwork/care_fe/blob/develop/src/components/ui/button.tsx

@manmeetnagii
Copy link
Contributor Author

LGTM, but let's switch to using Button instead of ButtonV2 in the entire AssetList.tsx file too. We are moving away to using shadcn UI components in all new files changed.

Button: https://github.com/ohcnetwork/care_fe/blob/develop/src/components/ui/button.tsx

Got it!

@manmeetnagii
Copy link
Contributor Author

manmeetnagii commented Dec 12, 2024

LGTM, but let's switch to using Button instead of ButtonV2 in the entire AssetList.tsx file too. We are moving away to using shadcn UI components in all new files changed.

Button: https://github.com/ohcnetwork/care_fe/blob/develop/src/components/ui/button.tsx

In Button: https://github.com/ohcnetwork/care_fe/blob/develop/src/components/ui/button.tsx the primary

LGTM, but let's switch to using Button instead of ButtonV2 in the entire AssetList.tsx file too. We are moving away to using shadcn UI components in all new files changed.

Button: https://github.com/ohcnetwork/care_fe/blob/develop/src/components/ui/button.tsx

@rithviknishad, the background color of the Shadcn button with the primary variant is bg-green-700, but in the deployed one, the ButtonV2 has bg-green-500. Should I change it to bg-500 or keep it as it is?

@github-actions github-actions bot added needs-triage question Further information is requested labels Dec 12, 2024
@rithviknishad
Copy link
Member

Skip modifying button.tsx It's as per our new figma designs. So stick with 700 shade.

@rithviknishad rithviknishad removed question Further information is requested needs-triage labels Dec 12, 2024
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 and nitpick comments (4)
src/components/Assets/AssetsList.tsx (2)

465-465: Update the id prop to match the component purpose

The id prop is currently set to "patient-search", which seems to be a copy-paste error. Update it to "asset-search" for clarity and consistency with the assets context.

Apply this diff:

-id="patient-search"
+id="asset-search"

200-218: Reconsider shortcutKey assignments for better intuitiveness

The shortcutKey values assigned to the search options may not be intuitive. Consider using keys that align with the initial letters of the search fields to enhance user experience.

Suggested changes:

{
  key: "name",
  label: "Name",
  type: "text" as const,
  placeholder: "Search by Name",
  value: qParams.name || undefined,
- shortcutKey: "n",
+ shortcutKey: "n", // 'n' for 'name' is appropriate
},
{
  key: "serial_number",
  label: "Serial Number",
  type: "text" as const,
  placeholder: "Search by Serial Number",
  value: qParams.serial_number || undefined,
- shortcutKey: "p",
+ shortcutKey: "s", // 's' for 'serial_number' is more intuitive
},
{
  key: "asset_qr_id",
  label: "QR Code ID",
  type: "text" as const,
  placeholder: "Search by QR Code ID",
  value: qParams.qr_code_id || undefined,
- shortcutKey: "u",
+ shortcutKey: "q", // 'q' for 'QR Code ID' improves clarity
},
src/components/Common/Export.tsx (2)

Line range hint 53-72: Ensure consistent styling for Button components

While replacing ButtonV2 with the new Button component, verify that the variant and size props are appropriately set to maintain consistent styling across the application. Review the custom className properties to minimize redundancy.

Consider adjusting the button properties:

<Button
-  variant={"outline_primary"}
-  className="py-2.5"
+  variant="outline"
+  size="lg"
>

Line range hint 119-144: Check Button component styling in ExportButton

Ensure that the Button component in ExportButton adheres to the standard styling guidelines. Use size and variant props instead of extensive custom classes to maintain consistency.

Suggested adjustments:

<Button
-  className="tooltip mx-2 p-4 text-lg text-secondary-800 disabled:bg-transparent disabled:text-secondary-500"
+  variant="secondary"
+  size="lg"
+  className="tooltip mx-2"
>

This reduces reliance on custom styles and utilizes standardized properties.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between e662368 and 6a3670d.

📒 Files selected for processing (3)
  • src/CAREUI/interactive/FiltersSlideover.tsx (2 hunks)
  • src/components/Assets/AssetsList.tsx (8 hunks)
  • src/components/Common/Export.tsx (6 hunks)
🔇 Additional comments (1)
src/CAREUI/interactive/FiltersSlideover.tsx (1)

63-72: LGTM

The replacement of ButtonV2 with the new Button component is correctly implemented, and the properties are appropriately set for consistent styling.

Comment on lines 464 to 470
<SearchByMultipleFields
id="patient-search"
options={searchOptions}
onSearch={(key, value) => updateQuery({ search: value })}
clearSearch={clearSearch}
className="w-full"
/>
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix 'onSearch' handler to correctly update query parameters

The onSearch function currently updates the search query parameter regardless of which field is being searched. To properly handle multiple search fields (name, serial_number, asset_qr_id), use the key parameter to update the corresponding query parameter.

Apply this diff to fix the issue:

-onSearch={(key, value) => updateQuery({ search: value })}
+onSearch={(key, value) => updateQuery({ [key]: value })}
📝 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
<SearchByMultipleFields
id="patient-search"
options={searchOptions}
onSearch={(key, value) => updateQuery({ search: value })}
clearSearch={clearSearch}
className="w-full"
/>
<SearchByMultipleFields
id="patient-search"
options={searchOptions}
onSearch={(key, value) => updateQuery({ [key]: value })}
clearSearch={clearSearch}
className="w-full"
/>

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 and nitpick comments (1)
src/components/Assets/AssetsList.tsx (1)

194-219: Consider enhancing type safety for search options.

While the search configuration is well-structured, we can improve type safety by defining an interface for the search options.

Consider applying this change:

+interface SearchOption {
+  key: 'name' | 'serial_number' | 'asset_qr_id';
+  label: string;
+  type: 'text';
+  placeholder: string;
+  value: string | undefined;
+  shortcutKey: string;
+}

-const searchOptions = [
+const searchOptions: SearchOption[] = [
   {
     key: "name",
     // ... rest remains the same
   },
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 6a3670d and ca130ab.

📒 Files selected for processing (1)
  • src/components/Assets/AssetsList.tsx (8 hunks)
🔇 Additional comments (3)
src/components/Assets/AssetsList.tsx (3)

Line range hint 20-33: LGTM! Hook configuration aligns with enhanced search functionality.

The addition of SearchByMultipleFields and Button components, along with the updated useFilters configuration, properly supports the new multi-field search feature.

Also applies to: 43-47


Line range hint 356-450: LGTM! Button layout improvements with proper responsive design.

The updated button layout:

  • Uses the new Button component as requested in PR comments
  • Maintains proper authorization checks
  • Implements responsive design with appropriate flex classes

464-470: ⚠️ Potential issue

Fix 'onSearch' handler to correctly update query parameters.

The onSearch function currently updates the 'search' query parameter regardless of which field is being searched. This issue was previously identified and still needs to be fixed.

Apply this diff to fix the issue:

-onSearch={(key, value) => updateQuery({ search: value })}
+onSearch={(key, value) => updateQuery({ [key]: value })}

src/components/Assets/AssetsList.tsx Show resolved Hide resolved
@manmeetnagii
Copy link
Contributor Author

@rithviknishad review this

@rithviknishad
Copy link
Member

cypress tests are failing

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (3)
src/components/Assets/AssetsList.tsx (3)

Line range hint 137-198: Consider extracting QR code scanning logic

The QR code scanning logic is complex and handles multiple responsibilities. Consider extracting it into a separate custom hook for better maintainability and reusability.

+// Create a new file: hooks/useQRScanner.ts
+export const useQRScanner = () => {
+  const { t } = useTranslation();
+
+  const scanAssetQR = async (assetURL: string) => {
+    // ... existing logic ...
+  };
+
+  return { scanAssetQR };
+};

-const accessAssetIdFromQR = async (assetURL: string) => {
-  // ... existing logic ...
-};

+const { scanAssetQR } = useQRScanner();

Line range hint 362-377: Consider using consistent button variants

The button implementation looks good but consider using consistent size and width props across all buttons for better UI consistency.

-<Button
-  disabled={isDisabled}
-  variant={"primary"}
-  size={"lg"}
-  className="gap-2 w-full lg:w-fit"
+<Button
+  disabled={isDisabled}
+  variant="default"
+  size="default"
+  className="gap-2 w-full lg:w-fit"

Line range hint 578-632: Optimize date calculations in warrantyAmcValidityChip

The function is well-structured but consider memoizing the date calculations to prevent unnecessary recalculations on re-renders.

+import { useMemo } from 'react';

-export const warrantyAmcValidityChip = (
+export const warrantyAmcValidityChip = useMemo((
   warranty_amc_end_of_validity: string,
-) => {
+) => {
   // ... existing logic ...
-};
+}, [warranty_amc_end_of_validity]);
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between ca130ab and bac9003.

📒 Files selected for processing (1)
  • src/components/Assets/AssetsList.tsx (7 hunks)
🔇 Additional comments (3)
src/components/Assets/AssetsList.tsx (3)

31-32: LGTM: Clean import of new components

The addition of SearchByMultipleFields and Button components aligns with the PR objectives and maintains good code organization.


467-473: ⚠️ Potential issue

Fix SearchByMultipleFields implementation

The onSearch handler is not utilizing the key parameter, which defeats the purpose of having multiple search fields.

Apply this fix to properly handle multiple search fields:

-onSearch={(key, value) => updateQuery({ search: value })}
+onSearch={(key, value) => updateQuery({ [key]: value })}

43-46: Verify clearSearch implementation for multiple search fields

The clearSearch function is added but its implementation needs verification to ensure it properly clears all search fields (name, serial_number, qr_code_id).

✅ Verification successful

Let me try to find the implementation of clearSearch and useFilters to verify how the search fields are being cleared.


I need to see the full implementation of useFilters and SearchByMultipleFields to understand how the clearSearch functionality is implemented and verify if it properly handles multiple search fields.


Let me try with different patterns to find these implementations, as the previous search didn't yield results.


From the earlier search results, I can see that:

  1. The clearSearch functionality is implemented in SearchByMultipleFields component and checks for specific params to clear
  2. The useFilters hook manages the clearSearch state and provides it to components
  3. The implementation in AssetsList.tsx properly passes the clearSearch prop and includes all necessary fields (name, serial_number, qr_code_id) in the cacheBlacklist

The clearSearch implementation is properly configured for multiple search fields

The codebase shows that clearSearch is correctly implemented to handle multiple search fields:

  • The SearchByMultipleFields component checks clearSearch params against field keys
  • The cacheBlacklist in AssetsList includes all required fields: name, serial_number, and qr_code_id
  • The clearSearch functionality is consistently used across similar components (FacilityList, ManagePatients)
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for clearSearch implementation
rg "clearSearch.*=.*{" -A 5

Length of output: 127


Script:

#!/bin/bash
# Search for clearSearch implementation with fixed regex
rg "clearSearch" -A 5

# Also search for useFilters implementation
ast-grep --pattern 'const useFilters = $_'

Length of output: 6245


Script:

#!/bin/bash
# Let's look at the useFilters hook implementation
rg -A 20 "const useFilters = \(" src/hooks/useFilters.tsx

# And also check the SearchByMultipleFields component implementation
rg -A 20 "const SearchByMultipleFields = " src/components/Common/SearchByMultipleFields.tsx

Length of output: 153


Script:

#!/bin/bash
# Try different pattern to find useFilters implementation
ast-grep --pattern 'export const useFilters = $_'

# Also try to find the SearchByMultipleFields component with a different pattern
ast-grep --pattern 'export const SearchByMultipleFields: React.FC<$_> = $_'

Length of output: 129

@manmeetnagii
Copy link
Contributor Author

cypress tests are failing

@Jacobjeevan @rithviknishad checks done!

Comment on lines 79 to 85
disabled={isExporting || disabled}
title={isExporting ? "Exporting..." : label}
icon={<CareIcon icon="l-export" />}
className="tooltip border-primary-500 bg-white text-primary-500 hover:bg-primary-100 enabled:border"
className="tooltip border-primary-700 bg-white text-primary-700 hover:bg-primary-100 enabled:border"
>
{exportItems.map((item) => (
<DropdownItem
Copy link
Member

Choose a reason for hiding this comment

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

Let's switch to dropdown from shadcn too since you've touched this file

https://ui.shadcn.com/docs/components/dropdown-menu

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (4)
src/components/Common/Export.tsx (4)

Line range hint 58-77: Consider standardizing button styling

The gap-2 class is used in the dropdown trigger button but not here. Consider standardizing the spacing across all export buttons for consistency.

-      <Button
+      <Button
         variant={"outline_primary"}
         disabled={isExporting || disabled}
         onClick={() => {
           let action = item.action;
           if (item.route) {
             action = async () => {
               const { data } = await request(item.route!);
               return data ?? null;
             };
           }
           if (action) {
             exportFile(action, item.filePrefix, item.type, item.parse);
           }
         }}
-        className="py-2.5"
+        className="py-2.5 gap-2"
       >

96-117: Refactor click handler for better maintainability

The onClick handler logic is duplicated between single export and menu items. Consider extracting this into a reusable function.

+  const handleExport = (item: ExportItem) => {
+    let action = item.action;
+    if (item.route) {
+      action = async () => {
+        const { data } = await request(item.route!);
+        return data ?? null;
+      };
+    }
+    if (action) {
+      exportFile(action, item.filePrefix, item.type, item.parse);
+    }
+  };

   return (
     <div key={item.label}
-      onClick={() => {
-        let action = item.action;
-        if (item.route) {
-          action = async () => {
-            const { data } = await request(item.route!);
-            return data ?? null;
-          };
-        }
-        if (action) {
-          exportFile(action, item.filePrefix, item.type, item.parse);
-        }
-      }}
+      onClick={() => handleExport(item)}
       {...item.options}
     >

Line range hint 135-160: Simplify button styling

The className combines multiple concerns which could be separated for better maintainability. Consider using the cn utility to compose classes conditionally.

-        className="tooltip mx-2 p-4 text-lg text-secondary-800 disabled:bg-transparent disabled:text-secondary-500"
+        className={cn(
+          "tooltip mx-2 p-4 text-lg",
+          "text-secondary-800",
+          "disabled:bg-transparent disabled:text-secondary-500"
+        )}

No ButtonV2 instances found in Export.tsx, but migration incomplete in other files

The file src/components/Common/Export.tsx has been properly migrated to use the new shadcn Button component from "../ui/button". However, there are still numerous files in the codebase that are using the old ButtonV2 component, including:

  • User management components (src/components/Users/)
  • Shifting components (src/components/Shifting/)
  • Resource components (src/components/Resource/)
  • Patient components (src/components/Patient/)
  • Facility components (src/components/Facility/)
  • And many others
🔗 Analysis chain

Line range hint 1-165: Verify complete migration from ButtonV2

Let's ensure all instances of ButtonV2 have been replaced with the shadcn Button component in this file.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any remaining ButtonV2 instances in the file
rg "ButtonV2" src/components/Common/Export.tsx

Length of output: 46


Script:

#!/bin/bash
# Let's verify the Button imports and usage in the file
rg -A 1 "import.*Button" src/components/Common/Export.tsx

# Also check if there are any other files still using ButtonV2
rg "ButtonV2" --type ts --type tsx

Length of output: 170


Script:

#!/bin/bash
# Check for ButtonV2 usage across all files (without file type restriction)
rg "ButtonV2"

# Verify the Button import and its usage in Export.tsx
rg -C 2 "Button" src/components/Common/Export.tsx

Length of output: 45522

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 1b02dc2 and e011a76.

📒 Files selected for processing (2)
  • src/components/Assets/AssetsList.tsx (7 hunks)
  • src/components/Common/Export.tsx (5 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/components/Assets/AssetsList.tsx
🔇 Additional comments (1)
src/components/Common/Export.tsx (1)

12-18: LGTM! Proper migration to shadcn components

The imports have been correctly updated to use shadcn UI components for both Button and DropdownMenu, which aligns with the project's direction and addresses the previous review feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

Enhancement: Update the button layout in Assets Page
2 participants