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(inheritance-report): Prepaid finishups #15323

Merged
merged 2 commits into from
Jun 24, 2024
Merged

Conversation

albinagu
Copy link
Member

@albinagu albinagu commented Jun 22, 2024

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

    • Introduced additional fields (prePaidApplicant, prepaidInheritance, name, nationalId) for improved reporting of executor and spouse details.
  • Refactor

    • Streamlined asset section inclusion logic for a more structured approach.
    • Updated spacing in OverviewHeirs component for better layout consistency.
    • Renamed identifiers for applicant to prePaidApplicant for naming consistency.
  • Bug Fixes

    • Corrected provider and localization messages in data collection items.
  • Documentation

    • Added new localization messages for marital status provider title and subtitle.
  • Chores

    • Enhanced code readability and maintainability by using constants for option values.

@albinagu albinagu requested a review from a team as a code owner June 22, 2024 17:12
Copy link
Contributor

coderabbitai bot commented Jun 22, 2024

Walkthrough

The changes introduce new fields for applicants, executors, and spouses in the inheritance report application. The handling of assets in the OverviewAssets component has been refactored for better structure. Additional assets options, spacing adjustments, and renaming of identifiers for clarity have been made. Various imports and schema definitions have been updated to accommodate these modifications, enhancing consistency through predefined options.

Changes

File(s) Change Summary
libs/.../mappers.ts Introduced fields prePaidApplicant, prepaidInheritance, name, and nationalId for executor and spouse objects in the expandAnswers function.
libs/.../OverviewAssets/index.tsx Refactored asset section inclusion logic using structured flags for real estate, stocks, money, and other assets. Changed isPrePaid flag handling to streamline control flow.
libs/.../OverviewHeirs/index.tsx Adjusted marginTop values based on index for better element spacing.
libs/.../sections/applicant.ts Removed PREPAID_INHERITANCE import, affecting dependencies and control flow.
libs/.../sections/assets.ts Modified condition functions to use getValueViaPath for control flow based on prepaidInheritance object values. Added PrePaidInheritanceOptions import.
libs/.../sections/deceased.ts Updated space property value to containerGutter in a specific section for improved layout.
libs/.../sections/prepaidInheritance/applicant.ts Renamed identifiers to prePaidApplicant and adjusted field widths for consistency and clarity.
libs/.../sections/prepaidInheritance/dataCollection.ts Changed provider from TBD to MaritalStatusApi and updated title and subTitle properties in buildDataProviderItem.
libs/.../sections/prepaidInheritance/inheritance.ts Updated checkbox option values to use constants from PrePaidInheritanceOptions instead of hardcoding them.
libs/.../constants.ts Introduced PrePaidInheritanceOptions enum for consistency and readability.
libs/.../dataSchema.ts Added schema definitions for prePaidApplicant, adjusted executors schema, and included new validations for name and nationalId. Introduced PrePaidInheritanceOptions.
libs/.../messages.ts Added new localization messages for maritalStatusProviderTitle and maritalStatusProviderSubtitle.
libs/.../helpers.ts Modified getPrePaidOverviewSectionsToDisplay function to handle the isPrePaid flag and refactor asset type handling logic.

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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration 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
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

Outside diff range and nitpick comments (1)
libs/application/templates/inheritance-report/src/lib/utils/helpers.ts (1)

Line range hint 122-122: Consider using optional chaining for better safety.

To enhance code safety and readability, consider using optional chaining when accessing nested properties.

- const estateData = (application.externalData.syslumennOnEntry?.data as {
+ const estateData = (application.externalData.syslumennOnEntry?.data as? {
Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 92ff090 and 4f85e8a.

Files selected for processing (13)
  • libs/application/template-api-modules/src/lib/modules/templates/inheritance-report/utils/mappers.ts (1 hunks)
  • libs/application/templates/inheritance-report/src/fields/Overview/OverviewAssets/index.tsx (2 hunks)
  • libs/application/templates/inheritance-report/src/fields/Overview/OverviewHeirs/index.tsx (1 hunks)
  • libs/application/templates/inheritance-report/src/forms/sections/applicant.ts (1 hunks)
  • libs/application/templates/inheritance-report/src/forms/sections/assets.ts (10 hunks)
  • libs/application/templates/inheritance-report/src/forms/sections/deceased.ts (1 hunks)
  • libs/application/templates/inheritance-report/src/forms/sections/prepaidInheritance/applicant.ts (3 hunks)
  • libs/application/templates/inheritance-report/src/forms/sections/prepaidInheritance/dataCollection.ts (1 hunks)
  • libs/application/templates/inheritance-report/src/forms/sections/prepaidInheritance/inheritance.ts (2 hunks)
  • libs/application/templates/inheritance-report/src/lib/constants.ts (1 hunks)
  • libs/application/templates/inheritance-report/src/lib/dataSchema.ts (3 hunks)
  • libs/application/templates/inheritance-report/src/lib/messages.ts (1 hunks)
  • libs/application/templates/inheritance-report/src/lib/utils/helpers.ts (2 hunks)
Files skipped from review due to trivial changes (4)
  • libs/application/templates/inheritance-report/src/fields/Overview/OverviewHeirs/index.tsx
  • libs/application/templates/inheritance-report/src/forms/sections/deceased.ts
  • libs/application/templates/inheritance-report/src/forms/sections/prepaidInheritance/applicant.ts
  • libs/application/templates/inheritance-report/src/lib/messages.ts
Additional context used
Path-based instructions (9)
libs/application/templates/inheritance-report/src/forms/sections/prepaidInheritance/inheritance.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."
libs/application/templates/inheritance-report/src/forms/sections/prepaidInheritance/dataCollection.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."
libs/application/templates/inheritance-report/src/lib/constants.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."
libs/application/templates/inheritance-report/src/forms/sections/applicant.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."
libs/application/templates/inheritance-report/src/lib/utils/helpers.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."
libs/application/templates/inheritance-report/src/fields/Overview/OverviewAssets/index.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/application/template-api-modules/src/lib/modules/templates/inheritance-report/utils/mappers.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."
libs/application/templates/inheritance-report/src/lib/dataSchema.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."
libs/application/templates/inheritance-report/src/forms/sections/assets.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."
Biome
libs/application/templates/inheritance-report/src/lib/utils/helpers.ts

[error] 122-122: Change to an optional chain. (lint/complexity/useOptionalChain)

Unsafe fix: Change to an optional chain.

libs/application/templates/inheritance-report/src/lib/dataSchema.ts

[error] 169-171: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)

Unsafe fix: Omit the else clause.


[error] 181-183: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)

Unsafe fix: Omit the else clause.


[error] 560-561: Unnecessary use of boolean literals in conditional expression. (lint/complexity/noUselessTernary)

Simplify your code by directly assigning the result without using a ternary operator.
If your goal is negation, you may use the logical NOT (!) or double NOT (!!) operator for clearer and concise code.
Check for more details about NOT operator.
Unsafe fix: Remove the conditional expression with


[error] 88-88: isNaN is unsafe. It attempts a type coercion. Use Number.isNaN instead. (lint/suspicious/noGlobalIsNan)

See the MDN documentation for more details.
Unsafe fix: Use Number.isNaN instead.

Additional comments not posted (11)
libs/application/templates/inheritance-report/src/forms/sections/prepaidInheritance/inheritance.ts (1)

8-8: Ensure consistent import paths.

The import statement for PrePaidInheritanceOptions uses a relative path. Confirm if this aligns with the project's standards for import paths, especially for constants that might be used across various modules.

libs/application/templates/inheritance-report/src/forms/sections/prepaidInheritance/dataCollection.ts (1)

35-36: Localized titles and subtitles are correctly implemented.

The use of localized strings for the titles and subtitles ensures that the application supports internationalization. This change aligns with best practices for global applications.

libs/application/templates/inheritance-report/src/lib/constants.ts (1)

23-28: Enum values are correctly defined with string assignments.

Defining enum values as strings provides clarity and can be beneficial for debugging and logging. This is a good practice, especially when these values are used in UI components or are sent to/from external APIs.

libs/application/templates/inheritance-report/src/lib/utils/helpers.ts (1)

57-78: Refactored asset inclusion logic looks good!

The consolidation of asset inclusion logic into a single function using boolean flags derived from isPrePaid and selected options enhances readability and maintainability.

libs/application/templates/inheritance-report/src/fields/Overview/OverviewAssets/index.tsx (1)

36-37: Streamlined logic for asset inclusion is effective and maintainable.

The refactoring to use a consolidated approach for determining asset sections based on isPrePaid and answers enhances both the clarity and maintainability of the code.

Also applies to: 42-45, 47-51, 126-129, 131-135, 140-142, 149-152, 154-158

libs/application/template-api-modules/src/lib/modules/templates/inheritance-report/utils/mappers.ts (1)

104-117: Addition of new fields in expandAnswers function is well-implemented.

The inclusion of prePaidApplicant, prepaidInheritance, name, and nationalId fields for executor and spouse objects enhances the data handling capabilities of the module.

libs/application/templates/inheritance-report/src/lib/dataSchema.ts (1)

Line range hint 137-198: Schema enhancements for handling prepaid inheritance are well-defined.

The additions and modifications to the schema to include prePaidApplicant and prepaidInheritance options are well-implemented, enhancing both the robustness and functionality of the module.

libs/application/templates/inheritance-report/src/forms/sections/assets.ts (4)

8-8: Ensure consistent import usage.

The addition of getValueViaPath is used in the conditional logic for asset sections. This is a good use of utility functions to simplify the retrieval of deeply nested properties.


16-20: Confirm the import of constants.

The import of PrePaidInheritanceOptions is introduced, which is used for checking asset types in conditions. This is a correct and necessary change for the implemented logic.


114-114: Consistent conditional logic across sections.

The conditions for showing various asset sections based on PREPAID_INHERITANCE are implemented consistently. This ensures that the form adapts correctly based on the type of inheritance being processed.

Also applies to: 176-176, 243-243, 305-305, 390-390


448-451: Validate inclusion logic for specific asset types.

The conditions for including specific asset types like stocks, money, and other assets are correctly using the PrePaidInheritanceOptions to check against the prepaidInheritance answers. This is a robust way to dynamically include sections based on form responses.

Also applies to: 536-539, 620-623

@datadog-island-is
Copy link

datadog-island-is bot commented Jun 22, 2024

Datadog Report

All test runs 48cd599 🔗

14 Total Test Services: 0 Failed, 13 Passed
⬆️ Test Sessions change in coverage: 1 increased (+0.01%), 22 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 4.78s 1 no change Link
api-domains-driving-license 0 0 0 23 0 50.54s 1 no change Link
api-domains-license-service 0 0 0 0 0 804.94ms 1 no change Link
api-domains-mortgage-certificate 0 0 0 4 0 29.16s 1 no change Link
application-api-files 0 0 0 12 0 16.76s 1 no change Link
application-system-api 0 0 0 111 2 2m 54.41s 1 no change Link
application-template-api-modules 0 0 0 109 0 2m 38.58s 1 no change Link
application-templates-driving-license 0 0 0 13 0 38.71s 1 no change Link
application-templates-general-petition 0 0 0 5 0 27.3s 1 no change Link
application-ui-shell 0 0 0 74 0 39.31s 1 no change Link

Copy link

codecov bot commented Jun 22, 2024

Codecov Report

Attention: Patch coverage is 0% with 43 lines in your changes missing coverage. Please review.

Project coverage is 37.07%. Comparing base (96759ea) to head (8ff801c).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #15323      +/-   ##
==========================================
- Coverage   37.07%   37.07%   -0.01%     
==========================================
  Files        6508     6508              
  Lines      132437   132440       +3     
  Branches    37874    37878       +4     
==========================================
  Hits        49102    49102              
- Misses      83335    83338       +3     
Flag Coverage Δ
application-system-api 42.13% <ø> (ø)
application-templates-inheritance-report 4.65% <0.00%> (-0.02%) ⬇️
application-ui-shell 21.62% <ø> (ø)
clients-driving-license 40.39% <ø> (ø)
clients-license-client 1.84% <ø> (ø)
clients-syslumenn 49.26% <ø> (ø)
license-api 43.17% <ø> (ø)
web 1.91% <ø> (ø)

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

Files Coverage Δ
...ules/templates/inheritance-report/utils/mappers.ts 3.14% <ø> (ø)
...inheritance-report/src/forms/sections/applicant.ts 0.00% <ø> (ø)
.../inheritance-report/src/forms/sections/deceased.ts 0.00% <ø> (ø)
...src/forms/sections/prepaidInheritance/applicant.ts 0.00% <ø> (ø)
...orms/sections/prepaidInheritance/dataCollection.ts 0.00% <ø> (ø)
...c/forms/sections/prepaidInheritance/inheritance.ts 0.00% <ø> (ø)
.../templates/inheritance-report/src/lib/constants.ts 100.00% <ø> (ø)
...n/templates/inheritance-report/src/lib/messages.ts 100.00% <ø> (ø)
...report/src/fields/Overview/OverviewHeirs/index.tsx 0.00% <0.00%> (ø)
...templates/inheritance-report/src/lib/dataSchema.ts 0.00% <0.00%> (ø)
... and 3 more

... and 1 file 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 96759ea...8ff801c. Read the comment docs.

Copy link
Member

@juni-haukur juni-haukur left a comment

Choose a reason for hiding this comment

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

lgtm

@albinagu albinagu added the automerge Merge this PR as soon as all checks pass label Jun 24, 2024
@kodiakhq kodiakhq bot merged commit 3c50256 into main Jun 24, 2024
47 checks passed
@kodiakhq kodiakhq bot deleted the efs_prepaid_finishups branch June 24, 2024 10:35
@coderabbitai coderabbitai bot mentioned this pull request Nov 7, 2024
6 tasks
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants