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(efs): Efs db tweaks 21.11 #16977

Merged
merged 6 commits into from
Nov 22, 2024
Merged

fix(efs): Efs db tweaks 21.11 #16977

merged 6 commits into from
Nov 22, 2024

Conversation

albinagu
Copy link
Member

@albinagu albinagu commented Nov 21, 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

Release Notes

  • New Features

    • Updated the OverviewDebts component to display debt descriptions in the format description (debtType).
    • Added a printing functionality in the PrintScreen component for asset and debt overviews.
    • Introduced a new alert message prompting users to fill in spouse information if the deceased was married.
    • Enhanced the debtsAndFuneralCost section with updated labels for various debt types.
  • Bug Fixes

    • Improved event handling for the print button to prevent default actions.
  • Documentation

    • Updated enums for debt types and relations to reflect new labels and values.

@albinagu albinagu requested a review from a team as a code owner November 21, 2024 12:03
Copy link
Contributor

coderabbitai bot commented Nov 21, 2024

Walkthrough

This pull request introduces several modifications across multiple files related to the inheritance report feature. Key changes include updates to the OverviewDebts component to alter how debt descriptions are displayed, adjustments to the PrintScreen component's event handling, and the addition of custom fields for printing in both the assets and debts sections. Additionally, the DebtTypes and RelationEnum enumerations are updated to reflect new labels and values, enhancing the overall structure and functionality of the application.

Changes

File Path Change Summary
libs/application/templates/inheritance-report/src/fields/Overview/OverviewDebts/index.tsx Updated TopRow title in Debt component to concatenate description with debtType; removed separate display of debtType.
libs/application/templates/inheritance-report/src/fields/PrintScreen/index.tsx Modified Button's onClick event to include e.preventDefault() before calling window.print().
libs/application/templates/inheritance-report/src/forms/sections/assets.ts Added new custom field PrintScreen with ID overviewPrint to the assetOverview section.
libs/application/templates/inheritance-report/src/forms/sections/debtsAndFuneralCost.ts Renamed labels in selections array for debt types; added new custom field PrintScreen with ID overviewPrint to debtsAndFuneralCostOverview.
libs/application/templates/inheritance-report/src/types.ts Updated DebtTypes enum: removed InsuranceCompany, changed PropertyFees label, and added PublicCharges. Updated RelationEnum with new values.
libs/application/templates/inheritance-report/src/forms/sections/heirs.ts Introduced new alert message field for spouse information in the heirs section.
libs/application/templates/inheritance-report/src/lib/messages.ts Added new message heirsReminderToFillInSpouse for prompting spouse information during the inheritance report process.

Possibly related PRs

Suggested labels

automerge

Suggested reviewers

  • kksteini
  • rafnarnason

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 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.

@albinagu albinagu added the deploy-feature Deploys features to dev label Nov 21, 2024
Copy link

codecov bot commented Nov 21, 2024

Codecov Report

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

Project coverage is 35.76%. Comparing base (df742aa) to head (d65c6f4).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...tes/inheritance-report/src/forms/sections/heirs.ts 0.00% 4 Missing ⚠️
...nheritance-report/src/fields/PrintScreen/index.tsx 0.00% 3 Missing ⚠️
...report/src/fields/Overview/OverviewDebts/index.tsx 0.00% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #16977      +/-   ##
==========================================
+ Coverage   35.61%   35.76%   +0.14%     
==========================================
  Files        6915     6910       -5     
  Lines      146014   145697     -317     
  Branches    41456    41414      -42     
==========================================
+ Hits        52010    52105      +95     
+ Misses      94004    93592     -412     
Flag Coverage Δ
api 3.34% <ø> (ø)
application-system-api 38.70% <ø> (+<0.01%) ⬆️
application-template-api-modules 27.70% <ø> (-0.02%) ⬇️
application-templates-inheritance-report 6.54% <0.00%> (-0.02%) ⬇️
application-ui-shell 20.57% <ø> (ø)
services-user-notification 46.71% <ø> (+<0.01%) ⬆️

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

