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

fix(social-insurance-maintenance): add warning #17205

Merged
merged 7 commits into from
Dec 16, 2024
Merged

Conversation

thorkellmani
Copy link
Member

@thorkellmani thorkellmani commented Dec 11, 2024

What

  • Conditional render of payment plan

Screenshots / Gifs

Attach Screenshots / Gifs to help reviewers understand the scope of the pull request

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

  • New Features

    • Updated messaging for payment plans, including new terminology and default messages.
    • Enhanced the IncomePlanDetail and PaymentPlan components with improved data fetching and rendering logic, incorporating feature flag checks.
  • Bug Fixes

    • Adjusted error handling and display logic for better user experience in the PaymentPlan component.
  • Chores

    • Removed unused components and added new ones for improved functionality.

Copy link
Contributor

coderabbitai bot commented Dec 11, 2024

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-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-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-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-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-e077e802-375a-43d4-b850-a9c31ae96239 > [email protected]: This version is no longer supported. Please see https://eslint.org/version-support for other options.

Walkthrough

The pull request introduces several modifications primarily focused on the messages.ts, IncomePlanDetail.tsx, and PaymentPlan.tsx files. Key changes include renaming a message related to social insurance from incomePlanTemporarilyUnavailable to paymentPlanTemporarilyUnavailable, along with updates to the associated ID and default message. Additionally, the IncomePlanDetail component has refined its display logic, while the PaymentPlan component has transitioned to using a lazy query for fetching previous payments, incorporating a feature flag to control visibility.

Changes

File Path Change Summary
libs/portals/my-pages/social-insurance-maintenance/src/lib/messages.ts - Renamed message: incomePlanTemporarilyUnavailablepaymentPlanTemporarilyUnavailable
- Updated ID: sp.social-insurance-maintenance:income-plan-temporarily-unavailablesp.social-insurance-maintenance:payment-plan-temporarily-unavailable
- Updated default message text.
libs/portals/my-pages/social-insurance-maintenance/src/screens/IncomePlanDetail/IncomePlanDetail.tsx - Replaced useGetIncomePlanDetailLazyQuery with useGetIncomePlanDetailQuery.
- Removed unnecessary useEffect hooks and local state management.
- Adjusted rendering logic for errors and loading states.
libs/portals/my-pages/social-insurance-maintenance/src/screens/PaymentPlan/PaymentPlan.tsx - Replaced useGetPreviousPaymentsQuery with useGetPreviousPaymentsLazyQuery.
- Introduced displayPaymentPlan state variable and feature flag check to control rendering of the payment plan.
- Adjusted rendering logic and replaced IntroHeader with IntroWrapper.

Possibly related PRs

Suggested labels

automerge

Suggested reviewers

  • ylfahfa

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. (Experiment)
  • @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.

@thorkellmani thorkellmani added the deploy-feature Deploys features to dev label Dec 11, 2024
@datadog-island-is
Copy link

datadog-island-is bot commented Dec 11, 2024

Datadog Report

All test runs 1cfa1f7 🔗

11 Total Test Services: 0 Failed, 10 Passed
➡️ Test Sessions change in coverage: 31 no change

Test Services
This report shows up to 10 services
Service Name Failed Known Flaky New Flaky Passed Skipped Total Time Code Coverage Change Test Service View
api 0 0 0 4 0 2.58s 1 no change Link
api-domains-auth-admin 0 0 0 18 0 12.62s 1 no change Link
api-domains-communications 0 0 0 5 0 35.61s 1 no change Link
api-domains-license-service 0 0 0 0 0 616.82ms 1 no change Link
application-system-api 0 0 0 46 0 2m 54.32s 1 no change Link
application-template-api-modules 0 0 0 118 0 2m 49.16s 1 no change Link
cms-translations 0 0 0 3 0 38.95s 1 no change Link
judicial-system-api 0 0 0 61 0 7.19s 1 no change Link
judicial-system-backend 0 0 0 21301 0 24m 36.01s 1 no change Link
services-user-notification 0 0 0 51 0 1m 40.76s 1 no change Link

@thorkellmani thorkellmani marked this pull request as ready for review December 11, 2024 14:46
@thorkellmani thorkellmani requested a review from a team as a code owner December 11, 2024 14:46
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: 3

🧹 Outside diff range and nitpick comments (1)
libs/portals/my-pages/social-insurance-maintenance/src/screens/IncomePlanDetail/IncomePlanDetail.tsx (1)

Line range hint 22-34: Avoid suppressing ESLint rules by properly handling dependencies in useEffect

You are suppressing the react-hooks/exhaustive-deps ESLint rule. Include featureFlagClient in the dependency array of the useEffect to ensure all dependencies are correctly accounted for.

Apply this diff to fix the issue:

 useEffect(() => {
   const isFlagEnabled = async () => {
     const ffEnabled = await featureFlagClient.getValue(
       `isServicePortalPaymentPlan2025Enabled`,
       false,
     )
     if (ffEnabled) {
       setDisplayPaymentPlan(ffEnabled as boolean)
     }
   }
   isFlagEnabled()
-  // eslint-disable-next-line react-hooks/exhaustive-deps
- }, [])
+ }, [featureFlagClient])
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 5c8c1b9 and 931cd96.

📒 Files selected for processing (3)
  • libs/portals/my-pages/social-insurance-maintenance/src/lib/messages.ts (1 hunks)
  • libs/portals/my-pages/social-insurance-maintenance/src/screens/IncomePlanDetail/IncomePlanDetail.tsx (1 hunks)
  • libs/portals/my-pages/social-insurance-maintenance/src/screens/PaymentPlan/PaymentPlan.tsx (2 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
libs/portals/my-pages/social-insurance-maintenance/src/screens/IncomePlanDetail/IncomePlanDetail.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/social-insurance-maintenance/src/screens/PaymentPlan/PaymentPlan.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/social-insurance-maintenance/src/lib/messages.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 (1)
libs/portals/my-pages/social-insurance-maintenance/src/lib/messages.ts (1)

125-128: LGTM

The message renaming and updates enhance clarity and consistency across the application.

Copy link

codecov bot commented Dec 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 35.76%. Comparing base (b2c44ee) to head (5af6f00).
Report is 31 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #17205      +/-   ##
==========================================
- Coverage   35.76%   35.76%   -0.01%     
==========================================
  Files        6931     6931              
  Lines      147974   147962      -12     
  Branches    42171    42165       -6     
==========================================
- Hits        52930    52925       -5     
+ Misses      95044    95037       -7     
Flag Coverage Δ
api 3.33% <ø> (ø)
api-domains-auth-admin 48.49% <ø> (ø)
api-domains-communications 39.42% <ø> (ø)
application-system-api 38.76% <ø> (ø)
application-template-api-modules 27.81% <ø> (ø)
cms 0.40% <ø> (ø)
cms-translations 38.76% <ø> (ø)
judicial-system-api 20.16% <ø> (ø)
judicial-system-backend 55.88% <ø> (ø)
services-user-notification 46.58% <ø> (ø)
web 2.43% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

see 4 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b2c44ee...5af6f00. Read the comment docs.

Copy link
Contributor

Affected services are: service-portal,
Feature deployment of your services will begin shortly. Your feature will be accessible here:
https://fixff-income-plan-beta.dev01.devland.is/minarsidur

Deployed services: service-portal.
Excluded services: ``

@thorkellmani thorkellmani changed the title fix: add warning fix(social-insurance-maintenance): add warning 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: 0

🧹 Outside diff range and nitpick comments (3)
libs/portals/my-pages/social-insurance-maintenance/src/screens/IncomePlanDetail/IncomePlanDetail.tsx (3)

Line range hint 34-45: Consider extracting conditional rendering logic

The nested ternary conditions make the code harder to read and maintain. Consider extracting these into separate components or using early returns.

Example refactor:

const renderContent = () => {
  if (error && !loading) {
    return <Problem error={error} noBorder={false} />;
  }
  
  if (!error && !loading && !data?.socialInsuranceIncomePlan) {
    return (
      <Problem
        type="no_data"
        noBorder={false}
        title={formatMessage(coreMessages.noData)}
        message={formatMessage(coreMessages.noDataFoundDetail)}
        imgSrc="./assets/images/sofa.svg"
      />
    );
  }
  
  return <Stack space={2}>...</Stack>;
};

Line range hint 61-67: Extract print functionality to a reusable hook

Consider creating a custom hook for print functionality that could be reused across components.

Example:

const usePrint = () => {
  const handlePrint = useCallback(() => {
    window.print();
  }, []);
  return handlePrint;
};

Line range hint 68-82: Use URL construction utilities for modify link

String concatenation for URL construction can be fragile. Consider using URL utilities or route constants.

Example:

import { joinUrl } from '@island.is/utils/url';

const modifyUrl = joinUrl(
  document.location.origin,
  formatMessage(m.incomePlanModifyLink)
);
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 931cd96 and c17382e.

📒 Files selected for processing (2)
  • libs/portals/my-pages/social-insurance-maintenance/src/screens/IncomePlanDetail/IncomePlanDetail.tsx (1 hunks)
  • libs/portals/my-pages/social-insurance-maintenance/src/screens/PaymentPlan/PaymentPlan.tsx (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • libs/portals/my-pages/social-insurance-maintenance/src/screens/PaymentPlan/PaymentPlan.tsx
🧰 Additional context used
📓 Path-based instructions (1)
libs/portals/my-pages/social-insurance-maintenance/src/screens/IncomePlanDetail/IncomePlanDetail.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."
🔇 Additional comments (2)
libs/portals/my-pages/social-insurance-maintenance/src/screens/IncomePlanDetail/IncomePlanDetail.tsx (2)

18-18: LGTM: Import changes align with new query strategy

The switch from lazy query to regular query hook simplifies the component's data fetching strategy.


25-25: Verify data fetching optimization

The unconditional query execution simplifies the code, but let's verify that this component is only mounted when the data is needed.

✅ Verification successful

Unconditional query execution is appropriate

The component is properly scoped and only rendered when needed, as evidenced by:

  • It's lazy-loaded and only used in a specific route /framfaersla/tekjuaaetlun/nuverandi
  • The route is protected by a scope check (ApiScope.internal)
  • It's marked as navHide: true in navigation, indicating it's only accessed through specific navigation flows
  • The component represents a detail view that inherently requires the data to be loaded
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check component usage to ensure it's only rendered when needed

# Look for parent components that render IncomePlanDetail
ast-grep --pattern 'import { IncomePlanDetail } from $_' -A 10
rg -l "IncomePlanDetail" | xargs rg "<IncomePlanDetail" -A 5

Length of output: 125


Script:

#!/bin/bash
# Let's try a broader search to find any references to IncomePlanDetail
rg "IncomePlanDetail" -B 2 -A 2

# Also search for route definitions that might render this component
rg -i "route.*incomePlan.*detail" -B 2 -A 2

Length of output: 5547

@thorkellmani thorkellmani added the automerge Merge this PR as soon as all checks pass label Dec 16, 2024
@kodiakhq kodiakhq bot merged commit c4bc9c4 into main Dec 16, 2024
31 checks passed
@kodiakhq kodiakhq bot deleted the fix/ff-income-plan branch December 16, 2024 16:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Merge this PR as soon as all checks pass deploy-feature Deploys features to dev
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants