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

refactor(my-pages): replace filter with UI core filter #17510

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

Conversation

disaerna
Copy link
Member

@disaerna disaerna commented Jan 15, 2025

My pages - Filter

Delete special my pages filter and use Island UI component instead

Checklist:

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • Formatting passes locally with my changes
  • I have rebased against main before asking for a review

Summary by CodeRabbit

Release Notes

  • Refactoring

    • Removed Filter component and associated CSS styles
    • Reorganized component and utility exports in core library
    • Updated layout of various finance and document filter components using Inline component
  • Component Changes

    • Simplified filter interfaces across multiple screens
    • Moved export and print buttons outside of filter components
    • Adjusted import structures in multiple files
  • Performance

    • Streamlined component organization
    • Removed unused imports and components

These changes primarily focus on improving the structure and maintainability of the UI components without significantly altering core functionality.

@disaerna disaerna requested review from a team as code owners January 15, 2025 13:44
@disaerna disaerna requested a review from sigruntg January 15, 2025 13:44
Copy link
Contributor

coderabbitai bot commented Jan 15, 2025

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 eslint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

warning [email protected]: This version is no longer supported. Please see https://eslint.org/version-support for other options.
warning eslint > @humanwhocodes/[email protected]: Use @eslint/config-array instead
warning eslint > @humanwhocodes/config-array > @humanwhocodes/[email protected]: Use @eslint/object-schema instead
warning eslint > file-entry-cache > flat-cache > [email protected]: Rimraf versions prior to v4 are no longer supported
warning eslint > file-entry-cache > flat-cache > rimraf > [email protected]: Glob versions prior to v9 are no longer supported
warning eslint > file-entry-cache > flat-cache > rimraf > glob > [email protected]: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
warning jest > @jest/core > jest-config > [email protected]: Glob versions prior to v9 are no longer supported
warning jest > @jest/core > jest-runtime > [email protected]: Glob versions prior to v9 are no longer supported
warning jest > @jest/core > @jest/reporters > [email protected]: Glob versions prior to v9 are no longer supported
warning jest > @jest/core > @jest/transform > babel-plugin-istanbul > test-exclude > [email protected]: Glob versions prior to v9 are no longer supported
warning storybook > @storybook/cli > puppeteer-core > [email protected]: Rimraf versions prior to v4 are no longer supported
warning storybook > @storybook/cli > puppeteer-core > rimraf > [email protected]: Glob versions prior to v9 are no longer supported
warning storybook > @storybook/cli > tempy > del > [email protected]: Rimraf versions prior to v4 are no longer supported
warning storybook > @storybook/cli > jscodeshift > temp > [email protected]: Rimraf versions prior to v4 are no longer supported
warning storybook > @storybook/cli > jscodeshift > temp > rimraf > [email protected]: Glob versions prior to v9 are no longer supported
warning storybook > @storybook/cli > jscodeshift > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-class-properties instead.
warning storybook > @storybook/cli > jscodeshift > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-optional-chaining instead.
warning storybook > @storybook/cli > jscodeshift > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-nullish-coalescing-operator instead.
warning react-native > @react-native/codegen > [email protected]: Glob versions prior to v9 are no longer supported
warning react-native > @react-native/community-cli-plugin > [email protected]: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
warning react-native > @react-native-community/cli > @react-native-community/cli-tools > [email protected]: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.
warning react-native > @react-native/community-cli-plugin > @react-native/dev-middleware > @rnx-kit/chromium-edge-launcher > [email protected]: Rimraf versions prior to v4 are no longer supported
warning react-native > @react-native/community-cli-plugin > @react-native/metro-babel-transformer > @react-native/babel-preset > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-class-properties instead.
warning react-native > @react-native/community-cli-plugin > @react-native/metro-babel-transformer > @react-native/babel-preset > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-optional-chaining instead.
warning react-native > @react-native/community-cli-plugin > @react-native/metro-babel-transformer > @react-native/babel-preset > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-nullish-coalescing-operator instead.
warning react-native > @react-native/community-cli-plugin > @react-native/metro-babel-transformer > @react-native/babel-preset > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-numeric-separator instead.
warning react-native > @react-native/community-cli-plugin > @react-native/metro-babel-transformer > @react-native/babel-preset > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-object-rest-spread instead.
warning react-native > @react-native/community-cli-plugin > @react-native/metro-babel-transformer > @react-native/babel-preset > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-optional-catch-binding instead.
warning react-native > @react-native/community-cli-plugin > @react-native/metro-babel-transformer > @react-native/babel-preset > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-logical-assignment-operators instead.
warning react-native > @react-native/community-cli-plugin > @react-native/metro-babel-transformer > @react-native/babel-preset > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-async-generator-functions instead.
warning next-auth > [email protected]: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
warning next-auth > [email protected]: this version is no longer supported
warning next-auth > @next-auth/typeorm-legacy-adapter > typeorm > [email protected]: Glob versions prior to v9 are no longer supported
warning @nx/next > @nx/webpack > stylus > [email protected]: Glob versions prior to v9 are no longer supported
warning @nx/next > @nx/webpack > webpack-dev-server > [email protected]: Rimraf versions prior to v4 are no longer supported
warning @nx/next > @nx/webpack > fork-ts-checker-webpack-plugin > [email protected]: this will be v4
warning @nx/next > @nx/webpack > webpack-dev-server > webpack-dev-middleware > [email protected]: this will be v4
warning workspace-aggregator-73222e92-4239-4907-b74f-7c8f0cab0f8a > [email protected]: This version is no longer supported. Please see https://eslint.org/version-support for other options.

Walkthrough

The pull request involves a comprehensive refactoring of filter components across multiple files in the my-pages portals. The primary changes include removing the standalone Filter component, reorganizing import statements, and modifying the layout of filter interfaces by introducing Inline components. The changes affect multiple screens and components, focusing on improving the structure and flexibility of filter implementations while maintaining existing functionality.

Changes

File Change Summary
libs/portals/my-pages/assets/src/screens/WorkMachinesOverview/WorkMachinesOverview.tsx Reorganized import statements, added DropdownMenu for file export
libs/portals/my-pages/core/src/components/Filter/Filter.css.ts Deleted file containing style definitions
libs/portals/my-pages/core/src/components/Filter/Filter.tsx Deleted React component with filtering functionality
libs/portals/my-pages/core/src/index.ts Significant export modifications, removing and adding multiple components and utilities
libs/portals/my-pages/documents/src/components/DocumentFilter/DocumentsFilterV2.tsx Updated imports, modified Filter component properties
libs/portals/my-pages/finance/src/components/* Multiple files updated with Inline component and filter layout changes
libs/portals/my-pages/finance/src/screens/FinanceLoans/FinanceLoans.tsx Removed unused imports
libs/portals/my-pages/finance/src/screens/FinanceTransactions/FinanceTransactions.tsx Reorganized filter UI components

Possibly related PRs

Suggested Labels

automerge, deploy-feature

Suggested Reviewers

  • thordurhhh
  • Toti91
  • mannipje

Finishing Touches

  • 📝 Generate Docstrings (Beta)

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.

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.

@disaerna disaerna removed request for a team and sigruntg January 15, 2025 13:45
@disaerna disaerna marked this pull request as draft January 15, 2025 13:45
@disaerna disaerna marked this pull request as ready for review January 15, 2025 13:45
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 (8)
libs/portals/my-pages/finance/src/components/HousingBenefitsPayments/HousingBenefitsFilter.tsx (1)

209-226: Consider adding loading and error states for export actions.

The export functionality should handle loading and error states to provide better user feedback during file generation.

 <DropdownExport
+  isLoading={isExporting}
+  onError={(error) => {
+    // Handle export error
+    console.error('Export failed:', error);
+  }}
   onGetCSV={() => exportHousingBenefitFiles(payments?.data ?? [], 'csv')}
   onGetExcel={() =>
     exportHousingBenefitFiles(payments?.data ?? [], 'xlsx')
   }
 />
libs/portals/my-pages/documents/src/components/DocumentFilter/DocumentsFilterV2.tsx (1)

101-101: Consider using consistent input sizes across filters.

The input size is set to xs, which differs from other filter implementations. Consider standardizing input sizes across all filter components for consistency.

libs/portals/my-pages/assets/src/screens/WorkMachinesOverview/WorkMachinesOverview.tsx (1)

224-224: Remove empty grid column.

The grid column with an empty fragment ({}) appears to serve no purpose and should be removed.

-<GridColumn span={'4/12'}>{}</GridColumn>
libs/portals/my-pages/finance/src/screens/FinanceTransactions/FinanceTransactions.tsx (2)

126-165: Consider optimizing date filter initialization.

The date filter initialization could be simplified by setting initial dates in a single useEffect, reducing potential re-renders.

-  useEffect(() => {
-    setFromDate(backInTheDay)
-    setToDate(new Date())
-    // eslint-disable-next-line react-hooks/exhaustive-deps
-  }, [])
+  useEffect(() => {
+    const today = new Date()
+    setFromDate(sub(today, { months: 3 }))
+    setToDate(today)
+  }, [])

146-166: Consider memoizing FilterMultiChoice categories.

The categories array is recreated on every render. Consider memoizing it using useMemo to optimize performance.

+ const filterCategories = useMemo(() => [
+   {
+     id: 'flokkur',
+     label: formatMessage(messages.transactionsLabel),
+     labelAs: 'h2',
+     selected: dropdownSelect ? [...dropdownSelect] : [],
+     filters: chargeTypeSelect,
+     inline: false,
+     singleOption: false,
+   },
+ ], [dropdownSelect, chargeTypeSelect, formatMessage])

  <FilterMultiChoice
    labelClear={formatMessage(m.clearSelected)}
    singleExpand={true}
    onChange={({ selected }) => setDropdownSelect(selected)}
    onClear={() => setEmptyChargeTypes()}
-   categories={[...]}
+   categories={filterCategories}
  />
libs/portals/my-pages/finance/src/components/DocumentScreen/DocumentScreen.tsx (2)

113-120: Simplify flex container properties.

The Box component's flex properties can be simplified by using the Stack component from island-ui/core.

- <Box
-   display="flex"
-   flexDirection="row"
-   justifyContent="flexStart"
-   flexWrap="wrap"
-   rowGap={2}
-   columnGap={2}
- >
+ <Stack space={2} direction="row" align="center" wrap>

Line range hint 167-192: Enhance date picker accessibility.

Consider adding aria-labels and helper text to improve the date picker's accessibility.

 <DatePicker
   label={formatMessage(m.datepickerFromLabel)}
   placeholderText={formatMessage(m.datepickLabel)}
   locale="is"
   backgroundColor="blue"
   size="xs"
   handleChange={(d) => setFromDate(d)}
   selected={fromDate}
   appearInline
+  aria-label={formatMessage(m.datepickerFromLabel)}
+  helperText={formatMessage(m.datepickerHelperText)}
 />
libs/portals/my-pages/finance/src/components/FinanceTransactionPeriods/FinanceTransactionPeriodsFilter.tsx (1)

171-202: Enhance type safety for filter categories.

Consider creating a dedicated type for filter categories to improve type safety and maintainability.

+ type FilterCategory = {
+   id: 'years' | 'flokkur';
+   label: string;
+   selected: string[];
+   filters: Array<{ label: string; value: string }>;
+   inline: boolean;
+   singleOption: boolean;
+ };

  <FilterMultiChoice
    labelClear={formatMessage(m.clearSelected)}
    singleExpand={true}
-   categories={[...]}
+   categories={categories as FilterCategory[]}
  />
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1a42953 and 8553ae2.

📒 Files selected for processing (10)
  • libs/portals/my-pages/assets/src/screens/WorkMachinesOverview/WorkMachinesOverview.tsx (3 hunks)
  • libs/portals/my-pages/core/src/components/Filter/Filter.css.ts (0 hunks)
  • libs/portals/my-pages/core/src/components/Filter/Filter.tsx (0 hunks)
  • libs/portals/my-pages/core/src/index.ts (1 hunks)
  • libs/portals/my-pages/documents/src/components/DocumentFilter/DocumentsFilterV2.tsx (2 hunks)
  • libs/portals/my-pages/finance/src/components/DocumentScreen/DocumentScreen.tsx (4 hunks)
  • libs/portals/my-pages/finance/src/components/FinanceTransactionPeriods/FinanceTransactionPeriodsFilter.tsx (2 hunks)
  • libs/portals/my-pages/finance/src/components/HousingBenefitsPayments/HousingBenefitsFilter.tsx (2 hunks)
  • libs/portals/my-pages/finance/src/screens/FinanceLoans/FinanceLoans.tsx (1 hunks)
  • libs/portals/my-pages/finance/src/screens/FinanceTransactions/FinanceTransactions.tsx (2 hunks)
💤 Files with no reviewable changes (2)
  • libs/portals/my-pages/core/src/components/Filter/Filter.css.ts
  • libs/portals/my-pages/core/src/components/Filter/Filter.tsx
✅ Files skipped from review due to trivial changes (1)
  • libs/portals/my-pages/finance/src/screens/FinanceLoans/FinanceLoans.tsx
🧰 Additional context used
📓 Path-based instructions (7)
libs/portals/my-pages/assets/src/screens/WorkMachinesOverview/WorkMachinesOverview.tsx (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
libs/portals/my-pages/finance/src/components/FinanceTransactionPeriods/FinanceTransactionPeriodsFilter.tsx (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
libs/portals/my-pages/finance/src/components/HousingBenefitsPayments/HousingBenefitsFilter.tsx (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
libs/portals/my-pages/finance/src/screens/FinanceTransactions/FinanceTransactions.tsx (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
libs/portals/my-pages/documents/src/components/DocumentFilter/DocumentsFilterV2.tsx (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
libs/portals/my-pages/finance/src/components/DocumentScreen/DocumentScreen.tsx (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
libs/portals/my-pages/core/src/index.ts (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
🔇 Additional comments (8)
libs/portals/my-pages/core/src/index.ts (1)

1-74: LGTM! Well-organized exports.

The exports are properly structured and grouped by type (components, hooks, utils). The removal of the Filter component aligns with the PR objective of replacing it with a UI core filter.

libs/portals/my-pages/finance/src/components/HousingBenefitsPayments/HousingBenefitsFilter.tsx (1)

81-207: LGTM! Well-structured filter implementation.

The filter implementation is clean and well-organized:

  • Uses the new UI core Filter component
  • Properly handles payment type selection
  • Includes date filtering with month/year selection
  • Maintains clear separation between filter controls and export functionality
libs/portals/my-pages/documents/src/components/DocumentFilter/DocumentsFilterV2.tsx (1)

1-27: LGTM! Well-organized imports and type definitions.

The imports are properly organized and the type definitions are clear and well-structured.

libs/portals/my-pages/assets/src/screens/WorkMachinesOverview/WorkMachinesOverview.tsx (1)

206-219: LGTM! Clean implementation of export functionality.

The export functionality is well-implemented using the DropdownMenu component with clear actions for CSV and Excel exports.

libs/portals/my-pages/finance/src/screens/FinanceTransactions/FinanceTransactions.tsx (2)

1-40: LGTM! Clean import organization.

The imports are well-organized, separating external dependencies from internal modules.


222-239: LGTM! Well-structured export functionality.

The export and print buttons are properly integrated into the Inline component, maintaining consistent spacing and alignment.

libs/portals/my-pages/finance/src/components/DocumentScreen/DocumentScreen.tsx (1)

208-215: LGTM! Well-implemented export functionality.

The export options are properly implemented with clear separation of concerns using dedicated utility functions.

libs/portals/my-pages/finance/src/components/FinanceTransactionPeriods/FinanceTransactionPeriodsFilter.tsx (1)

206-217: LGTM! Well-structured print functionality.

The print button is properly integrated into the Inline component with consistent styling.

Copy link
Member

@thorkellmani thorkellmani left a comment

Choose a reason for hiding this comment

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

LGTM

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

Successfully merging this pull request may close these issues.

2 participants