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

feat(driving-license): check if 65+ renewal is possible #16292

Merged
merged 13 commits into from
Oct 7, 2024
Merged

Conversation

stjanilofts
Copy link
Member

@stjanilofts stjanilofts commented Oct 7, 2024

https://app.asana.com/0/1204431115744096/1208446138184156

Summary by CodeRabbit

  • New Features

    • Introduced a new license renewal type for individuals aged 65 and older.
    • Added specific messages for eligibility regarding extended driving licenses.
    • Enhanced eligibility checks for driving license applications, including checks for the new renewal type.
    • Added a new API method to check eligibility for the renewal process for older applicants.
    • Expanded the set of requirements with a new enum value related to driving licenses.
    • Added an optional property for issuance information in the driving license category type.
  • Bug Fixes

    • Corrected a typographical error in an API call related to health declarations.
  • Documentation

    • Updated messaging framework to include new eligibility criteria.
  • Chores

    • Added new constants for extended license categories and remarks.

@stjanilofts stjanilofts requested a review from a team as a code owner October 7, 2024 12:53
Copy link
Contributor

coderabbitai bot commented Oct 7, 2024

Walkthrough

The pull request introduces updates to the DrivingLicenseService and related components, enhancing license renewal functionality for individuals aged 65 and older. Key changes include the addition of the B-full-renewal-65 license type, the implementation of a new API method getCanApplyForRenewal65, and modifications to eligibility checks. New constants and messages have been added to support these changes, while existing methods have been corrected and streamlined for improved logic handling.

Changes

File Change Summary
libs/api/domains/driving-license/src/lib/drivingLicense.service.ts - Updated canApplyFor method to include B-full-renewal-65 and call getCanApplyForRenewal65 API.
- Corrected postHealthDeclaration method name.
libs/api/domains/driving-license/src/lib/drivingLicense.type.ts - Added new enum value noExtendedDrivingLicense to RequirementKey.
libs/application/templates/driving-license/src/fields/EligibilitySummary/extractReasons.ts - Added handling for RequirementKey.NoExtendedDrivingLicense in eligibility messages.
libs/application/templates/driving-license/src/fields/EligibilitySummary/useEligibility.ts - Introduced constants B_FULL_RENEWAL_65 and remarksCannotRenew65.
- Enhanced eligibility checks for B_FULL_RENEWAL_65.
libs/application/templates/driving-license/src/forms/prerequisites/sectionApplicationFor.ts - Modified age variable handling and simplified logic for disabling options related to B_FULL_RENEWAL_65.
libs/application/templates/driving-license/src/lib/constants.ts - Added constants codesExtendedLicenseCategories and remarksCannotRenew65.
libs/application/templates/driving-license/src/lib/messages.ts - Added new messages noExtendedDrivingLicenseTitle and noExtendedDrivingLicenseDescription for eligibility requirements.
libs/application/templates/driving-license/src/lib/types.ts - Updated DrivingLicenseCategory type to include optional property issued.
libs/clients/driving-license/src/lib/drivingLicenseApi.service.ts - Added new method getCanApplyForRenewal65 to handle renewal requests for the new license type.

Possibly related PRs

Suggested labels

high priority

Suggested reviewers

  • kksteini
  • thorkellmani

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.

@stjanilofts stjanilofts added the automerge Merge this PR as soon as all checks pass label Oct 7, 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: 5

🧹 Outside diff range and nitpick comments (11)
libs/application/templates/driving-license/src/lib/constants.ts (2)

29-41: LGTM! Consider consolidating license category constants.

The new codesExtendedLicenseCategories constant is a welcome addition, providing a comprehensive list of extended license categories. It adheres to the coding guidelines by being exportable and using TypeScript.

Consider consolidating this new constant with the existing otherLicenseCategories to avoid duplication and improve maintainability. For example:

export const allLicenseCategories = [
  'C1', 'C1E', 'C', 'CE', 'D1', 'D1E', 'D', 'DE', 'Bfar', 'Far', 'FAR'
];
export const otherLicenseCategories = allLicenseCategories.filter(category => ['C', 'C1', 'CE', 'D', 'D1', 'DE'].includes(category));
export const codesExtendedLicenseCategories = allLicenseCategories;

This approach would make it easier to maintain the list of license categories in one place while still providing separate constants for different use cases.


42-42: LGTM! Consider adding comments for code clarity.

The new remarksCannotRenew65 constant is well-named and adheres to the coding guidelines. It's exported for reusability and uses TypeScript as required.

To improve code clarity, consider adding a comment explaining the meaning of each code. For example:

export const remarksCannotRenew65 = [
  '400', // e.g., "Medical condition preventing renewal"
  '450', // e.g., "Age-related restriction"
  '95'   // e.g., "Administrative reason"
];

This would make the code more self-documenting and easier for other developers to understand and maintain.

libs/application/templates/driving-license/src/fields/EligibilitySummary/extractReasons.ts (2)

28-29: LGTM with a minor suggestion.

The addition of the new case for RequirementKey.NoExtendedDrivingLicense is consistent with the existing structure. However, consider returning a description message instead of a title to align with the function's name and purpose.

Consider changing:

-      return requirementsMessages.noExtendedDrivingLicenseTitle
+      return requirementsMessages.noExtendedDrivingLicenseDescription

This would better align with the function's name getDeniedByServiceMessageDescription.


Line range hint 1-97: Summary: Changes align well with PR objectives.

The modifications in this file successfully implement the new feature for checking eligibility for driving license renewal, particularly for individuals aged 65 and older. The changes are well-integrated into the existing code structure and follow consistent patterns.

Key points:

  1. A new requirement key NoExtendedDrivingLicense has been added to handle extended driving license checks.
  2. The changes are implemented in both getDeniedByServiceMessageDescription and requirementKeyToStep functions, ensuring comprehensive handling of the new requirement.
  3. The code maintains good TypeScript practices and appears to be designed for reusability across different NextJS apps.

These changes align well with the PR objectives of implementing a feature to check eligibility for renewal of driving licenses for individuals aged 65 and older.

Consider documenting the purpose and usage of the NoExtendedDrivingLicense requirement key in the code or in a separate documentation file to improve maintainability and clarity for other developers.

libs/application/templates/driving-license/src/forms/prerequisites/sectionApplicationFor.ts (3)

Line range hint 46-51: Consider a more appropriate fallback value for age

The fallback value of 0 for the age variable might lead to unexpected behavior in age-based calculations. Consider using a value that clearly indicates an invalid or unset age, such as -1 or null.

let age =
  getValueViaPath<number>(
    app.externalData,
    'nationalRegistry.data.age',
-  ) ?? 0
+  ) ?? -1 // or null

This change would make it easier to distinguish between a valid age of 0 and an unset age value.


Line range hint 56-71: Approve fake data handling with a minor suggestion

The implementation of fake data handling is well-structured and correctly simulates different license scenarios. The placement of the age reassignment within this block is appropriate.

To improve readability, consider extracting the license type checks into a separate function:

function getFakeLicenseCategories(licenseType: string): Array<{ nr: string; validToCode: number }> {
  switch (licenseType) {
    case 'temp':
      return [{ nr: 'B', validToCode: 8 }];
    case 'full':
      return [{ nr: 'B', validToCode: 9 }];
    case 'BE':
      return [
        { nr: 'B', validToCode: 9 },
        { nr: 'BE', validToCode: 9 },
      ];
    default:
      return [];
  }
}

// Usage
categories = getFakeLicenseCategories(fakeData.currentLicense);

This refactoring would make the code more maintainable and easier to extend in the future.


97-97: Approve simplified condition with a suggestion for consistency

The simplification of the condition for disabling the B_FULL_RENEWAL_65 option improves code readability and correctly handles both real and fake data scenarios.

For consistency with other parts of the code and to make the age threshold more maintainable, consider extracting it as a constant:

const RENEWAL_AGE_THRESHOLD = 65;

// Then use it in the condition
disabled: !currentLicense || age < RENEWAL_AGE_THRESHOLD,

This change would make it easier to update the age threshold in the future if needed and would align with best practices for magic number avoidance.

libs/api/domains/driving-license/src/lib/drivingLicense.service.ts (1)

358-366: LGTM! Consider using a switch statement for better readability.

The changes successfully implement the new license type 'B-full-renewal-65' and handle it appropriately. The method remains reusable and adheres to TypeScript usage guidelines.

To improve code readability and maintainability, consider refactoring the if-else chain into a switch statement:

switch (type) {
  case 'B-full-renewal-65':
    return this.drivingLicenseApi.getCanApplyForRenewal65({
      token,
    });
  case 'B-full':
    return this.drivingLicenseApi.getCanApplyForCategoryFull({
      category: 'B',
      token,
    });
  case 'BE':
    return this.drivingLicenseApi.getCanApplyForCategoryFull({
      category: 'BE',
      token,
    });
  case 'B-temp':
    return this.drivingLicenseApi.getCanApplyForCategoryTemporary({
      token,
    });
  default:
    throw new Error('unhandled license type');
}

This refactoring would make it easier to add new license types in the future and improve the overall structure of the method.

libs/clients/driving-license/src/lib/drivingLicenseApi.service.ts (1)

375-390: LGTM! Consider standardizing token handling for consistency.

The new getCanApplyForRenewal65 method is well-implemented and follows the existing patterns in the class. It correctly uses API version constants and returns the expected result structure.

For consistency with other methods in this class, consider removing the 'Bearer ' prefix from the token:

-      jwttoken: params.token,
+      jwttoken: params.token.replace('Bearer ', ''),

This change would align the token handling with methods like getIsTeacher and getDrivingAssessment.

libs/application/templates/driving-license/src/lib/messages.ts (1)

983-992: LGTM! Consider adding more context to the description.

The new messages for 65+ driving license renewal are well-formatted and consistent with the existing code. They clearly communicate that it's not possible to apply for a 65+ driving license renewal.

Consider expanding the description field to provide more context for translators or other developers. For example:

 noExtendedDrivingLicenseDescription: {
   id: 'dl.application:requirementunmet.noExtendedDrivingLicenseDescription',
   defaultMessage: 'Ekki hægt að sækja um endurnýjun á 65+ ökuskírteini.',
-  description: 'requirement unmet 65 plus renewal',
+  description: 'Message shown when a user 65 or older cannot renew their driving license online',
 },
libs/application/templates/driving-license/src/fields/EligibilitySummary/useEligibility.ts (1)

Line range hint 26-26: Address the TODO regarding health certificate support

The TODO comment indicates that this code should be removed when RLS/SGS supports the health certificate in the BE license. Please ensure this task is tracked and the code is updated accordingly.

Would you like me to open a new GitHub issue to track this task?

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between ea6cc03 and 10a85b2.

📒 Files selected for processing (9)
  • libs/api/domains/driving-license/src/lib/drivingLicense.service.ts (1 hunks)
  • libs/api/domains/driving-license/src/lib/drivingLicense.type.ts (1 hunks)
  • libs/application/templates/driving-license/src/fields/EligibilitySummary/extractReasons.ts (2 hunks)
  • libs/application/templates/driving-license/src/fields/EligibilitySummary/useEligibility.ts (3 hunks)
  • libs/application/templates/driving-license/src/forms/prerequisites/sectionApplicationFor.ts (4 hunks)
  • libs/application/templates/driving-license/src/lib/constants.ts (1 hunks)
  • libs/application/templates/driving-license/src/lib/messages.ts (1 hunks)
  • libs/application/templates/driving-license/src/lib/types.ts (1 hunks)
  • libs/clients/driving-license/src/lib/drivingLicenseApi.service.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (9)
libs/api/domains/driving-license/src/lib/drivingLicense.service.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/api/domains/driving-license/src/lib/drivingLicense.type.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/driving-license/src/fields/EligibilitySummary/extractReasons.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/driving-license/src/fields/EligibilitySummary/useEligibility.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/driving-license/src/forms/prerequisites/sectionApplicationFor.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/driving-license/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/driving-license/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."
libs/application/templates/driving-license/src/lib/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."
libs/clients/driving-license/src/lib/drivingLicenseApi.service.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 (4)
libs/application/templates/driving-license/src/lib/types.ts (1)

14-14: LGTM! The change adheres to coding guidelines.

The addition of the optional issued property to the DrivingLicenseCategory type is well-implemented and aligns with TypeScript best practices. This change enhances the type definition without breaking existing usage.

The file continues to meet the coding guidelines for libs/**/*:

  1. The types defined are reusable across different NextJS apps dealing with driving licenses.
  2. TypeScript is correctly used for defining and exporting types.
  3. The structure allows for effective tree-shaking and bundling.
libs/application/templates/driving-license/src/fields/EligibilitySummary/extractReasons.ts (1)

90-94: LGTM! Verify message consistency.

The new case for RequirementKey.NoExtendedDrivingLicense is well-implemented and consistent with the existing structure. Both title and description are provided as expected.

To ensure consistency across the application, please verify that the messages used here (noExtendedDrivingLicenseTitle and noExtendedDrivingLicenseDescription) are defined in the requirementsMessages object. Run the following script to check:

✅ Verification successful

Verified!

The new message keys noExtendedDrivingLicenseTitle and noExtendedDrivingLicenseDescription are properly defined in requirementsMessages.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that the new messages are defined in requirementsMessages

# Test: Search for the new message keys in the file containing requirementsMessages
rg --type typescript 'noExtendedDrivingLicenseTitle|noExtendedDrivingLicenseDescription' libs/application/templates/driving-license/src/lib/messages.ts

Length of output: 188


Script:

#!/bin/bash
# Description: Verify that the new messages are defined in requirementsMessages

# Test: Search for the new message keys in the file containing requirementsMessages
rg --type ts 'noExtendedDrivingLicenseTitle|noExtendedDrivingLicenseDescription' libs/application/templates/driving-license/src/lib/messages.ts

Length of output: 373

libs/application/templates/driving-license/src/forms/prerequisites/sectionApplicationFor.ts (1)

Line range hint 1-124: Overall assessment: Improvements in age handling and fake data scenarios

The changes in this file effectively implement the feature for checking 65+ driving license renewal eligibility. The modifications improve age-based condition handling and introduce a robust fake data mechanism for testing various scenarios. The code adheres to TypeScript best practices and maintains a structure that supports reusability and effective tree-shaking.

Key improvements:

  1. Flexible age variable handling
  2. Comprehensive fake data simulation
  3. Simplified conditions for license type options

The suggested refactorings, if implemented, would further enhance code maintainability and readability. Great job on implementing this feature!

libs/api/domains/driving-license/src/lib/drivingLicense.service.ts (1)

358-366: LGTM! Typo in API call corrected.

The correction of the API call from postTemporaryLicenseWithHealthDeclaratio to postTemporaryLicenseWithHealthDeclaration fixes a typo and ensures the correct method is called. This change improves code quality and reduces the risk of runtime errors.

Copy link

codecov bot commented Oct 7, 2024

Codecov Report

Attention: Patch coverage is 13.95349% with 37 lines in your changes missing coverage. Please review.

Project coverage is 36.86%. Comparing base (80d7546) to head (84b7292).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...se/src/fields/EligibilitySummary/useEligibility.ts 0.00% 25 Missing ⚠️
...iving-license/src/lib/drivingLicenseApi.service.ts 0.00% 5 Missing ⚠️
...se/src/fields/EligibilitySummary/extractReasons.ts 0.00% 4 Missing ⚠️
...e/src/forms/prerequisites/sectionApplicationFor.ts 0.00% 2 Missing ⚠️
.../driving-license/src/lib/drivingLicense.service.ts 75.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #16292      +/-   ##
==========================================
- Coverage   36.86%   36.86%   -0.01%     
==========================================
  Files        6798     6796       -2     
  Lines      140499   140515      +16     
  Branches    39946    39955       +9     
==========================================
- Hits        51795    51794       -1     
- Misses      88704    88721      +17     
Flag Coverage Δ
air-discount-scheme-web 0.00% <ø> (ø)
api 3.37% <ø> (ø)
api-domains-driving-license 44.46% <40.00%> (-0.05%) ⬇️
application-api-files 57.94% <ø> (ø)
application-core 71.54% <ø> (+0.24%) ⬆️
application-system-api 41.67% <10.00%> (-0.01%) ⬇️
application-template-api-modules 24.26% <10.00%> (-0.03%) ⬇️
application-templates-accident-notification 29.44% <ø> (ø)
application-templates-car-recycling 3.12% <ø> (ø)
application-templates-criminal-record 26.63% <ø> (ø)
application-templates-driving-license 18.40% <6.06%> (-0.23%) ⬇️
application-templates-estate 12.32% <ø> (ø)
application-templates-example-payment 25.41% <ø> (ø)
application-templates-financial-aid 14.34% <ø> (ø)
application-templates-general-petition 23.68% <ø> (ø)
application-templates-health-insurance 26.62% <ø> (ø)
application-templates-inheritance-report 6.45% <ø> (ø)
application-templates-marriage-conditions 15.23% <ø> (ø)
application-templates-mortgage-certificate 43.96% <ø> (ø)
application-templates-parental-leave 30.03% <ø> (ø)
application-types 6.71% <ø> (ø)
application-ui-components 1.28% <ø> (ø)
application-ui-shell 21.27% <ø> (ø)
clients-charge-fjs-v2 24.11% <ø> (ø)
clients-driving-license 40.63% <0.00%> (-0.14%) ⬇️
clients-license-client 1.83% <ø> (ø)
license-api 42.57% <0.00%> (-0.06%) ⬇️
testing-e2e ?
web 1.83% <ø> (ø)

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

Files with missing lines Coverage Δ
...ins/driving-license/src/lib/drivingLicense.type.ts 100.00% <100.00%> (ø)
...ion/templates/driving-license/src/lib/constants.ts 100.00% <100.00%> (ø)
...tion/templates/driving-license/src/lib/messages.ts 100.00% <ø> (ø)
.../driving-license/src/lib/drivingLicense.service.ts 53.36% <75.00%> (-0.04%) ⬇️
...e/src/forms/prerequisites/sectionApplicationFor.ts 0.00% <0.00%> (ø)
...se/src/fields/EligibilitySummary/extractReasons.ts 0.00% <0.00%> (ø)
...iving-license/src/lib/drivingLicenseApi.service.ts 50.97% <0.00%> (-1.27%) ⬇️
...se/src/fields/EligibilitySummary/useEligibility.ts 0.00% <0.00%> (ø)

... and 8 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 80d7546...84b7292. Read the comment docs.

@datadog-island-is
Copy link

datadog-island-is bot commented Oct 7, 2024

Datadog Report

All test runs 45c05ee 🔗

25 Total Test Services: 0 Failed, 24 Passed
🔻 Test Sessions change in coverage: 5 decreased, 1 increased (+0.1%), 91 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
air-discount-scheme-web 0 0 0 2 0 7.87s 1 no change Link
api 0 0 0 4 0 2.74s 1 no change Link
api-domains-driving-license 0 0 0 23 0 29.67s 1 decreased (-0.06%) Link
api-domains-license-service 0 0 0 0 0 537.2ms 1 no change Link
application-api-files 0 0 0 12 0 6.47s 1 no change Link
application-core 0 0 0 90 0 19.84s 1 increased (+0.1%) Link
application-system-api 0 0 0 120 2 3m 20.53s 1 no change Link
application-template-api-modules 0 0 0 134 0 1m 57.4s 1 decreased (-0.01%) Link
application-templates-accident-notification 0 0 0 148 0 18.86s 1 no change Link
application-templates-criminal-record 0 0 0 2 0 11.55s 1 no change Link

🔻 Code Coverage Decreases vs Default Branch (5)

  • application-templates-driving-license - jest 24.25% (-0.3%) - Details
  • api-domains-driving-license - jest 33.87% (-0.06%) - Details
  • license-api - jest 33.81% (-0.04%) - Details
  • clients-driving-license - jest 26.2% (-0.03%) - Details
  • application-template-api-modules - jest 26% (-0.01%) - Details

Copy link
Member

@kksteini kksteini left a comment

Choose a reason for hiding this comment

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

Some thoughts but otherwise LGTM 👍

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/application/templates/driving-license/src/fields/EligibilitySummary/useEligibility.ts (1)

199-211: LGTM with a minor suggestion for type annotation.

The return statement for the B_FULL_RENEWAL_65 case is well-structured and includes all necessary conditions for eligibility. The use of the nullish coalescing operator (??) is a good practice for handling potential undefined values.

To further improve type safety, consider adding an explicit type annotation to the returned object:

return {
  loading,
  eligibility: {
    isEligible: loading
      ? undefined
      : (data.drivingLicenseApplicationEligibility?.isEligible ?? false) &&
        hasQualityPhoto &&
        !hasExtendedDrivingLicense &&
        !hasAnyInvalidRemarks,
    requirements,
  } as ApplicationEligibility,
};

This ensures that the returned object strictly adheres to the expected UseEligibilityResult type, providing better type checking and developer experience.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 10a85b2 and 2a0ccd6.

📒 Files selected for processing (1)
  • libs/application/templates/driving-license/src/fields/EligibilitySummary/useEligibility.ts (3 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
libs/application/templates/driving-license/src/fields/EligibilitySummary/useEligibility.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/driving-license/src/fields/EligibilitySummary/useEligibility.ts (2)

3-7: LGTM: Import statements are well-organized and use TypeScript types.

The addition of ApplicationEligibilityRequirement aligns with the changes in the file. The import statements are organized and make use of TypeScript types, which adheres to the coding guidelines for reusability and TypeScript usage.


11-18: LGTM: New constants added for 65+ renewal eligibility check.

The addition of B_FULL_RENEWAL_65 and remarksCannotRenew65 constants aligns with the new functionality for checking eligibility for 65+ renewal. These constants are properly imported, promoting reusability across the application.

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/driving-license/src/fields/EligibilitySummary/useEligibility.ts (2)

100-115: LGTM: Well-implemented hasExtendedDrivingLicense function

The hasExtendedDrivingLicense function is well-structured with clear logic and good use of early returns. It correctly checks for extended driving licenses by comparing issuance dates.

Consider adding a type annotation for the return value:

const hasExtendedDrivingLicense = (
  currentLicense: DrivingLicense | undefined,
  drivingLicenseIssued: string | undefined,
): boolean => {
  // ... existing implementation ...
}

This addition would enhance type safety and code clarity.


168-212: LGTM: Well-implemented eligibility check for B_FULL_RENEWAL_65

The new eligibility check for B_FULL_RENEWAL_65 is well-implemented and aligns with the PR objectives. It correctly checks for extended licenses, invalid remarks, and quality photos. The use of the spread operator for constructing the requirements array is efficient.

Consider adding error handling for potential undefined values:

const licenseB = currentLicense?.categories?.find(
  (license) => license.nr === 'B',
) ?? null;

if (!licenseB) {
  console.warn('No B license found for B_FULL_RENEWAL_65 application');
  // Handle this case, perhaps by returning early or setting a default value
}

const drivingLicenseIssued = licenseB?.issued;

This addition would make the code more robust against unexpected data structures.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 2a0ccd6 and ccab305.

📒 Files selected for processing (2)
  • libs/application/templates/driving-license/src/fields/EligibilitySummary/useEligibility.ts (4 hunks)
  • libs/application/templates/driving-license/src/lib/messages.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • libs/application/templates/driving-license/src/lib/messages.ts
🧰 Additional context used
📓 Path-based instructions (1)
libs/application/templates/driving-license/src/fields/EligibilitySummary/useEligibility.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 (3)
libs/application/templates/driving-license/src/fields/EligibilitySummary/useEligibility.ts (3)

3-7: LGTM: New imports and constants align with PR objectives

The additions of ApplicationEligibilityRequirement, RequirementKey, B_FULL_RENEWAL_65, and remarksCannotRenew65 are appropriate for implementing the new 65+ license renewal eligibility check. These changes contribute to better type safety and code organization.

Also applies to: 11-11, 13-13, 18-18


138-139: LGTM: Improved eligibility type and initialization

The change to ApplicationEligibilityRequirement[] for the eligibility variable aligns with the new structure of the requirements array. The use of optional chaining and nullish coalescing (?. and ??) improves the code's robustness by safely handling potential undefined values.


Line range hint 1-220: LGTM: Well-implemented feature for 65+ driving license renewal eligibility

The changes in this file successfully implement the new feature for checking eligibility for 65+ driving license renewals. The additions and modifications are well-structured, maintain consistency with existing patterns, and follow TypeScript best practices. The code is readable, maintainable, and aligns well with the PR objectives.

Key improvements:

  1. Addition of new types and constants for better type safety and code organization.
  2. Implementation of hasExtendedDrivingLicense function for clear and reusable logic.
  3. Updated eligibility checks incorporating new requirements for 65+ renewals.

The changes adhere to the coding guidelines for libs, ensuring reusability across different NextJS apps and effective TypeScript usage.

@stjanilofts stjanilofts removed the automerge Merge this PR as soon as all checks pass label Oct 7, 2024
@stjanilofts stjanilofts added the automerge Merge this PR as soon as all checks pass label Oct 7, 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 (1)
libs/application/templates/driving-license/src/fields/EligibilitySummary/useEligibility.ts (1)

100-115: LGTM: Well-implemented hasExtendedDrivingLicense function.

The hasExtendedDrivingLicense function is well-structured and correctly implements the logic for checking extended driving licenses. It properly handles edge cases and improves code modularity.

Consider adding type annotations for better type safety:

const hasExtendedDrivingLicense = (
  currentLicense: DrivingLicense | undefined,
  drivingLicenseIssued: string | undefined
): boolean => {
  // ... (rest of the function remains the same)
}
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between ccab305 and a308181.

📒 Files selected for processing (1)
  • libs/application/templates/driving-license/src/fields/EligibilitySummary/useEligibility.ts (4 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
libs/application/templates/driving-license/src/fields/EligibilitySummary/useEligibility.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 (4)
libs/application/templates/driving-license/src/fields/EligibilitySummary/useEligibility.ts (4)

3-7: LGTM: New imports and constants for 65+ renewal eligibility checks.

The additions of ApplicationEligibilityRequirement, RequirementKey, B_FULL_RENEWAL_65, and remarksCannotRenew65 are appropriate for implementing the new eligibility checks for 65+ driving license renewals.

Also applies to: 11-11, 18-18


138-139: LGTM: Improved eligibility type and initialization.

The change in the eligibility type to ApplicationEligibilityRequirement[] and the updated initialization using optional chaining and nullish coalescing improve type safety and robustness.


Line range hint 1-218: LGTM: Excellent adherence to coding guidelines and best practices.

The overall structure of the file is well-organized and follows a logical flow. The code effectively uses TypeScript for type definitions and adheres to best practices for reusability across different NextJS apps. The implementation aligns well with the provided coding guidelines.


168-212: LGTM: Well-implemented eligibility logic for B_FULL_RENEWAL_65.

The new eligibility logic for B_FULL_RENEWAL_65 is well-structured and correctly implements the required checks for 65+ renewals. The dynamic construction of requirements enhances flexibility and maintainability.

Consider adding error handling for potential undefined values. Run the following script to verify the usage of optional chaining throughout the file:

If the script returns any matches, consider adding optional chaining (?.) to those property accesses to prevent potential runtime errors.

@kodiakhq kodiakhq bot merged commit c51f52a into main Oct 7, 2024
87 checks passed
@kodiakhq kodiakhq bot deleted the feat/dl-65plus branch October 7, 2024 20:23
stjanilofts added a commit that referenced this pull request Oct 8, 2024
* check if 65 renewal is possible

* remove console log

* cleanup

* coderabbit tweaks

* coderabbit changes

* quick fix

* add type?

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
kodiakhq bot added a commit that referenced this pull request Oct 8, 2024
)

* check if 65 renewal is possible

* remove console log

* cleanup

* coderabbit tweaks

* coderabbit changes

* quick fix

* add type?

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
thordurhhh pushed a commit that referenced this pull request Oct 8, 2024
* check if 65 renewal is possible

* remove console log

* cleanup

* coderabbit tweaks

* coderabbit changes

* quick fix

* add type?

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
kodiakhq bot added a commit that referenced this pull request Oct 11, 2024
…-pages (#16234)

* Service portal removal. Add portals my pages

* minor fixes

* Fix

* path fix

* fix(portals-admin): locklist (#16279)

* fix(portals-admin): locklist

* tweak

* msg id fix

* tweak

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>

* feat(service-portal): feature flag resolver for documents (#16285)

* fix: def info and alert

* feat: add feature flag to resolver

* fix: move ff call to seperate function

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>

* fix(vehicles-bulk-mileage): Fixes after testing review (#16295)

* fix: testing fixes v1

* fix: testing comments v2

* fix: better message

* fix: function name

* fix: duplicate loading

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>

* feat(tests): New @island/testing/e2e library (#16287)

* Add @swc-node/register and @swc/core

* Add testing/e2e library

* update project.json for testing/e2e

* fix import for libTestingE2e

---------

Co-authored-by: Kristofer <kristofer@andes.is>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>

* feat(parental-leave): ApplicationRights (#15901)

* feat(parental-leave): ApplicationRights

Added applicationRights to parental-leave when sending application. Since we are using a new way of calculating periods

* Fix days used by period calculation

* Tests for new periods

* rename function with proper camelCase

* Refactor: Made duplicate code into a function

* Make ApplicationRights nullable

* refactor: function instead of duplicate code

* remove console.log

* error handling for period data

* clientConfig nullable fix

* Fixes for calculation of months. And using clamp to get correct value of daysLeft

* Multiply amount of months by 30 for period calculation with month durations

* Fix old calculation of endDate with months

---------

Co-authored-by: hfhelgason <hfhelgason@deloitte.is>
Co-authored-by: veronikasif <54938148+veronikasif@users.noreply.github.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>

* feat(passport-application): Updated readme (#16296)

* updated readme

* updated readme

* chore: nx format:write update dirty files

---------

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

* fix(regulations-admin): date format signature, remove self affect, disclaimer text (#16288)

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>

* fix(regulations-admin): No diff no addition in appendix (#16293)

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>

* fix(web): Global alert banner - Handle null case (#16298)

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>

* fix(web): Change custom syslumenn pages config for header (#16299)

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>

* fix(j-s): Digital mailbox API (#16301)

* feat(j-s): Block create subpoena on staging and dev

* Update subpoena.service.ts

* fix(j-s): Fix mailbox API

* remove changes not meant for this branch

* Update subpoena.service.ts

* fix(j-s): reverting changes from other branch

* Update subpoena.response.ts

* Update subpoena.response.ts

* Update subpoena.response.ts

* Update subpoena.response.ts

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>

* fix(signature-collection): Fix list reviewed toggle (#16300)

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>

* chore(scripts): Stricter shell script checking (#16242)

* Set style level for shellcheck

* Linting & formatting scripts

* Remove _podman.sh script

* Format all scripts

* Add reviewdog/action-shfmt step

* Configure shfmt

* Merge from main

* Linting

* Move shfmt to before lint

* Remove reviewdog

* Allow external sources in shellcheck

* Use Reviewdog for shellcheck

* Set version for Reviewdog

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>

* chore(new-primary-school): Update messages namespace (#16302)

Co-authored-by: veronikasif <54938148+veronikasif@users.noreply.github.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>

* feat(driving-license): check if 65+ renewal is possible (#16292)

* check if 65 renewal is possible

* remove console log

* cleanup

* coderabbit tweaks

* coderabbit changes

* quick fix

* add type?

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>

* feat(service-portal): default defender and has chosen fields for subpoena (#16306)

* fix: def info and alert

* feat: add feature flag to resolver

* fix: move ff call to seperate function

* feat: add default choices ans has chosen + loading states

* fix: use type

* fix: undefined type issue

* fix: simplify check

* Update service setup for my pages infra

* chore: charts update dirty files

* Remove from infra

* undo rename

---------

Co-authored-by: albinagu <47886428+albinagu@users.noreply.github.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
Co-authored-by: Ásdís Erna Guðmundsdóttir <disa@hugsmidjan.is>
Co-authored-by: Þorkell Máni Þorkelsson <wowthorkell@gmail.com>
Co-authored-by: Svanhildur Einarsdóttir <54863023+svanaeinars@users.noreply.github.com>
Co-authored-by: Kristofer <kristofer@andes.is>
Co-authored-by: helgifr <helgifreyr95@gmail.com>
Co-authored-by: hfhelgason <hfhelgason@deloitte.is>
Co-authored-by: veronikasif <54938148+veronikasif@users.noreply.github.com>
Co-authored-by: Rafn Árnason <rafnarnason@gmail.com>
Co-authored-by: andes-it <builders@andes.is>
Co-authored-by: Rúnar Vestmann <43557895+RunarVestmann@users.noreply.github.com>
Co-authored-by: mannipje <135017126+mannipje@users.noreply.github.com>
Co-authored-by: unakb <una@kolibri.is>
Co-authored-by: juni-haukur <158475136+juni-haukur@users.noreply.github.com>
Co-authored-by: birkirkristmunds <142495885+birkirkristmunds@users.noreply.github.com>
Co-authored-by: Kristján Albert <kal@juni.is>
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