Files with missing lines Coverage Δ
...es/inheritance-report/src/forms/sections/assets.ts 0.00% <ø> (ø)
...e-report/src/forms/sections/debtsAndFuneralCost.ts 0.00% <ø> (ø)
...n/templates/inheritance-report/src/lib/messages.ts 100.00% <ø> (ø)
...report/src/fields/Overview/OverviewDebts/index.tsx 0.00% <0.00%> (ø)
...nheritance-report/src/fields/PrintScreen/index.tsx 0.00% <0.00%> (ø)
...tes/inheritance-report/src/forms/sections/heirs.ts 0.00% <0.00%> (ø)

... and 21 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 df742aa...d65c6f4. Read the comment docs.

---- 🚨 Try these New Features:

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 (3)
libs/application/templates/inheritance-report/src/fields/PrintScreen/index.tsx (1)

Line range hint 4-24: Add TypeScript types to improve code quality.

The component could benefit from proper TypeScript typing:

  1. Add explicit type for the event parameter
  2. Define component type

Apply this diff to improve type safety:

-export const PrintScreen = () => {
+import { MouseEvent } from 'react'
+
+export const PrintScreen: React.FC = () => {
   return (
     <Box
       position="absolute"
       className={styles.printButton}
       display={['none', 'none', 'block']}
     >
       <Button
         colorScheme="default"
         icon="print"
         iconType="filled"
-        onClick={(e) => {
+        onClick={(e: MouseEvent<HTMLButtonElement>) => {
           e.preventDefault()
           window.print()
         }}
         preTextIconType="filled"
         variant="ghost"
       ></Button>
     </Box>
   )
 }
libs/application/templates/inheritance-report/src/fields/Overview/OverviewDebts/index.tsx (1)

126-129: Consider using localization for the title format.

The parentheses format should be localized to support different display patterns across languages.

+  // Add to messages
+  const titleFormat = formatMessage(
+    m.debtTitleFormat,
+    { description: description ?? '', type: debtType ?? '' }
+  )
           title={titleFormat}
libs/application/templates/inheritance-report/src/types.ts (1)

Breaking changes detected in RelationEnum with inconsistent usage

The verification reveals critical issues:

  • Two different versions of RelationEnum exist in the codebase
  • prepaidInheritance/applicant.ts attempts to use both old (ADVOCATE) and new enum values (REPRESENTATIVE, HEIR, GRANTOR)
  • applicant.ts uses the new values including EXCHANGEMANAGER
  • The enum appears to be redefined in the same file (types.ts)

Action items:

  • Remove the duplicate enum definition
  • Update prepaidInheritance/applicant.ts to use only the new enum values
  • Ensure all enum values are properly documented as suggested
  • Consider adding a migration guide for this breaking change
🔗 Analysis chain

Line range hint 249-254: Address TODO comment and verify enum usage

The TODO comment questions whether the value labels make sense. Additionally, this is a breaking change that completely redefines the RelationEnum.

Let's verify the impact:

Please:

  1. Remove the TODO comment after confirming the labels
  2. Document the enum values
  3. Ensure all usages are updated to use the new values
-// todo: do these value labels make sense?
 export enum RelationEnum {
+  /** Representative of the estate */
   REPRESENTATIVE = 'representative',
+  /** Heir to the estate */
   HEIR = 'heir',
+  /** Manager handling the exchange */
   EXCHANGEMANAGER = 'exchangeManager',
+  /** Person granting rights */
   GRANTOR = 'grantor',
 }
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check usage of RelationEnum values across the codebase

# Find all files using the old enum values
echo "Files potentially using old RelationEnum values:"
rg -l "RelationEnum\.(PARENT|CHILD|SIBLING|SPOUSE|ADVOCATE)"

# Find all files using the new enum values
echo "Files using new RelationEnum values:"
rg -l "RelationEnum\.(REPRESENTATIVE|HEIR|EXCHANGEMANAGER|GRANTOR)"

Length of output: 594


Script:

#!/bin/bash
# Let's check the actual usage context in these files
echo "Content of files using old enum values:"
rg -A 5 -B 5 "RelationEnum\.(PARENT|CHILD|SIBLING|SPOUSE|ADVOCATE)" libs/application/templates/inheritance-report/src/forms/sections/prepaidInheritance/applicant.ts

echo -e "\nContent of files using new enum values:"
rg -A 5 -B 5 "RelationEnum\.(REPRESENTATIVE|HEIR|EXCHANGEMANAGER|GRANTOR)" libs/application/templates/inheritance-report/src/forms/sections/prepaidInheritance/applicant.ts libs/application/templates/inheritance-report/src/forms/sections/applicant.ts

# Let's also check for the enum definition
echo -e "\nEnum definition:"
rg -A 10 "export enum RelationEnum" libs/application/templates/inheritance-report/src/types.ts

Length of output: 4724

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 29bb191 and 75ea36a.

📒 Files selected for processing (5)
  • libs/application/templates/inheritance-report/src/fields/Overview/OverviewDebts/index.tsx (1 hunks)
  • libs/application/templates/inheritance-report/src/fields/PrintScreen/index.tsx (1 hunks)
  • libs/application/templates/inheritance-report/src/forms/sections/assets.ts (1 hunks)
  • libs/application/templates/inheritance-report/src/forms/sections/debtsAndFuneralCost.ts (2 hunks)
  • libs/application/templates/inheritance-report/src/types.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • libs/application/templates/inheritance-report/src/forms/sections/assets.ts
🧰 Additional context used
📓 Path-based instructions (4)
libs/application/templates/inheritance-report/src/fields/Overview/OverviewDebts/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/templates/inheritance-report/src/fields/PrintScreen/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/templates/inheritance-report/src/forms/sections/debtsAndFuneralCost.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/types.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 (6)
libs/application/templates/inheritance-report/src/fields/PrintScreen/index.tsx (1)

15-18: LGTM! Event handler implementation looks good.

The addition of preventDefault() is a good practice to ensure the button click doesn't trigger any unexpected form submissions or page refreshes.

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

126-129: LGTM: Compliant with library coding guidelines.

The code follows the required guidelines for library components:

  • Uses TypeScript for type safety
  • Component is reusable across NextJS apps
  • Imports are specific, enabling effective tree-shaking
libs/application/templates/inheritance-report/src/forms/sections/debtsAndFuneralCost.ts (2)

73-88: Verify the impact of debt type reordering on existing data

The significant reordering of debt types (e.g., moving PublicCharges to the top, changing positions of Loan and CreditCard) might affect existing records. Please ensure that:

  1. Data migration scripts handle the reordering correctly
  2. UI components displaying these values are updated accordingly
  3. Any downstream processing of these values is adjusted
✅ Verification successful

Let me analyze the results to understand the impact of debt type reordering:

  1. The DebtTypes enum is used in several key places:

    • Form configuration (debtsAndFuneralCost.ts)
    • Syslumenn client mapping (syslumennClient.utils.ts)
    • Fake data generation (fakeData.ts)
    • Data schema validation (dataSchema.ts)
  2. The mapping in syslumennClient.utils.ts shows a fixed mapping between TegundAndlags numbers and DebtTypes, which suggests the order in the form doesn't affect the underlying data storage.

  3. The data schema (dataSchema.ts) validates debtType as a string, not based on enum order.

Let me verify the enum definition to confirm if there are any numeric values that could be affected by reordering:


Reordering of debt types in the form is safe

The reordering of debt types in the form is safe because:

  • The DebtTypes enum uses string values, not numeric indices
  • Data storage and validation are based on these string values, not the order
  • The mapping in syslumennClient.utils.ts uses fixed string values
  • The form only changes the display order, not the underlying enum values
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other usages of DebtTypes enum to ensure consistent updates
ast-grep --pattern 'DebtTypes.$_'

# Search for any data migration scripts related to debt types
rg -g '*.ts' -g '*.sql' -i 'debttype|debt.*migration'

Length of output: 6726


Script:

#!/bin/bash
# Find the DebtTypes enum definition
ast-grep --pattern 'enum DebtTypes {
  $$$
}'

Length of output: 1346


198-203: 🛠️ Refactor suggestion

Enhance type safety and reusability of the PrintScreen component

While the PrintScreen component addition follows the pattern used in other sections, consider these improvements:

  1. Define TypeScript interfaces for the component props
  2. Export the interface for reuse across different NextJS apps
  3. Document any required parent context or dependencies

Consider adding a type definition file:

// PrintScreenProps.ts
export interface PrintScreenProps {
  // Add relevant props based on component requirements
  id: string;
  title?: string;
  // ... other props
}
libs/application/templates/inheritance-report/src/types.ts (2)

305-307: LGTM: Debt type labels updated correctly

The changes to the DebtTypes enum look good:

  • Updated PropertyFees label to be more precise
  • Added PublicCharges for better categorization

Line range hint 1-313: Excellent TypeScript usage and exports

The file follows TypeScript best practices:

  • Clear interface definitions with proper typing
  • Consistent enum usage
  • Well-structured exports
  • Reusable types that can be shared across NextJS apps

@datadog-island-is
Copy link

datadog-island-is bot commented Nov 21, 2024

Datadog Report

All test runs 2c1e1d8 🔗

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

Test 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.44s 1 no change Link
application-system-api 0 0 0 34 0 2m 16.99s 1 no change Link
application-template-api-modules 0 0 0 116 0 2m 2.76s 1 no change Link
application-ui-shell 0 0 0 74 0 30.93s 1 no change Link
services-user-notification 0 0 0 51 0 1m 4.73s 1 no change Link

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)
libs/application/templates/inheritance-report/src/forms/sections/heirs.ts (1)

93-108: Consider extracting the condition function for reusability

The alert message implementation is well-structured and type-safe. However, to improve maintainability and reusability, consider extracting the condition function.

+const isDeceasedMarried = (answers: Record<string, unknown>): boolean => 
+  getValueViaPath<string>(answers, 'customShare.deceasedWasMarried') === YES
+
 buildAlertMessageField({
   id: 'reminderToFillInSpouse',
   title: '',
   message: m.heirsReminderToFillInSpouse,
   alertType: 'info',
   marginBottom: 'containerGutter',
-  condition: (answers) => {
-    return (
-      getValueViaPath<string>(
-        answers,
-        'customShare.deceasedWasMarried',
-      ) === YES
-    )
-  },
+  condition: isDeceasedMarried,
 }),
libs/application/templates/inheritance-report/src/lib/messages.ts (1)

1374-1378: Add a description to help translators understand the context.

The message structure is correct and follows the established patterns. However, consider adding a meaningful description to help translators understand when and where this reminder message is displayed.

  heirsReminderToFillInSpouse: {
    id: 'ir.application:heirsReminderToFillInSpouse',
    defaultMessage: 'Athugið að passa þarf að skrá inn upplýsingar um maka.',
-    description: '',
+    description: 'Reminder message shown when spouse information needs to be filled in the heirs section',
  },
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 75ea36a and f67b397.

📒 Files selected for processing (2)
  • libs/application/templates/inheritance-report/src/forms/sections/heirs.ts (2 hunks)
  • libs/application/templates/inheritance-report/src/lib/messages.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
libs/application/templates/inheritance-report/src/forms/sections/heirs.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/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 (2)
libs/application/templates/inheritance-report/src/forms/sections/heirs.ts (2)

2-2: LGTM: Import added correctly

The buildAlertMessageField import is properly added from the core package, maintaining alphabetical order and following the reusability guidelines.


Line range hint 1-400: LGTM: Well-structured form configuration

The form configuration demonstrates:

  • Strong TypeScript usage for type safety
  • Proper component reusability through core builders
  • Clear hierarchical structure
  • Consistent naming conventions

@albinagu albinagu added automerge Merge this PR as soon as all checks pass and removed deploy-feature Deploys features to dev labels Nov 21, 2024
@kodiakhq kodiakhq bot merged commit d45ac0c into main Nov 22, 2024
42 checks passed
@kodiakhq kodiakhq bot deleted the efs_db_-21.11 branch November 22, 2024 11:38
jonnigs pushed a commit that referenced this pull request Nov 26, 2024
* fix(efs): Efs db tweaks 21.11

* reminder to fill in spouse

* chore: nx format:write update dirty files

* spouse reminder tweak

---------

Co-authored-by: andes-it <builders@andes.is>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
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.

3 participants