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(samgongustofa): Small cleanup in applications #16946

Merged
merged 8 commits into from
Nov 21, 2024

Conversation

johannaagma
Copy link
Member

@johannaagma johannaagma commented Nov 19, 2024

What

  • Add mockable payment to MortgageCertificate
  • Return recipientList on addReview action for TransferOfVehicleOwnership (for consistency and debugging)
  • Add validation to plateSize field to make sure either front or rear is selected
  • Make sure to clear the plateSize field when switching vehicle value

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

    • Enhanced vehicle ownership transfer process with updated review notification functionality, returning a list of email recipients for better tracking.
    • Introduced a mockable payment catalog API for improved testing capabilities.
  • Bug Fixes

    • Improved error handling and validation logic for vehicle selection and plate size management.
  • Documentation

    • Removed outdated payment-related message definitions across various templates for clarity and consistency.
  • Refactor

    • Streamlined payment-related sections in forms by removing unnecessary parameters and updating state management for vehicle details.

These updates aim to enhance user experience and improve system reliability.

Copy link
Contributor

coderabbitai bot commented Nov 19, 2024

Walkthrough

The pull request introduces modifications primarily to the TransferOfVehicleOwnershipService class, changing the return type of the addReview method to return a list of email recipients. Several message definitions related to payment labels have been removed across multiple files, including the paymentChargeOverview section. Additionally, new mockable APIs have been introduced for testing purposes, and various components have been updated to manage vehicle selection and payment information more effectively.

Changes

File Change Summary
libs/application/template-api-modules/src/lib/modules/templates/transport-authority/transfer-of-vehicle-ownership/transfer-of-vehicle-ownership.service.ts Updated addReview method to return Promise<Array<EmailRecipient>> instead of Promise<void>, returning an array of newly added recipients.
libs/application/templates/aosh/transfer-of-machine-ownership/src/lib/messages/payment.ts Removed messages forPayment and total from paymentChargeOverview.
libs/application/templates/directorate-of-immigration/citizenship/src/lib/messages/payment.ts Removed paymentChargeOverview section from payment object.
libs/application/templates/healthcare-license-certificate/src/lib/messages/payment.ts Removed paymentChargeOverview section from payment object.
libs/application/templates/healthcare-work-permit/src/lib/messages/payment.ts Removed paymentChargeOverview section from payment object.
libs/application/templates/id-card/src/lib/messages/payment.ts Removed paymentChargeOverview section from payment object.
libs/application/templates/mortgage-certificate/src/dataProviders/index.ts Added new export MockableSyslumadurPaymentCatalogApi for testing purposes.
libs/application/templates/mortgage-certificate/src/forms/MortgageCertificateForm.ts Updated MortgageCertificateForm to remove references to payment module properties.
libs/application/templates/mortgage-certificate/src/forms/Prerequisites.ts Added MockableSyslumadurPaymentCatalogApi to dataProviders array.
libs/application/templates/mortgage-certificate/src/lib/messages/payment.ts Removed labels property and forPayment message from payment object.
libs/application/templates/mortgage-certificate/src/lib/mortgageCertificateTemplate.ts Added import for MockableSyslumadurPaymentCatalogApi to api array in roles configuration.
libs/application/templates/transport-authority/order-vehicle-license-plate/src/fields/VehiclesField/VehicleSelectField.tsx Refactored vehicle selection logic to enhance clarity and reset plate size values on selection.
libs/application/templates/transport-authority/order-vehicle-license-plate/src/lib/dataSchema.ts Updated plateSize validation logic to ensure at least one of the arrays must be non-empty.
libs/application/templates/university/src/lib/messages/payment.ts Removed paymentChargeOverview message definitions from payment object.
libs/application/ui-fields/src/lib/FindVehicleFormField/FindVehicleFormField.tsx Added state variables for managing vehicle plate sizes and refined error handling logic.
libs/application/ui-fields/src/lib/VehicleRadioFormField/VehicleRadioFormField.tsx Added state updates for vehicle plate sizes in onRadioControllerSelect function.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Service
    participant NotificationSystem

    User->>Service: addReview(application, auth)
    Service->>Service: Validate buyer
    alt Validation successful
        Service->>Service: Compare current and previous recipients
        Service->>User: Return newly added recipients
        Service->>NotificationSystem: Send notifications to recipients
    else Validation failed
        Service->>User: Return empty array
    end
Loading

Possibly related PRs

Suggested labels

automerge

Suggested reviewers

  • sigruntg

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.

Copy link

codecov bot commented Nov 19, 2024

Codecov Report

Attention: Patch coverage is 6.25000% with 15 lines in your changes missing coverage. Please review.

Project coverage is 36.42%. Comparing base (6752b9b) to head (abf09ae).
Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
...ownership/transfer-of-vehicle-ownership.service.ts 0.00% 9 Missing ⚠️
.../order-vehicle-license-plate/src/lib/dataSchema.ts 0.00% 2 Missing ⚠️
.../lib/FindVehicleFormField/FindVehicleFormField.tsx 0.00% 2 Missing ⚠️
...ib/VehicleRadioFormField/VehicleRadioFormField.tsx 0.00% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #16946      +/-   ##
==========================================
+ Coverage   36.41%   36.42%   +0.01%     
==========================================
  Files        6898     6904       +6     
  Lines      144868   144644     -224     
  Branches    41403    41324      -79     
==========================================
- Hits        52751    52691      -60     
+ Misses      92117    91953     -164     
Flag Coverage Δ
api 3.34% <ø> (ø)
application-system-api 41.02% <0.00%> (-0.01%) ⬇️
application-template-api-modules 27.74% <0.00%> (+0.01%) ⬆️
application-templates-mortgage-certificate 43.45% <100.00%> (+0.02%) ⬆️
application-templates-parental-leave 29.86% <ø> (ø)
application-ui-shell 20.57% <0.00%> (-0.01%) ⬇️

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

Files with missing lines Coverage Δ
...r-of-machine-ownership/src/lib/messages/payment.ts 100.00% <ø> (ø)
...mmigration/citizenship/src/lib/messages/payment.ts 100.00% <ø> (ø)
...re-license-certificate/src/lib/messages/payment.ts 100.00% <ø> (ø)
...healthcare-work-permit/src/lib/messages/payment.ts 100.00% <ø> (ø)
...tion/templates/id-card/src/lib/messages/payment.ts 100.00% <ø> (ø)
...es/mortgage-certificate/src/dataProviders/index.ts 100.00% <100.00%> (ø)
...e-certificate/src/forms/MortgageCertificateForm.ts 0.00% <ø> (ø)
...es/mortgage-certificate/src/forms/Prerequisites.ts 0.00% <ø> (ø)
...s/mortgage-certificate/src/lib/messages/payment.ts 100.00% <ø> (ø)
...certificate/src/lib/mortgageCertificateTemplate.ts 50.00% <ø> (ø)
... and 4 more

... and 52 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 0885426...abf09ae. Read the comment docs.

---- 🚨 Try these New Features:

@datadog-island-is
Copy link

datadog-island-is bot commented Nov 19, 2024

Datadog Report

All test runs bc4e210 🔗

6 Total Test Services: 0 Failed, 6 Passed
🔻 Test Sessions change in coverage: 1 decreased (-0.02%), 2 increased, 28 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.35s 1 no change Link
application-system-api 0 0 0 112 2 3m 30.23s 1 no change Link
application-template-api-modules 0 0 0 116 0 2m 2.36s 1 increased (+0.01%) Link
application-templates-mortgage-certificate 0 0 0 3 0 21.66s 1 increased (+0.03%) Link
application-templates-parental-leave 0 0 0 163 0 15.3s 1 no change Link
application-ui-shell 0 0 0 74 0 32.11s 1 decreased (-0.02%) Link

🔻 Code Coverage Decreases vs Default Branch (1)

  • application-ui-shell - jest 26.76% (-0.02%) - Details

@johannaagma johannaagma marked this pull request as ready for review November 20, 2024 15:19
@johannaagma johannaagma requested review from a team as code owners November 20, 2024 15:19
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 (6)
libs/application/templates/healthcare-work-permit/src/lib/messages/payment.ts (1)

Similar payment message structures found in transport authority templates that need cleanup

Several transport authority templates contain similar payment message structures that could benefit from cleanup:

  • change-co-owner-of-vehicle/messages/payment.ts: Contains redundant paymentChargeOverview messages
  • change-operator-of-vehicle/messages/payment.ts: Contains redundant paymentChargeOverview messages
  • order-vehicle-license-plate/messages/payment.ts: Contains redundant paymentChargeOverview messages
  • transfer-of-vehicle-ownership/messages/payment.ts: Contains redundant paymentChargeOverview messages

These files have similar patterns of duplicate payment-related messages that could be consolidated, following the cleanup pattern shown in the healthcare work permit template.

🔗 Analysis chain

Line range hint 1-24: Consider extending cleanup to other templates.

Since similar message definitions were removed from multiple templates, let's ensure we haven't missed any.


Let me check the actual content of these payment message files to see if they contain similar patterns that need cleanup.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Find other templates that might need similar cleanup

# Search for similar payment message patterns in other templates
rg "paymentChargeOverview.*forPayment|total.*defaultMessage.*['\"]Til greiðslu['\"]" \
  --type ts \
  libs/application/templates

Length of output: 1636


Script:

#!/bin/bash
# Check content of payment message files in transport authority templates
for file in $(fd "payment.ts" libs/application/templates/transport-authority --type f); do
  echo "=== $file ==="
  cat "$file"
  echo -e "\n"
done

Length of output: 11397

libs/application/templates/transport-authority/order-vehicle-license-plate/src/fields/VehiclesField/VehicleSelectField.tsx (1)

97-98: Consider extracting plate size reset logic.

Consider extracting the plate size reset logic into a separate function for better reusability and maintainability.

+ const resetPlateSizes = () => {
+   setValue('plateSize.frontPlateSize', [])
+   setValue('plateSize.rearPlateSize', [])
+ }

  const onChange = (option: Option) => {
    // ... existing code ...
          setValue('pickVehicle.plate', permno)

-         setValue('plateSize.frontPlateSize', [])
-         setValue('plateSize.rearPlateSize', [])
+         resetPlateSizes()

          setIsLoading(false)
libs/application/ui-fields/src/lib/VehicleRadioFormField/VehicleRadioFormField.tsx (1)

67-69: Consider grouping related state updates.

The plate size reset logic could be better organized by grouping it with other vehicle-related state updates.

 setValue(`${field.id}.plate`, permno)
 setValue(`${field.id}.type`, currentVehicle?.make)
 setValue(`${field.id}.color`, currentVehicle?.color || undefined)
+setValue('plateSize.frontPlateSize', [])
+setValue('plateSize.rearPlateSize', [])

 setValue('vehicleMileage.requireMileage', currentVehicle?.requireMileage)
 setValue('vehicleMileage.mileageReading', currentVehicle?.mileageReading)

-setValue('plateSize.frontPlateSize', [])
-setValue('plateSize.rearPlateSize', [])

 if (permno) setValue('vehicleInfo.plate', permno)
libs/application/ui-fields/src/lib/FindVehicleFormField/FindVehicleFormField.tsx (2)

Line range hint 1-607: Consider improving component modularity

The component handles multiple vehicle types which makes it less reusable and harder to maintain. Consider:

  1. Extracting vehicle type-specific logic into separate components
  2. Making form field IDs configurable through props instead of hardcoding

This would improve reusability across different NextJS apps and make the component more maintainable.


Line range hint 566-574: Improve type safety in error handling

Replace the type assertion (errors as any)?.pickVehicle with proper typing. Consider:

  1. Extending the errors type to include the expected structure
  2. Using type guards to handle potential undefined values

This would improve type safety and make the code more maintainable.

Example:

interface FormErrors {
  pickVehicle?: {
    message: string;
  };
}

// Then use proper typing
const errors = errors as FormErrors;
if (errors?.pickVehicle) {
  // Handle error
}
libs/application/template-api-modules/src/lib/modules/templates/transport-authority/transfer-of-vehicle-ownership/transfer-of-vehicle-ownership.service.ts (1)

345-345: Consider adding an error log for unauthorized access.

While the early return is correct, adding a log message would help in debugging unauthorized access attempts.

-      return []
+      this.logger.debug(
+        `Unauthorized addReview attempt. Expected buyer ${answers.buyer.nationalId}, got ${auth.nationalId}`
+      )
+      return []
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between ed824e6 and 6def85f.

📒 Files selected for processing (18)
  • libs/application/template-api-modules/src/lib/modules/templates/transport-authority/transfer-of-vehicle-ownership/transfer-of-vehicle-ownership.service.ts (3 hunks)
  • libs/application/templates/aosh/transfer-of-machine-ownership/src/lib/messages/payment.ts (0 hunks)
  • libs/application/templates/directorate-of-immigration/citizenship/src/lib/messages/payment.ts (0 hunks)
  • libs/application/templates/healthcare-license-certificate/src/lib/messages/payment.ts (0 hunks)
  • libs/application/templates/healthcare-work-permit/src/lib/messages/payment.ts (1 hunks)
  • libs/application/templates/id-card/src/lib/messages/payment.ts (0 hunks)
  • libs/application/templates/mortgage-certificate/src/dataProviders/index.ts (2 hunks)
  • libs/application/templates/mortgage-certificate/src/forms/MortgageCertificateForm.ts (0 hunks)
  • libs/application/templates/mortgage-certificate/src/forms/Prerequisites.ts (2 hunks)
  • libs/application/templates/mortgage-certificate/src/lib/messages/payment.ts (0 hunks)
  • libs/application/templates/mortgage-certificate/src/lib/mortgageCertificateTemplate.ts (2 hunks)
  • libs/application/templates/transport-authority/order-vehicle-license-plate/src/fields/VehiclesField/VehicleSelectField.tsx (1 hunks)
  • libs/application/templates/transport-authority/order-vehicle-license-plate/src/lib/dataSchema.ts (1 hunks)
  • libs/application/templates/university/src/lib/messages/payment.ts (0 hunks)
  • libs/application/types/src/lib/Fields.ts (1 hunks)
  • libs/application/ui-fields/src/lib/FindVehicleFormField/FindVehicleFormField.tsx (1 hunks)
  • libs/application/ui-fields/src/lib/PaymentChargeOverviewFormField/PaymentChargeOverviewFormField.tsx (2 hunks)
  • libs/application/ui-fields/src/lib/VehicleRadioFormField/VehicleRadioFormField.tsx (1 hunks)
💤 Files with no reviewable changes (7)
  • libs/application/templates/aosh/transfer-of-machine-ownership/src/lib/messages/payment.ts
  • libs/application/templates/directorate-of-immigration/citizenship/src/lib/messages/payment.ts
  • libs/application/templates/healthcare-license-certificate/src/lib/messages/payment.ts
  • libs/application/templates/id-card/src/lib/messages/payment.ts
  • libs/application/templates/mortgage-certificate/src/forms/MortgageCertificateForm.ts
  • libs/application/templates/mortgage-certificate/src/lib/messages/payment.ts
  • libs/application/templates/university/src/lib/messages/payment.ts
🧰 Additional context used
📓 Path-based instructions (11)
libs/application/template-api-modules/src/lib/modules/templates/transport-authority/transfer-of-vehicle-ownership/transfer-of-vehicle-ownership.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/application/templates/healthcare-work-permit/src/lib/messages/payment.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/mortgage-certificate/src/dataProviders/index.ts (1)

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

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
libs/application/templates/mortgage-certificate/src/forms/Prerequisites.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/mortgage-certificate/src/lib/mortgageCertificateTemplate.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/transport-authority/order-vehicle-license-plate/src/fields/VehiclesField/VehicleSelectField.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/transport-authority/order-vehicle-license-plate/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/types/src/lib/Fields.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/ui-fields/src/lib/FindVehicleFormField/FindVehicleFormField.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/ui-fields/src/lib/PaymentChargeOverviewFormField/PaymentChargeOverviewFormField.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/ui-fields/src/lib/VehicleRadioFormField/VehicleRadioFormField.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."
📓 Learnings (2)
libs/application/templates/mortgage-certificate/src/dataProviders/index.ts (1)
Learnt from: norda-gunni
PR: island-is/island.is#16471
File: libs/application/templates/driving-license/src/forms/prerequisites/sectionExternalData.ts:69-72
Timestamp: 2024-11-12T15:15:20.157Z
Learning: In `libs/application/templates/driving-license/src/forms/prerequisites/sectionExternalData.ts`, the `MockableSyslumadurPaymentCatalogApi` is not a replacement for `SyslumadurPaymentCatalogApi`; both providers should be included in the `dataProviders` array.
libs/application/templates/mortgage-certificate/src/forms/Prerequisites.ts (1)
Learnt from: norda-gunni
PR: island-is/island.is#16471
File: libs/application/templates/driving-license/src/forms/prerequisites/sectionExternalData.ts:69-72
Timestamp: 2024-11-12T15:15:20.157Z
Learning: In `libs/application/templates/driving-license/src/forms/prerequisites/sectionExternalData.ts`, the `MockableSyslumadurPaymentCatalogApi` is not a replacement for `SyslumadurPaymentCatalogApi`; both providers should be included in the `dataProviders` array.
🔇 Additional comments (16)
libs/application/templates/healthcare-work-permit/src/lib/messages/payment.ts (1)

Line range hint 1-24: LGTM! Verify message usage.

The removal of duplicate payment messages is a good cleanup, as these have default values in buildFormPaymentChargeOverviewSection.

Let's verify no components are still referencing the removed messages:

✅ Verification successful

Removal of payment messages is safe and verified

The search results confirm that:

  • No references to the removed message IDs exist in the healthcare-work-permit template
  • The removed messages were template-specific and not shared across templates
  • Other transport-authority templates maintain their own message definitions with different namespaces (ta.tvo, ta.ovlp, etc.)
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for any remaining references to the removed message IDs

# Check for any remaining usage of the removed message IDs
rg "hwp\.application:payment\.paymentChargeOverview\.(forPayment|total)" \
  --type ts \
  --type tsx

Length of output: 123


Script:

#!/bin/bash
# Description: Search for any remaining references to the removed message IDs with correct ripgrep options

# Check for any remaining usage of the removed message IDs in TypeScript files
rg "hwp\.application:payment\.paymentChargeOverview\.(forPayment|total)" \
  -t ts

# Also search for any direct references to these message keys in the codebase
rg "paymentChargeOverview\.(forPayment|total)" \
  -t ts

# Search for any PaymentChargeOverviewField usage in the healthcare-work-permit template
fd "\.tsx?$" libs/application/templates/healthcare-work-permit -x rg -l "PaymentChargeOverviewField"

Length of output: 3194

libs/application/templates/mortgage-certificate/src/dataProviders/index.ts (2)

3-3: LGTM! Clean import addition

The import follows TypeScript best practices and supports effective tree-shaking.


16-22: Verify mock API integration

The mock API configuration looks good and follows the established pattern. Both mock and real payment catalog APIs coexist as recommended.

Let's verify the integration:

✅ Verification successful

Mock API integration is properly configured

The codebase analysis confirms that both the real payment catalog API (SyslumadurPaymentCatalogApi) and mock API (MockableSyslumadurPaymentCatalogApi) are correctly configured and used together in the application template. The mock API follows the established pattern documented in the template API modules README, with proper configuration for the SYSLUMENN organization. Both APIs are properly integrated in the prerequisites form and template configuration.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that both APIs are properly integrated in the application template

# Check if both APIs are used in the prerequisites form
ast-grep --pattern 'dataProviders: [
  $$$
  SyslumadurPaymentCatalogApi,
  $$$
  MockableSyslumadurPaymentCatalogApi,
  $$$
]'

# Verify the mock API is used in test files
rg -t ts "MockableSyslumadurPaymentCatalogApi" -g "*test*" -g "*spec*"

Length of output: 200


Script:

#!/bin/bash
# Let's try a different approach to verify the API integration

# Check where SyslumadurPaymentCatalogApi is used
rg "SyslumadurPaymentCatalogApi" -A 5 -B 5

# Check for any payment catalog API usage patterns
rg "PaymentCatalogApi" -A 5 -B 5

# Look for test files related to payment catalog
fd "payment.*\.(spec|test)\.(ts|tsx)$"

# Check the dataProviders configuration
ast-grep --pattern 'dataProviders = {
  $$$
}'

Length of output: 279081

libs/application/templates/transport-authority/order-vehicle-license-plate/src/lib/dataSchema.ts (1)

14-21: LGTM! The validation logic correctly ensures at least one plate size is selected.

The refinement implementation effectively validates that either frontPlateSize or rearPlateSize must be non-empty, which aligns with the PR objectives. The schema is also properly exported for reuse across different NextJS apps.

Let's verify if this validation is consistently used across the codebase:

✅ Verification successful

The plateSize validation is correctly implemented and consistently used across the codebase

Based on the codebase analysis:

  1. The Zod schema validation in dataSchema.ts ensures at least one plate size is selected (front or rear)
  2. The validation is consistently used in form components (PickPlateSize.tsx, VehicleSelectField.tsx, etc.)
  3. The plateSize field is properly handled in the backend services for order processing
  4. Error messages and UI components properly reflect the validation state

The implementation aligns with the PR objectives and is used consistently throughout the application.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for consistent usage of plateSize validation
# Look for any other validation logic related to plateSize that might conflict

# Search for plateSize validation patterns
rg -A 3 "plateSize.*validate|validate.*plateSize"

# Search for plateSize field usage
ast-grep --pattern 'plateSize: {
  $$$
}'

Length of output: 95


Script:

#!/bin/bash
# Let's try a broader search for plateSize usage and validation

# Search for plateSize in the codebase
rg -g '!{dist,build}/*' -A 5 'plateSize'

# Search for any Zod schema validation related to plateSize
ast-grep --pattern 'plateSize: z.$$$'

# Look for any test files that might validate plateSize
fd -g '*test*.{ts,tsx,js,jsx}' --exec rg -l 'plateSize'

Length of output: 37848

libs/application/ui-fields/src/lib/PaymentChargeOverviewFormField/PaymentChargeOverviewFormField.tsx (3)

49-50: Move the conditional check outside the Text component

To prevent unnecessary margin when there's no text, consider moving the conditional check outside the Text component.

Here's the suggested change:

-        <Text variant="h5">
-          {field.forPaymentLabel &&
-            formatText(field.forPaymentLabel, application, formatMessage)}
-        </Text>
+        {field.forPaymentLabel && (
+          <Text variant="h5">
+            {formatText(field.forPaymentLabel, application, formatMessage)}
+          </Text>
+        )}

75-76: Move the conditional check outside the Text component

Similar to the above, move the conditional check outside the Text component to prevent unnecessary margin.

Here's the suggested change:

-        <Text variant="h5">
-          {field.totalLabel &&
-            formatText(field.totalLabel, application, formatMessage)}
-        </Text>
+        {field.totalLabel && (
+          <Text variant="h5">
+            {formatText(field.totalLabel, application, formatMessage)}
+          </Text>
+        )}

Line range hint 1-89: Implementation looks good overall!

The component is well-structured with:

  • Proper TypeScript usage with well-defined types
  • Reusable design using shared UI components
  • Clean imports enabling effective tree-shaking
  • Clear and maintainable logic for payment charge calculations
libs/application/templates/mortgage-certificate/src/forms/Prerequisites.ts (2)

14-14: LGTM! Clean import addition.

The import follows TypeScript best practices and maintains effective tree-shaking capabilities.


64-67: LGTM! Correctly implements mockable payment feature.

The implementation correctly follows the established pattern by:

  • Keeping both the mock and real payment catalog APIs
  • Maintaining consistency with empty titles
  • Following the same provider structure as other data providers

This aligns with the previous learning about maintaining both providers in the system.

libs/application/templates/mortgage-certificate/src/lib/mortgageCertificateTemplate.ts (2)

24-24: LGTM! Verify mock API implementation.

The import addition follows the established pattern and naming conventions.

Let's verify the mock API implementation:

✅ Verification successful

Mock API implementation verified and properly configured

The MockableSyslumadurPaymentCatalogApi is correctly implemented as a configured instance of the base MockablePaymentCatalogApi with:

  • Proper organization ID configuration for SYSLUMENN
  • Correct external data ID for payment tracking
  • Appropriate usage in Prerequisites form for payment processing
  • Implementation follows the documented pattern for payment mocking in the template API modules
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check the mock API implementation
ast-grep --pattern 'class MockableSyslumadurPaymentCatalogApi {
  $$$
}'

# Verify test coverage
fd -e test.ts -e spec.ts . | xargs rg "MockableSyslumadurPaymentCatalogApi"

Length of output: 150


Script:

#!/bin/bash
# Let's try a broader search for the mock API implementation
rg -l "MockableSyslumadurPaymentCatalogApi"

# Search for the implementation pattern with more context
rg "class.*MockableSyslumadurPaymentCatalogApi" -A 10

# Check the dataProviders directory content
fd . "dataProviders"

Length of output: 934


Script:

#!/bin/bash
# Let's check the implementation in the dataProviders index file
rg "MockableSyslumadurPaymentCatalogApi" libs/application/templates/mortgage-certificate/src/dataProviders/index.ts -A 10

# Check if this is a shared implementation
cat libs/application/template-api-modules/README.md

# Check the usage in Prerequisites form
rg "MockableSyslumadurPaymentCatalogApi" libs/application/templates/mortgage-certificate/src/forms/Prerequisites.ts -A 5

Length of output: 16609


88-93: Clarify the coexistence of both payment catalog APIs.

While the addition follows the correct pattern, having both SyslumadurPaymentCatalogApi and MockableSyslumadurPaymentCatalogApi in the same configuration might lead to confusion. Consider:

  1. Adding a comment explaining when each API is used
  2. Using environment-based conditional logic to include only one API

Let's check how these APIs are used:

✅ Verification successful

Based on the gathered information, I can now provide a final response:

Both payment catalog APIs are intentionally included for mock payment functionality

The coexistence of both APIs is by design, as part of a mock payment feature implementation. The system includes a UI component with a "Enable mock payment" toggle that allows switching between real and mock payment APIs during testing or development. This is controlled through:

  1. A feature flag system (getApplicationFeatureFlags)
  2. A dedicated mock payment configuration (MOCKPAYMENT constant)
  3. UI controls for toggling between real and mock implementations

No changes are needed as this is an intentional implementation pattern for testing and development purposes.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for environment-based API selection
rg -A 5 "SyslumadurPaymentCatalogApi|MockableSyslumadurPaymentCatalogApi" --type ts

# Look for potential configuration handling
fd -e ts . | xargs rg "process\.env.*(_ENV|NODE_ENV|ENVIRONMENT)"

Length of output: 42251


Script:

#!/bin/bash
# Look for environment-based configuration or feature flags that might control API selection
rg -A 5 "getApplicationFeatureFlags|getFeatureFlags|isFeatureEnabled" --type ts

# Look for any configuration or initialization of these APIs
ast-grep --pattern 'const $_ = $$$PaymentCatalogApi.configure({
  $$$
})'

Length of output: 22468


Script:

#!/bin/bash
# Check for feature flags related to mockable payment
rg -A 5 "MOCK.*PAYMENT|ALLOW.*MOCK|ENABLE.*MOCK" --type ts

# Look for any conditional logic around these APIs
ast-grep --pattern 'if ($$$) {
  $$$PaymentCatalogApi$$$
}'

Length of output: 4300

libs/application/templates/transport-authority/order-vehicle-license-plate/src/fields/VehiclesField/VehicleSelectField.tsx (1)

90-96: LGTM! Improved state management logic.

The separation of permno determination and state updates improves code clarity and maintainability.

libs/application/ui-fields/src/lib/VehicleRadioFormField/VehicleRadioFormField.tsx (1)

67-69: Verify plateSize object structure existence.

The code assumes the existence of a plateSize object with frontPlateSize and rearPlateSize fields. While the logic to clear these fields is correct, we should ensure this structure is properly initialized.

✅ Verification successful

The plateSize object structure is properly defined and used throughout the codebase.

The search results confirm that the plateSize object structure with frontPlateSize and rearPlateSize fields is well-established in the codebase:

  • It's defined in the data schema (dataSchema.ts) using Zod:
plateSize: z.object({
  frontPlateSize: z.array(z.string()),
  rearPlateSize: z.array(z.string())
})
  • It's consistently used across multiple components and services
  • The structure is referenced in GraphQL DTOs, form fields, and validation logic
  • The same structure is used in other components that handle plate size resets
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for plateSize object initialization or type definition
ast-grep --pattern 'interface $_ {
  $$$
  plateSize: {
    frontPlateSize: $_
    rearPlateSize: $_
  }
  $$$
}'

Length of output: 115


Script:

#!/bin/bash
# Let's try a broader search for plateSize-related type definitions
ast-grep --pattern 'type $_ = {
  $$$
  plateSize: $_
  $$$
}'

# Also search for plateSize in interface definitions with a more flexible pattern
ast-grep --pattern 'interface $_ {
  $$$
  plateSize: $_
  $$$
}'

# Search for actual usage of plateSize in the codebase
rg "plateSize" -A 2 -B 2

Length of output: 34562

libs/application/ui-fields/src/lib/FindVehicleFormField/FindVehicleFormField.tsx (1)

253-255: LGTM: Plate size clearing implementation

The implementation correctly clears both front and rear plate sizes when a new vehicle is selected.

Let's verify that these fields are properly defined in the form schema:

✅ Verification successful

Plate size fields are properly defined and used consistently

The verification confirms that:

  • The plate size fields are properly defined in the form schema (dataSchema.ts) with the correct structure: plateSize.frontPlateSize and plateSize.rearPlateSize as arrays of strings
  • The same field clearing pattern is consistently used across multiple components in the codebase
  • The fields are properly referenced in the form configuration and validation logic
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if plateSize fields are defined in the form schema
rg -A 2 'plateSize[^a-zA-Z]' 

Length of output: 21580

libs/application/types/src/lib/Fields.ts (1)

520-521: LGTM! The changes align with the PR objectives.

The modification to make forPaymentLabel and totalLabel optional is appropriate since these fields have default values in buildFormPaymentChargeOverviewSection.

Let's verify that this change doesn't break existing implementations:

✅ Verification successful

LGTM! Making these fields optional is safe and aligns with the codebase

The verification shows that:

  1. All usages of PaymentChargeOverviewField provide default values for these labels in buildFormPaymentChargeOverviewSection
  2. All direct implementations (transport-authority templates) explicitly set both labels
  3. The component's stories demonstrate usage both with and without these labels
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for direct usage of PaymentChargeOverviewField to ensure no code relies on these fields being required
ast-grep --pattern 'PaymentChargeOverviewField = {
  $$$
  forPaymentLabel: $_
  $$$
}'

ast-grep --pattern 'PaymentChargeOverviewField = {
  $$$
  totalLabel: $_
  $$$
}'

Length of output: 174


Script:

#!/bin/bash
# Let's try a different approach to find usages of PaymentChargeOverviewField
# First, find direct references to the type
rg "PaymentChargeOverviewField" -A 5 -B 5

# Also search for any object literals that set these properties
rg "forPaymentLabel:|totalLabel:" -A 2 -B 2

# Check if there are any test files that might be using these fields
fd "test|spec" -e ts -e tsx --exec rg -l "PaymentChargeOverviewField|forPaymentLabel|totalLabel" {}

Length of output: 32647

libs/application/template-api-modules/src/lib/modules/templates/transport-authority/transfer-of-vehicle-ownership/transfer-of-vehicle-ownership.service.ts (1)

336-336: LGTM! Return type change improves debuggability.

The change from Promise<void> to Promise<Array<EmailRecipient>> enhances transparency by making the notification recipients visible to callers.

Copy link
Member

@Toti91 Toti91 left a comment

Choose a reason for hiding this comment

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

code owned LGTM

@johannaagma johannaagma added the deprecated:automerge (Disabled) Merge this PR as soon as all checks pass label Nov 21, 2024
@kodiakhq kodiakhq bot merged commit 2e6ef49 into main Nov 21, 2024
48 checks passed
@kodiakhq kodiakhq bot deleted the fix/samgongustofa-cleanup branch November 21, 2024 08:52
jonnigs pushed a commit that referenced this pull request Nov 26, 2024
* Make fields forPaymentLabel and totalLabel in PaymentChargeOverview optional (it has default value in buildFormPaymentChargeOverviewSection)

* Add mockable payment to MortgageCertificate

* Return recipientList on addReview action for TransferOfVehicleOwnership

* Add validation to plateSize field to make sure either front or rear is selected

* Make sure to clear the plateSize field when switching vehicle value

* Cleanup

* Cleanup check for oldEntry

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
@coderabbitai coderabbitai bot mentioned this pull request Jan 8, 2025
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deprecated:automerge (Disabled) Merge this PR as soon as all checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants