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(accident-notification): dates coming to sjukra #16713

Merged
merged 4 commits into from
Nov 5, 2024
Merged

Conversation

jonnigs
Copy link
Member

@jonnigs jonnigs commented Nov 4, 2024

What

Dates going to Sjúkratryggingar didn't have hours and minutes, just the date.
locationDescription and description were always coming in as the same thing.
Removed a lot of the "as" keyword in the same file.

Checklist:

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • Formatting passes locally with my changes
  • I have rebased against main before asking for a review

Summary by CodeRabbit

  • New Features

    • Introduced a new section in the Accident Notification Form for agriculture-related accident locations.
    • Added options for users to specify the location of accidents, enhancing detail capture.
  • Improvements

    • Enhanced error handling and type safety in utility functions related to accident notifications.
    • Updated logic for displaying fields based on accident type, refining user experience.

@jonnigs jonnigs requested a review from a team as a code owner November 4, 2024 16:24
Copy link
Contributor

coderabbitai bot commented Nov 4, 2024

Walkthrough

The pull request introduces changes to the accident-notification-v2.utils.ts and locationSubSection.ts files. Enhancements in type safety and error handling are made, including optional parameters and improved type annotations in the utility functions. A new utility function for date creation is added. In the form section, a new multi-field for agriculture-related accidents is introduced, along with conditions for displaying existing fields based on accident types. These modifications enhance the robustness and clarity of the code and improve the form's ability to capture detailed accident information.

Changes

File Change Summary
libs/application/template-api-modules/src/lib/modules/templates/accident-notification/accident-notification-v2.utils.ts Updated whoIsTheNotificationForToDTO to accept an optional parameter; added createDateTime function; improved type annotations and error handling.
libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/aboutTheAccidentSection/locationSubSection.ts Added new buildMultiField for agriculture-related accidents; updated condition for existing buildMultiField for studies-related accidents.

Possibly related PRs

Suggested labels

deploy-feature

Suggested reviewers

  • norda-gunni
  • obmagnusson

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.

@jonnigs jonnigs changed the title fix: dates coming to sjukra fix(accident-notification): dates coming to sjukra Nov 4, 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: 1

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 5242780 and efb078c.

📒 Files selected for processing (2)
  • libs/application/template-api-modules/src/lib/modules/templates/accident-notification/accident-notification-v2.utils.ts (11 hunks)
  • libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/aboutTheAccidentSection/locationSubSection.ts (0 hunks)
💤 Files with no reviewable changes (1)
  • libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/aboutTheAccidentSection/locationSubSection.ts
🧰 Additional context used
📓 Path-based instructions (1)
libs/application/template-api-modules/src/lib/modules/templates/accident-notification/accident-notification-v2.utils.ts (1)

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

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
🔇 Additional comments (6)
libs/application/template-api-modules/src/lib/modules/templates/accident-notification/accident-notification-v2.utils.ts (6)

62-65: LGTM: Improved null safety handling

The function now gracefully handles undefined values by defaulting to self-reporting, which enhances the robustness of the code.


113-124: LGTM: Enhanced type safety with explicit type annotations

The addition of explicit type annotations to getValueViaPath calls improves type safety and makes the code more maintainable.

Also applies to: 158-162, 177-181


207-213: LGTM: Improved null handling with appropriate defaults

The addition of null coalescing operators with empty string defaults ensures the API always receives valid string values, preventing potential null reference issues.

Also applies to: 240-244


352-360: LGTM: Enhanced type safety in conditional logic

The addition of type annotations improves the reliability of conditional checks when determining employer information.


396-409: LGTM: Proper handling of optional club information

The changes ensure robust handling of club-related data for sports accidents with appropriate null checks and defaults.


281-284: Verify the distinction between locationDescription and description fields

The PR objectives mention that locationDescription and description fields were returning the same value. While this change uses different paths for these fields, let's verify they capture distinct information:

  • description: Uses accidentDetails?.descriptionOfAccident
  • locationDescription: Uses locationAndPurpose.location

Let's verify the field usage:

Also applies to: 288-293

✅ Verification successful

Fields locationDescription and description now correctly capture distinct information

The verification confirms these fields are properly differentiated:

  • description uses accidentDetails.descriptionOfAccident which captures the accident description itself
  • locationDescription uses locationAndPurpose.location which captures the location details
  • The fields are used in separate form sections:
    • Location details in locationSubSection.ts
    • Accident details in accidentDetailSubSection.ts
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for references to these fields to ensure they capture different information
echo "Searching for locationDescription usage..."
rg -A 3 "locationAndPurpose.location"

echo "Searching for descriptionOfAccident usage..."
rg -A 3 "descriptionOfAccident"

Length of output: 4723

Copy link

codecov bot commented Nov 4, 2024

Codecov Report

Attention: Patch coverage is 3.27869% with 59 lines in your changes missing coverage. Please review.

Project coverage is 36.56%. Comparing base (f5abefd) to head (5b8cadf).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...ent-notification/accident-notification-v2.utils.ts 3.27% 59 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #16713      +/-   ##
==========================================
+ Coverage   36.52%   36.56%   +0.03%     
==========================================
  Files        6883     6882       -1     
  Lines      143349   143422      +73     
  Branches    40840    40902      +62     
==========================================
+ Hits        52364    52437      +73     
  Misses      90985    90985              
Flag Coverage Δ
air-discount-scheme-backend 54.03% <ø> (ø)
air-discount-scheme-web 0.00% <ø> (ø)
api 3.37% <ø> (ø)
api-domains-air-discount-scheme 36.96% <ø> (ø)
api-domains-assets 26.71% <ø> (ø)
api-domains-auth-admin 48.48% <ø> (ø)
api-domains-communications 39.80% <ø> (ø)
api-domains-criminal-record 47.40% <ø> (ø)
api-domains-driving-license 44.44% <ø> (ø)
api-domains-education 31.20% <ø> (ø)
api-domains-health-insurance 34.23% <ø> (ø)
api-domains-mortgage-certificate 34.63% <ø> (ø)
api-domains-payment-schedule 41.19% <ø> (ø)
application-api-files 56.49% <ø> (ø)
application-core 71.61% <ø> (+0.64%) ⬆️
application-system-api 41.28% <3.27%> (-0.02%) ⬇️
application-template-api-modules 27.78% <3.27%> (-0.02%) ⬇️
application-templates-accident-notification 29.21% <ø> (ø)
application-templates-car-recycling 3.12% <ø> (ø)
application-templates-criminal-record 26.26% <ø> (ø)
application-templates-driving-license 18.40% <ø> (ø)
application-templates-estate 12.18% <ø> (ø)
application-templates-example-payment 25.17% <ø> (ø)
application-templates-financial-aid 15.56% <ø> (ø)
application-templates-general-petition 23.40% <ø> (ø)
application-templates-inheritance-report 6.52% <ø> (ø)
application-templates-marriage-conditions 15.20% <ø> (ø)
application-templates-mortgage-certificate 43.52% <ø> (ø)
application-templates-parental-leave 29.93% <ø> (ø)
application-types 6.62% <ø> (ø)
application-ui-components 1.27% <ø> (ø)
application-ui-shell 20.86% <ø> (ø)
clients-charge-fjs-v2 24.11% <ø> (ø)
clients-driving-license 40.12% <ø> (ø)
clients-driving-license-book 43.38% <ø> (ø)
clients-financial-statements-inao 48.91% <ø> (ø)
clients-license-client 1.83% <ø> (ø)
clients-regulations 42.18% <ø> (ø)
clients-rsk-company-registry 29.76% <ø> (ø)
clients-rsk-personal-tax-return 38.00% <ø> (ø)
clients-smartsolutions 12.77% <ø> (ø)
clients-syslumenn 49.15% <ø> (ø)
cms 0.42% <ø> (ø)
cms-translations 38.92% <ø> (ø)
content-search-toolkit 8.14% <ø> (ø)
contentful-apps 4.69% <ø> (ø)
dokobit-signing 62.40% <ø> (ø)
download-service 44.23% <ø> (ø)
email-service 60.24% <ø> (ø)
feature-flags 90.32% <ø> (ø)
file-storage 52.41% <ø> (ø)
financial-aid-backend 51.24% <ø> (ø)
judicial-system-api 19.57% <ø> (ø)
judicial-system-audit-trail 68.53% <ø> (ø)
judicial-system-backend 55.20% <ø> (+0.10%) ⬆️
judicial-system-message 66.66% <ø> (ø)
judicial-system-message-handler 47.53% <ø> (ø)
judicial-system-scheduler 70.35% <ø> (ø)
license-api 42.46% <ø> (-0.08%) ⬇️
nest-config 77.74% <ø> (ø)
nest-feature-flags 50.83% <ø> (+0.64%) ⬆️
nova-sms 61.71% <ø> (ø)
portals-admin-regulations-admin 1.85% <ø> (ø)
portals-core 15.96% <ø> (ø)
services-auth-admin-api 51.87% <ø> (ø)
services-auth-delegation-api 57.45% <ø> (-0.07%) ⬇️
services-auth-ids-api 51.46% <ø> (ø)
services-auth-personal-representative 45.08% <ø> (+0.02%) ⬆️
services-auth-personal-representative-public 41.27% <ø> (ø)
services-auth-public-api 48.96% <ø> (ø)
services-endorsements-api 53.58% <ø> (ø)
services-sessions 65.36% <ø> (ø)
services-university-gateway 49.28% <ø> (ø)
services-user-notification 46.89% <ø> (ø)
services-user-profile 61.82% <ø> (+0.09%) ⬆️
web 1.80% <ø> (ø)

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

Files with missing lines Coverage Δ
...Form/aboutTheAccidentSection/locationSubSection.ts 0.00% <ø> (ø)
...ent-notification/accident-notification-v2.utils.ts 16.06% <3.27%> (-0.99%) ⬇️

... and 5 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 f5abefd...5b8cadf. Read the comment docs.

Copy link
Member

@HjorturJ HjorturJ left a comment

Choose a reason for hiding this comment

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

LGTM

@datadog-island-is
Copy link

datadog-island-is bot commented Nov 4, 2024

Datadog Report

All test runs a701fed 🔗

66 Total Test Services: 1 Failed, 62 Passed
🔻 Test Sessions change in coverage: 4 decreased, 196 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
services-auth-admin-api 1 0 0 55 0 0s N/A Link
air-discount-scheme-backend 0 0 0 82 0 29.38s N/A Link
air-discount-scheme-web 0 0 0 2 0 7.61s 1 no change Link
api 0 0 0 4 0 2.71s N/A Link
api-domains-air-discount-scheme 0 0 0 6 0 18s 1 no change Link
api-domains-assets 0 0 0 3 0 11.43s 1 no change Link
api-domains-auth-admin 0 0 0 18 0 13s N/A Link
api-domains-communications 0 0 0 5 0 30.43s 1 no change Link
api-domains-criminal-record 0 0 0 5 0 9.25s 1 no change Link
api-domains-driving-license 0 0 0 23 0 27.53s 1 no change Link

❌ Failed Tests (1)

  • MeScopesController with auth should return a forbidden exception when removing super user delegation type: PersonalRepresentative PATCH: should return a forbidden exception when removing super user delegation type: PersonalRepresentative - apps/services/auth/admin-api/src/app/v2/scopes/test/me-scopes.spec.ts - Details

    Expand for error
     terminating connection due to administrator command
    

🔻 Code Coverage Decreases vs Default Branch (4)

  • application-core - jest 79.62% (-0.2%) - Details
  • services-auth-delegation-api - jest 51.36% (-0.18%) - Details
  • services-university-gateway - jest 45.06% (-0.03%) - Details
  • application-template-api-modules - jest 30.04% (-0.01%) - Details

@jonnigs jonnigs added the deprecated:automerge (Disabled) Merge this PR as soon as all checks pass label Nov 4, 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/template-api-modules/src/lib/modules/templates/accident-notification/accident-notification-v2.utils.ts (1)

Line range hint 1-1: Update documentation to reflect date format changes

The PR checklist indicates that documentation updates are pending. Please update the documentation to reflect:

  1. The new date+time format being sent to Sjúkratryggingar
  2. The separation of location and accident descriptions
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between efb078c and 5b8cadf.

📒 Files selected for processing (1)
  • libs/application/template-api-modules/src/lib/modules/templates/accident-notification/accident-notification-v2.utils.ts (11 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
libs/application/template-api-modules/src/lib/modules/templates/accident-notification/accident-notification-v2.utils.ts (1)

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

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
🔇 Additional comments (6)
libs/application/template-api-modules/src/lib/modules/templates/accident-notification/accident-notification-v2.utils.ts (6)

113-124: LGTM! Enhanced type safety

Added proper TypeScript type annotations to improve type checking and code maintainability.


290-302: LGTM! Improved date handling and field separation

The changes properly address both PR objectives:

  1. Dates now include time information using createDateTime
  2. Location description and accident description are properly separated

361-369: LGTM! Enhanced type safety

Added proper TypeScript type annotations to improve type checking.


405-415: LGTM! Enhanced type safety

Added proper TypeScript type annotations to improve type checking.


62-65: LGTM! Improved null safety

The function now properly handles undefined cases by defaulting to self-reporting.


248-266: Consider timezone handling

While the function correctly handles hours and minutes now, it might be worth considering timezone implications when creating the Date object.

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.

2 participants