-
Notifications
You must be signed in to change notification settings - Fork 57
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(aod): finishups #15853
fix(aod): finishups #15853
Conversation
WalkthroughThe changes involve enhancements to the Changes
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? TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
Documentation and Community
Tip Early access features: enabledWe are currently testing the following features in early access:
Note:
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #15853 +/- ##
==========================================
- Coverage 36.94% 36.91% -0.03%
==========================================
Files 6680 6680
Lines 136459 136464 +5
Branches 38745 38763 +18
==========================================
- Hits 50409 50378 -31
- Misses 86050 86086 +36
Flags with carried forward coverage won't be shown. Click here to find out more. see 10 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
There was a problem hiding this 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, codebase verification and nitpick comments (8)
libs/application/templates/announcement-of-death/src/lib/dataSchema.ts (1)
Line range hint
1-124
: Ensure optimal reusability and TypeScript usage.The changes adhere well to the additional instructions for
libs
files:
- The schema is modular and potentially reusable across different NextJS apps.
- TypeScript is used effectively for type definitions.
- Specific imports and modular structure support effective tree-shaking.
To further improve TypeScript usage and reusability, consider exporting the FirearmApplicant type:
export type FirearmApplicant = z.TypeOf<typeof dataSchema.shape.firearmApplicant>;This would allow other parts of the application to import and use this type directly.
libs/application/templates/announcement-of-death/src/fields/FirearmApplicant/index.tsx (4)
110-114
: Approve changes with a minor suggestion for error handlingThe addition of the
required
attribute and the use ofgetErrorViaPath
for error handling are good improvements. However, consider simplifying the error path for consistency with other fields.Consider updating the error path to match the field name structure:
- getErrorViaPath(errors, 'firearmApplicant.nationalId') || + getErrorViaPath(errors, fieldNames.firearmApplicantNationalId) ||This change would make the error handling consistent across all fields and easier to maintain.
140-143
: Approve changes with a minor suggestion for error handling consistencyThe addition of the
required
attribute and the use ofgetErrorViaPath
for error handling are good improvements.For consistency with the previous suggestion, consider updating the error path:
- getErrorViaPath(errors, 'firearmApplicant.phone') || undefined + getErrorViaPath(errors, fieldNames.firearmApplicantPhone) || undefinedThis change would make the error handling consistent across all fields and easier to maintain.
151-154
: Approve changes with a minor suggestion for error handling consistencyThe addition of the
required
attribute and the use ofgetErrorViaPath
for error handling are good improvements.For consistency with the previous suggestions, consider updating the error path:
- getErrorViaPath(errors, 'firearmApplicant.email') || undefined + getErrorViaPath(errors, fieldNames.firearmApplicantEmail) || undefinedThis change would make the error handling consistent across all fields and easier to maintain.
Line range hint
1-160
: Enhance TypeScript usage for better type safetyThe component generally adheres to the guidelines for library files, including reusability and TypeScript usage. However, there's room for improvement in type definitions.
Consider the following enhancements:
- Define a type for the
application
prop inFirearmApplicantBaseProps
:interface FirearmApplicantBaseProps extends FieldBaseProps { errors: FieldErrors<FieldValues>; application: Application; // Define the Application type }
- Use more specific types for the
watch
function results:const nationalId = watch(fieldNames.firearmApplicantNationalId) as string; const name = watch(fieldNames.firearmApplicantName) as string;
- Consider creating a union type for field names:
type FieldName = keyof typeof fieldNames;These changes will improve type safety and make the component more robust.
libs/application/templates/announcement-of-death/src/forms/overviewSections.ts (2)
339-345
: New field added to display firearm possession status.A new
buildKeyValueField
has been added to explicitly show whether the applicant had firearms. This enhances the user interface and provides clear information.Consider adding a comment explaining the purpose of this new field for better code maintainability. For example:
+ // Explicitly display whether the applicant had firearms buildKeyValueField({ label: m.firearmsHadFirearms, width: 'full', value: ({ answers }) => answers.hadFirearms === YES ? m.firearmsYes : m.firearmsNo, condition: (answers) => showInDone(answers.viewOverview), }),
346-352
: Repositioned and updated firearmApplicantInfo field.The
firearmApplicantInfo
description field has been moved after the new key-value field, maintaining a logical flow of information. The condition remains unchanged, ensuring that detailed applicant info is only shown when necessary. The addedspace
property likely improves the visual layout.For consistency with the previous fields, consider updating the condition to use the
showInDone
function:condition: (answers) => - showInDone(answers.viewOverview) && answers.hadFirearms === YES, + showInDone(answers.viewOverview) && showInDone(answers.hadFirearms === YES),This change would make the condition consistent with the pattern used in other fields and potentially more flexible if the
showInDone
function's behavior is modified in the future.libs/application/templates/announcement-of-death/src/lib/messages.ts (1)
235-242
: Lack of TypeScript Type Definitions or InterfacesThe file
libs/application/templates/announcement-of-death/src/lib/messages.ts
does not contain any TypeScript type definitions or interfaces. This may not align with the requirement to use TypeScript for defining props and exporting types where applicable. Please review and ensure that TypeScript is used appropriately for type safety.
- No
export type
orexport interface
statements were found.Analysis chain
Verify TypeScript usage and export.
To ensure compliance with the additional instructions for
libs/**/*
files, please confirm that these message definitions are properly exported and that TypeScript is used for defining props and exporting types where applicable.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Check if the messages are properly exported and if TypeScript is used for types grep -n "export const m = defineMessages" libs/application/templates/announcement-of-death/src/lib/messages.ts grep -n "import.*from 'react-intl'" libs/application/templates/announcement-of-death/src/lib/messages.tsLength of output: 307
Script:
#!/bin/bash # Check for TypeScript type definitions and exports in the file grep -n "export type" libs/application/templates/announcement-of-death/src/lib/messages.ts grep -n "export interface" libs/application/templates/announcement-of-death/src/lib/messages.tsLength of output: 190
Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Files selected for processing (4)
- libs/application/templates/announcement-of-death/src/fields/FirearmApplicant/index.tsx (3 hunks)
- libs/application/templates/announcement-of-death/src/forms/overviewSections.ts (2 hunks)
- libs/application/templates/announcement-of-death/src/lib/dataSchema.ts (2 hunks)
- libs/application/templates/announcement-of-death/src/lib/messages.ts (1 hunks)
Additional context used
Path-based instructions (4)
libs/application/templates/announcement-of-death/src/lib/dataSchema.ts (1)
Pattern
libs/**/*
: "Confirm that the code adheres to the following:
- Reusability of components and hooks across different NextJS apps.
- TypeScript usage for defining props and exporting types.
- Effective tree-shaking and bundling practices."
libs/application/templates/announcement-of-death/src/fields/FirearmApplicant/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/announcement-of-death/src/forms/overviewSections.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/announcement-of-death/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 not posted (7)
libs/application/templates/announcement-of-death/src/lib/dataSchema.ts (3)
8-8
: LGTM: Importing specific constants.The import of
YES
andNO
constants from '@island.is/application/core' is appropriate and follows good practices for tree-shaking.
80-80
: LGTM: New field added as per requirements.The addition of the
hadFirearms
field usingz.enum([YES, NO])
is correct and aligns with the PR objectives. It enhances the schema to capture whether the applicant has firearms.
83-83
: LGTM: Improved validation for nationalId.The update to the
nationalId
field in thefirearmApplicant
object enhances validation by ensuring the ID corresponds to a person. This is a good use of Zod'srefine
method for custom validation.libs/application/templates/announcement-of-death/src/fields/FirearmApplicant/index.tsx (1)
126-126
: Approve the addition ofreadOnly
attributeThe addition of the
readOnly
attribute to the name input is appropriate. This ensures that the automatically populated name from the national ID lookup cannot be manually edited by the user, maintaining data integrity.libs/application/templates/announcement-of-death/src/forms/overviewSections.ts (1)
331-338
: Simplified condition for firearm applicant section.The condition for displaying the divider and description fields has been simplified to only check
showInDone(answers.viewOverview)
. This change broadens the circumstances under which these fields are displayed.To ensure this change doesn't have unintended consequences, please run the following script:
Verification successful
Simplified condition for firearm applicant section verified.
The search confirmed that there are no other occurrences of
hadFirearms
in conditions forfirearmApplicant
. This indicates that the condition simplification is isolated and does not introduce unintended side effects.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Check for other occurrences of hadFirearms in conditions # Expected: No other occurrences of hadFirearms in conditions for firearmApplicant rg --type typescript 'condition.*hadFirearms.*firearmApplicant' libs/application/templates/announcement-of-death/src/Length of output: 154
Script:
#!/bin/bash # Description: Check for other occurrences of hadFirearms in conditions # Expected: No other occurrences of hadFirearms in conditions for firearmApplicant rg 'condition.*hadFirearms.*firearmApplicant' libs/application/templates/announcement-of-death/src/Length of output: 101
libs/application/templates/announcement-of-death/src/lib/messages.ts (2)
235-239
: New message definition looks good.The new
firearmsApplicant
message has been added correctly with a unique ID and an appropriate default message in Icelandic.
242-242
: Simplified message for firearms applicant overview header.The
defaultMessage
forfirearmsApplicantOverviewHeader
has been simplified from 'Skotvopn - vörsluaðili' to 'Skotvopn', which appears to be an intentional improvement in the user interface text.
Datadog ReportAll test runs ✅ 4 Total Test Services: 0 Failed, 4 Passed Test Services
|
There was a problem hiding this 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, codebase verification and nitpick comments (1)
libs/application/template-api-modules/src/lib/modules/templates/announcement-of-death/smsGenerators/requestReviewSms.ts (1)
5-8
: Verify and Update Usages ofgenerateRequestReviewSms
The
RequestReviewSms
type andgenerateRequestReviewSms
function have been updated to include alink
parameter. While this change is correctly implemented in theannouncement-of-death.service.ts
file, other usages in different services might not have been updated. Please verify and update these usages to ensure they pass the requiredlink
parameter:
libs/application/template-api-modules/src/lib/modules/templates/transport-authority/transfer-of-vehicle-ownership/transfer-of-vehicle-ownership.service.ts
libs/application/template-api-modules/src/lib/modules/templates/transport-authority/change-co-owner-of-vehicle/change-co-owner-of-vehicle.service.ts
libs/application/template-api-modules/src/lib/modules/templates/transport-authority/change-operator-of-vehicle/change-operator-of-vehicle.service.ts
libs/application/template-api-modules/src/lib/modules/templates/aosh/transfer-of-machine-ownership/transfer-of-machine-ownership.service.ts
Analysis chain
Update to
RequestReviewSms
type signatureThe
RequestReviewSms
type has been updated to include a newlink
parameter of type string. This change is consistent with the modifications in the function implementation.To ensure this change doesn't break existing code, let's verify its usage:
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Search for usages of RequestReviewSms type rg --type typescript "RequestReviewSms" -C 5Length of output: 79
Script:
#!/bin/bash # Correct the file type and search for usages of RequestReviewSms type rg --type ts "RequestReviewSms" -C 5Length of output: 37423
Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Files selected for processing (2)
- libs/application/template-api-modules/src/lib/modules/templates/announcement-of-death/announcement-of-death.service.ts (3 hunks)
- libs/application/template-api-modules/src/lib/modules/templates/announcement-of-death/smsGenerators/requestReviewSms.ts (2 hunks)
Additional context used
Path-based instructions (2)
libs/application/template-api-modules/src/lib/modules/templates/announcement-of-death/smsGenerators/requestReviewSms.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/template-api-modules/src/lib/modules/templates/announcement-of-death/announcement-of-death.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 not posted (6)
libs/application/template-api-modules/src/lib/modules/templates/announcement-of-death/smsGenerators/requestReviewSms.ts (2)
10-13
: Update togenerateRequestReviewSms
function signatureThe function signature has been updated to match the new
RequestReviewSms
type, adding thelink
parameter. This change is consistent with the type definition.Let's verify that all calls to this function have been updated:
Verification successful
All calls to
generateRequestReviewSms
have been updatedThe verification confirms that all instances of the
generateRequestReviewSms
function call have been updated to include thelink
parameter, consistent with the updated function signature.
transfer-of-vehicle-ownership.service.ts
change-operator-of-vehicle.service.ts
change-co-owner-of-vehicle.service.ts
transfer-of-machine-ownership.service.ts
announcement-of-death.service.ts
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Search for calls to generateRequestReviewSms rg --type typescript "generateRequestReviewSms\(" -C 5Length of output: 91
Script:
#!/bin/bash # Correcting the file type and searching for calls to generateRequestReviewSms rg --type ts "generateRequestReviewSms\(" -C 5Length of output: 11859
24-26
: Update to SMS message contentThe SMS message has been updated to include instructions for using the provided link. This enhances the user experience by providing clear guidance.
However, there are a few points to consider:
- The message is quite long and might be split into multiple SMS messages.
- The link is appended at the end without any context or call-to-action.
Consider the following improvements:
- Shorten the message if possible to fit within SMS character limits.
- Add a clear call-to-action before the link, e.g., "Click here to proceed:"
Here's a suggested refactor:
- `Með undirritun lýsir þú því yfir að þú hafir leyfi til að varsla skotvopnin og samþykkir jafnframt að taka við vörslu þeirra. - Ef þú áttir von á þessari beiðni máttu smella á linkinn hér fyrir neðan. - ${link}`, + `Með undirritun samþykkir þú að taka við vörslu skotvopnanna. + Ef þú áttir von á þessari beiðni, smelltu hér til að halda áfram: ${link}`,Let's check if similar message constructions exist elsewhere in the codebase:
libs/application/template-api-modules/src/lib/modules/templates/announcement-of-death/announcement-of-death.service.ts (4)
4-7
: LGTM: New imports are appropriate and follow best practices.The added imports are necessary for the changes in the file and follow TypeScript best practices. They support effective tree-shaking and bundling.
Also applies to: 29-33, 39-40
48-48
: LGTM: Constructor updated with ConfigService parameter.The addition of the
ConfigService
parameter with the correct typeConfigService<BaseTemplateAPIModuleConfig>
follows dependency injection best practices and ensures type safety.
149-156
: Approve changes with a suggestion for improved error handling.The addition of the dynamic link in the SMS is a good improvement. However, consider adding a check for the
clientLocationOrigin
value to ensure it's defined before using it.Consider adding a check for
clientLocationOrigin
:const clientLocationOrigin = getConfigValue( this.configService, 'clientLocationOrigin', ) as string | undefined if (!clientLocationOrigin) { throw new Error('clientLocationOrigin is not defined in the configuration'); } const link = `${clientLocationOrigin}/${ApplicationConfigurations.AnnouncementOfDeath.slug}/${application.id}`This will prevent potential runtime errors if the configuration is missing.
Line range hint
1-307
: Overall changes align with PR objectives and improve functionality.The modifications to the
AnnouncementOfDeathService
class, particularly in the SMS notification functionality, are consistent with the PR objectives. The changes improve the service's ability to generate contextually relevant notifications by leveraging configuration data.The code adheres to TypeScript best practices, supports reusability, and maintains effective tree-shaking and bundling practices. These improvements enhance the overall quality and functionality of the application.
This reverts commit fb2ccc5.
* fix(aod): finishups * sms tweak * Revert "sms tweak" This reverts commit fb2ccc5. --------- Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
Checklist:
Summary by CodeRabbit
New Features
Bug Fixes
Documentation