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(application-system): Error messages, input validation, code cleanup #17571

Merged
merged 8 commits into from
Jan 20, 2025

Conversation

Ballioli
Copy link
Member

@Ballioli Ballioli commented Jan 20, 2025

...

Attach a link to issue if relevant

What

Specify what you're trying to achieve

Why

Specify why you need to achieve this

Screenshots / Gifs

Attach Screenshots / Gifs to help reviewers understand the scope of the pull request

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

    • Added an alert message when an employee's national ID matches the user's national ID.
    • Enhanced form validation for occupation, employment rate, and accident time fields.
    • Introduced a new scope related to accident management.
  • Bug Fixes

    • Improved error handling in the application submission process.
    • Updated validation checks for form fields.
  • Documentation

    • Added a new message for self-reporting workplace accidents.
  • Refactor

    • Modified external data and message structures.
    • Updated API scopes for accident management.
  • Style

    • Adjusted form section titles and layouts.

@Ballioli Ballioli requested review from a team as code owners January 20, 2025 13:02
Copy link
Contributor

coderabbitai bot commented Jan 20, 2025

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 eslint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

warning [email protected]: This version is no longer supported. Please see https://eslint.org/version-support for other options.
warning eslint > @humanwhocodes/[email protected]: Use @eslint/config-array instead
warning eslint > @humanwhocodes/config-array > @humanwhocodes/[email protected]: Use @eslint/object-schema instead
warning eslint > file-entry-cache > flat-cache > [email protected]: Rimraf versions prior to v4 are no longer supported
warning eslint > file-entry-cache > flat-cache > rimraf > [email protected]: Glob versions prior to v9 are no longer supported
warning eslint > file-entry-cache > flat-cache > rimraf > glob > [email protected]: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
warning jest > @jest/core > jest-config > [email protected]: Glob versions prior to v9 are no longer supported
warning jest > @jest/core > @jest/reporters > [email protected]: Glob versions prior to v9 are no longer supported
warning jest > @jest/core > jest-runtime > [email protected]: Glob versions prior to v9 are no longer supported
warning jest > @jest/core > @jest/transform > babel-plugin-istanbul > test-exclude > [email protected]: Glob versions prior to v9 are no longer supported
warning storybook > @storybook/cli > puppeteer-core > [email protected]: Rimraf versions prior to v4 are no longer supported
warning storybook > @storybook/cli > puppeteer-core > rimraf > [email protected]: Glob versions prior to v9 are no longer supported
warning storybook > @storybook/cli > tempy > del > [email protected]: Rimraf versions prior to v4 are no longer supported
warning storybook > @storybook/cli > jscodeshift > temp > [email protected]: Rimraf versions prior to v4 are no longer supported
warning storybook > @storybook/cli > jscodeshift > temp > rimraf > [email protected]: Glob versions prior to v9 are no longer supported
warning storybook > @storybook/cli > jscodeshift > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-class-properties instead.
warning storybook > @storybook/cli > jscodeshift > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-optional-chaining instead.
warning storybook > @storybook/cli > jscodeshift > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-nullish-coalescing-operator instead.
warning react-native > @react-native/codegen > [email protected]: Glob versions prior to v9 are no longer supported
warning react-native > @react-native/community-cli-plugin > [email protected]: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
warning react-native > @react-native-community/cli > @react-native-community/cli-tools > [email protected]: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.
warning react-native > @react-native/community-cli-plugin > @react-native/dev-middleware > @rnx-kit/chromium-edge-launcher > [email protected]: Rimraf versions prior to v4 are no longer supported
warning react-native > @react-native/community-cli-plugin > @react-native/metro-babel-transformer > @react-native/babel-preset > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-class-properties instead.
warning react-native > @react-native/community-cli-plugin > @react-native/metro-babel-transformer > @react-native/babel-preset > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-optional-chaining instead.
warning react-native > @react-native/community-cli-plugin > @react-native/metro-babel-transformer > @react-native/babel-preset > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-nullish-coalescing-operator instead.
warning react-native > @react-native/community-cli-plugin > @react-native/metro-babel-transformer > @react-native/babel-preset > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-numeric-separator instead.
warning react-native > @react-native/community-cli-plugin > @react-native/metro-babel-transformer > @react-native/babel-preset > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-optional-catch-binding instead.
warning react-native > @react-native/community-cli-plugin > @react-native/metro-babel-transformer > @react-native/babel-preset > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-async-generator-functions instead.
warning react-native > @react-native/community-cli-plugin > @react-native/metro-babel-transformer > @react-native/babel-preset > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-object-rest-spread instead.
warning react-native > @react-native/community-cli-plugin > @react-native/metro-babel-transformer > @react-native/babel-preset > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-logical-assignment-operators instead.
warning next-auth > [email protected]: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
warning next-auth > [email protected]: this version is no longer supported
warning next-auth > @next-auth/typeorm-legacy-adapter > typeorm > [email protected]: Glob versions prior to v9 are no longer supported
warning @nx/next > @nx/webpack > stylus > [email protected]: Glob versions prior to v9 are no longer supported
warning @nx/next > @nx/webpack > webpack-dev-server > [email protected]: Rimraf versions prior to v4 are no longer supported
warning @nx/next > @nx/webpack > fork-ts-checker-webpack-plugin > [email protected]: this will be v4
warning @nx/next > @nx/webpack > webpack-dev-server > webpack-dev-middleware > [email protected]: this will be v4
warning workspace-aggregator-2cf0b9b1-289e-4f04-ba71-54e0ac77acde > [email protected]: This version is no longer supported. Please see https://eslint.org/version-support for other options.

Walkthrough

This pull request introduces several modifications to the Work Accident Notification application, focusing on enhancing error handling, validation, and user experience. Changes span multiple files across the application, including service logic, form validation, message definitions, and API scopes. The modifications aim to improve data integrity, provide clearer user feedback, and refine the application's overall robustness.

Changes

File Path Change Summary
libs/application/template-api-modules/.../work-accident-notification.service.ts Updated error handling in submitApplication method, added xCorrelationId, improved error logging
libs/application/templates/aosh/work-accident-notification/src/fields/Occupation/index.tsx Added validation checks for occupation selection, marked occupation selection fields as required
libs/application/templates/aosh/work-accident-notification/src/forms/... Various form-related changes:
- Reduced maxLength for accident description fields
- Updated section titles
- Added alert message for employee data entry
libs/application/templates/aosh/work-accident-notification/src/lib/WorkAccidentNotificationTemplate.ts Changed required API scope from vinnueftirlitid to vinnueftirlitidAccident
libs/application/templates/aosh/work-accident-notification/src/lib/dataSchema.ts Enhanced data validation for accident time, employee employment rate, and company postcode
libs/auth/scopes/src/lib/api.scope.ts Added new vinnueftirlitidAccident API scope

Possibly related PRs

Suggested Labels

automerge, deploy-feature

Suggested Reviewers

  • johannaagma
  • HjorturJ

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9d71630 and 31fdf94.

📒 Files selected for processing (1)
  • libs/application/templates/aosh/work-accident-notification/src/forms/WorkAccidentNotificationForm/EmployeeSection/employee.ts (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
libs/application/templates/aosh/work-accident-notification/src/forms/WorkAccidentNotificationForm/EmployeeSection/employee.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 (1)
libs/application/templates/aosh/work-accident-notification/src/forms/WorkAccidentNotificationForm/EmployeeSection/employee.ts (1)

24-25: LGTM! Type imports follow guidelines.

The new TypeScript type imports enhance type safety and follow the coding guidelines for library files.

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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
Member

@berglindoma13 berglindoma13 left a comment

Choose a reason for hiding this comment

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

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: 2

🧹 Nitpick comments (7)
libs/application/templates/aosh/work-accident-notification/src/fields/Occupation/index.tsx (3)

4-4: Remove unused ErrorMessage import.

The ErrorMessage component is imported but never used in the code. Remove it to maintain effective tree-shaking.

-import { Box, ErrorMessage, Select } from '@island.is/island-ui/core'
+import { Box, Select } from '@island.is/island-ui/core'

178-186: Extract duplicate validation logic into a reusable function.

The validation logic is duplicated between onChangeSubMajorGroup and onChangeMinorGroup. Extract it into a shared function to improve maintainability.

+const updateOccupationIfValid = (
+  selectedGroup: Options,
+  groupOptions: VictimsOccupationDto[],
+  idx: number,
+  setValue: Function,
+) => {
+  if (selectedGroup?.value) {
+    const isValidToSelect = findGroupByCode(
+      groupOptions,
+      selectedGroup.value,
+    )?.validToSelect
+    if (isValidToSelect) {
+      setValue(`employee[${idx}].victimsOccupation`, selectedGroup)
+    }
+  }
+}

 const onChangeSubMajorGroup = (value?: EventOption) => {
   if (!value || !value.value || !value.label) return
   const selectedGroup: Options = {
     value: value.value,
     label: value.label,
   }
   setSelectedSubMajorGroup(selectedGroup)
-  if (selectedGroup?.value) {
-    const isValidToSelect = findGroupByCode(
-      subMajorGroupOptions,
-      selectedGroup.value,
-    )?.validToSelect
-    if (isValidToSelect) {
-      setValue(`employee[${idx}].victimsOccupation`, selectedGroup)
-    }
-  }
+  updateOccupationIfValid(selectedGroup, subMajorGroupOptions, idx, setValue)
   // ... rest of the function
 }

 const onChangeMinorGroup = (value?: EventOption) => {
   if (!value || !value.value || !value.label) return
   const selectedGroup: Options = {
     value: value.value,
     label: value.label,
   }
   setSelectedMinorGroup(selectedGroup)
-  if (selectedGroup?.value) {
-    const isValidToSelect = findGroupByCode(
-      minorGroupOptions,
-      selectedGroup.value,
-    )?.validToSelect
-    if (isValidToSelect) {
-      setValue(`employee[${idx}].victimsOccupation`, selectedGroup)
-    }
-  }
+  updateOccupationIfValid(selectedGroup, minorGroupOptions, idx, setValue)
   // ... rest of the function
 }

Also applies to: 207-215


Line range hint 1-494: Consider splitting the component for better reusability.

The component is quite large and handles multiple responsibilities (search, validation, state management). Consider splitting it into smaller, focused components:

  • OccupationSearch
  • OccupationGroupSelect
  • OccupationForm

This would improve maintainability and reusability across different NextJS apps.

libs/application/template-api-modules/src/lib/modules/templates/aosh/work-accident-notification/work-accident-notification.service.ts (1)

108-113: Consider enhancing error handling with specific error details.

The current implementation throws a generic error message. Consider:

  1. Including the original error details in the thrown error
  2. Using a custom error class for better error handling upstream
- throw Error('Error submitting application to AOSH')
+ throw new TemplateApiError(
+   {
+     title: 'AOSH Submission Error',
+     summary: error.message || 'Error submitting application to AOSH',
+   },
+   500,
+ )
libs/application/templates/aosh/work-accident-notification/src/lib/dataSchema.ts (2)

30-49: Add edge case handling for time validation.

The time validation for the current date could have edge cases around midnight. Consider adding a small buffer time to prevent validation issues during form submission.

       if (date.toDateString() === now.toDateString()) {
         const hours = parseInt(data.time.slice(0, 2))
         const minutes = parseInt(data.time.slice(2, 4))
         const inputTime = new Date()
         inputTime.setHours(hours, minutes, 0, 0)
+        // Add a 1-minute buffer for form submission
+        const bufferTime = new Date(now.getTime() + 60000)
-        if (inputTime > now) {
+        if (inputTime > bufferTime) {
           return false
         }
       }

82-90: Add input sanitization for employment rate.

While the validation is correct, consider sanitizing the input by trimming whitespace and handling decimal values.

     employmentRate: z.string().refine(
       (v) => {
+        const sanitized = v.trim()
+        if (!/^\d+\.?\d*$/.test(sanitized)) return false
-        const rateNum = parseInt(v, 10)
+        const rateNum = parseFloat(sanitized)
         return rateNum > 0 && rateNum <= 100
       },
       {
         message: '1-100%',
       },
     ),
libs/application/templates/aosh/work-accident-notification/src/lib/messages/externalData.ts (1)

Line range hint 27-41: Consider breaking down the long announcement message.

The announcement message contains multiple important pieces of information mixed together. Consider:

  1. Breaking it into smaller, focused messages for better maintainability
  2. Using a structured format (like a list) for better readability
  3. Moving the business logic (user role validation) to a separate component

Example structure:

announcementWarning: {
  id: '...#markdown',
  defaultMessage: 'Vinsamlega athugaðu að þú ert innskráð/ur sem einstaklingur.',
},
announcementEmployerDuty: {
  id: '...#markdown',
  defaultMessage: 'Atvinnurekanda ber skylda til að...',
},
announcementLoginAdvice: {
  id: '...#markdown',
  defaultMessage: 'Ef þú ert að skrá þessa tilkynningu fyrir hönd fyrirtækis...',
}
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6cd8e3a and 9d71630.

📒 Files selected for processing (13)
  • libs/application/template-api-modules/src/lib/modules/templates/aosh/work-accident-notification/work-accident-notification.service.ts (2 hunks)
  • libs/application/templates/aosh/work-accident-notification/src/fields/Occupation/index.tsx (7 hunks)
  • libs/application/templates/aosh/work-accident-notification/src/forms/WorkAccidentNotificationForm/AccidentSection/about.ts (3 hunks)
  • libs/application/templates/aosh/work-accident-notification/src/forms/WorkAccidentNotificationForm/AnnouncementSection/index.ts (2 hunks)
  • libs/application/templates/aosh/work-accident-notification/src/forms/WorkAccidentNotificationForm/ConclusionSection/index.ts (1 hunks)
  • libs/application/templates/aosh/work-accident-notification/src/forms/WorkAccidentNotificationForm/EmployeeSection/employee.ts (2 hunks)
  • libs/application/templates/aosh/work-accident-notification/src/forms/WorkAccidentNotificationForm/InformationSection/companySection.ts (2 hunks)
  • libs/application/templates/aosh/work-accident-notification/src/forms/WorkAccidentNotificationForm/InformationSection/projectPurchase.ts (0 hunks)
  • libs/application/templates/aosh/work-accident-notification/src/lib/WorkAccidentNotificationTemplate.ts (1 hunks)
  • libs/application/templates/aosh/work-accident-notification/src/lib/dataSchema.ts (3 hunks)
  • libs/application/templates/aosh/work-accident-notification/src/lib/messages/employee.ts (1 hunks)
  • libs/application/templates/aosh/work-accident-notification/src/lib/messages/externalData.ts (1 hunks)
  • libs/auth/scopes/src/lib/api.scope.ts (1 hunks)
💤 Files with no reviewable changes (1)
  • libs/application/templates/aosh/work-accident-notification/src/forms/WorkAccidentNotificationForm/InformationSection/projectPurchase.ts
🧰 Additional context used
📓 Path-based instructions (12)
libs/auth/scopes/src/lib/api.scope.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/aosh/work-accident-notification/src/forms/WorkAccidentNotificationForm/AccidentSection/about.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/aosh/work-accident-notification/src/forms/WorkAccidentNotificationForm/InformationSection/companySection.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/aosh/work-accident-notification/work-accident-notification.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/aosh/work-accident-notification/src/lib/messages/employee.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/aosh/work-accident-notification/src/forms/WorkAccidentNotificationForm/ConclusionSection/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/aosh/work-accident-notification/src/lib/WorkAccidentNotificationTemplate.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/aosh/work-accident-notification/src/forms/WorkAccidentNotificationForm/AnnouncementSection/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/aosh/work-accident-notification/src/lib/messages/externalData.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/aosh/work-accident-notification/src/forms/WorkAccidentNotificationForm/EmployeeSection/employee.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/aosh/work-accident-notification/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/aosh/work-accident-notification/src/fields/Occupation/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."
🔇 Additional comments (13)
libs/auth/scopes/src/lib/api.scope.ts (1)

31-31: LGTM! Good separation of concerns for accident-related functionality.

The new scope vinnueftirlitidAccident provides more granular access control compared to the general vinnueftirlitid scope, following the principle of least privilege.

Let's verify if this new scope is used consistently:

✅ Verification successful

Scope implementation verified and consistent

The new vinnueftirlitidAccident scope is properly implemented and consistently used:

  • Defined in the central scopes file
  • Correctly used in the work accident notification template
  • No instances of using the general scope for accident-related functionality
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any usage of the old scope in accident-related files
rg "vinnueftirlitid[^A]" -g "*accident*"

# Search for usage of the new scope
rg "vinnueftirlitidAccident" -g "*.ts"

Length of output: 345

libs/application/templates/aosh/work-accident-notification/src/lib/WorkAccidentNotificationTemplate.ts (1)

48-48: LGTM! Proper implementation of the new granular scope.

The template correctly uses the new accident-specific scope, maintaining consistency with the scope definition changes.

libs/application/templates/aosh/work-accident-notification/src/forms/WorkAccidentNotificationForm/ConclusionSection/index.ts (1)

14-14: LGTM! Improved section title.

Adding a meaningful title enhances the user experience and maintains consistency with the tabTitle.

libs/application/template-api-modules/src/lib/modules/templates/aosh/work-accident-notification/work-accident-notification.service.ts (1)

57-57: LGTM! Added correlation ID for better traceability.

Using application.id as correlation ID helps in tracking requests through the system.

libs/application/templates/aosh/work-accident-notification/src/forms/WorkAccidentNotificationForm/AccidentSection/about.ts (1)

132-132: Verify the reason for reducing maxLength to 498 characters.

The maxLength has been reduced by 2 characters for three text fields. This seems like a specific constraint, possibly related to backend processing or database limitations.

Also applies to: 141-141, 150-150

libs/application/templates/aosh/work-accident-notification/src/lib/messages/employee.ts (1)

164-169: LGTM! Well-crafted alert message with legal context.

The new alert message effectively:

  1. Warns about self-reporting restrictions
  2. References relevant legislation (law 46/1980, article 79)
  3. Provides clear guidance for both employees and self-employed individuals
libs/application/templates/aosh/work-accident-notification/src/forms/WorkAccidentNotificationForm/EmployeeSection/employee.ts (1)

24-25: LGTM! Well-typed imports from shared packages.

The new imports follow TypeScript best practices and promote code reusability by utilizing shared type definitions.

libs/application/templates/aosh/work-accident-notification/src/lib/dataSchema.ts (2)

66-66: LGTM! Nullable postnumber field.

Making postnumberOfBranch nullable aligns with the optional nature of branch information in the form.


12-14: Consider adding timezone handling to time validation.

The time validation should explicitly handle timezone differences to ensure consistent behavior across different regions.

 const TimeWithRefine = z
   .string()
-  .refine((x) => (x ? isValid24HFormatTime(x) : false), {})
+  .refine((x) => (x ? isValid24HFormatTime(x) : false), {
+    message: 'Invalid time format. Please use 24-hour format (HHMM)',
+  })
libs/application/templates/aosh/work-accident-notification/src/forms/WorkAccidentNotificationForm/InformationSection/companySection.ts (1)

Line range hint 177-201: LGTM! Improved parameter handling in conditions.

The changes properly handle unused parameters using the underscore convention, which is a TypeScript best practice. The conditional logic remains correct while improving code clarity.

libs/application/templates/aosh/work-accident-notification/src/forms/WorkAccidentNotificationForm/AnnouncementSection/index.ts (2)

8-8: LGTM! Import changes improve tree-shaking.

The specific import of FormValue instead of the entire Application type improves tree-shaking capabilities.


23-25: Consider accessibility implications of empty title.

An empty title in a description field might affect screen readers and accessibility. If the heading is intentionally removed, consider adding an aria-label or using an alternative accessible structure.

✅ Verification successful

Empty title is part of the established design pattern.

The empty title in this description field follows a common pattern used throughout the codebase for supplementary content and layout purposes. The accessibility is maintained through:

  • Parent section headings providing context
  • Description text for screen readers
  • Proper heading hierarchy with titleVariant properties
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for other empty titles in description fields
ast-grep --pattern 'buildDescriptionField({
  $$$
  title: "",
  $$$
})'

Length of output: 74


Script:

#!/bin/bash
# Check for buildDescriptionField usage with broader pattern
ast-grep --pattern 'buildDescriptionField({$$$})'

# Also check the component implementation
rg -l "buildDescriptionField" --type ts

# Look for similar title patterns
rg "title: ['\"]{2}" --type ts

Length of output: 66858

libs/application/templates/aosh/work-accident-notification/src/lib/messages/externalData.ts (1)

27-27: Verify markdown support implementation.

The addition of #markdown suffix suggests markdown formatting support. Ensure that:

  1. The markdown parser is properly implemented
  2. The content is safely sanitized
  3. The rendering component handles markdown correctly
✅ Verification successful

Markdown implementation is properly secured and well-implemented

The markdown implementation:

  • Uses a reliable markdown parser (markdown-to-jsx)
  • Implements proper sanitization by disabling raw HTML parsing
  • Uses secure component overrides from the UI library
  • Handles links safely with configurable behavior
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for markdown handling implementation
rg -l "markdown|sanitize|parse" --type ts

Length of output: 53078


Script:

#!/bin/bash
# Check for Markdown component usage in the template
rg -A 5 "Markdown" "libs/application/templates/aosh/work-accident-notification/"

# Check Markdown component implementation
cat "libs/shared/components/src/Markdown/Markdown.tsx"

# Check markdown options and sanitization
cat "libs/shared/components/src/Markdown/markdownOptions.tsx"

Length of output: 2122

@datadog-island-is
Copy link

datadog-island-is bot commented Jan 20, 2025

Datadog Report

All test runs 047eeba 🔗

10 Total Test Services: 0 Failed, 10 Passed
🔻 Test Sessions change in coverage: 1 decreased (-0.01%), 4 increased, 195 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-backend 0 0 0 63 0 22.62s N/A Link
air-discount-scheme-web 0 0 0 2 0 6.58s N/A Link
api 0 0 0 4 0 2.54s N/A Link
api-catalogue-services 0 0 0 23 0 9.35s N/A Link
api-domains-air-discount-scheme 0 0 0 6 0 16.69s N/A Link
api-domains-assets 0 0 0 3 0 9.6s N/A Link
api-domains-auth-admin 0 0 0 18 0 10.21s 1 no change Link
api-domains-communications 0 0 0 5 0 31.32s N/A Link
api-domains-criminal-record 0 0 0 5 0 8.55s N/A Link
api-domains-driving-license 0 0 0 23 0 27.72s N/A Link

🔻 Code Coverage Decreases vs Default Branch (1)

  • services-user-profile - jest 49.33% (-0.01%) - Details

Copy link

codecov bot commented Jan 20, 2025

Codecov Report

Attention: Patch coverage is 25.00000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 35.57%. Comparing base (50310aa) to head (9882093).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...notification/work-accident-notification.service.ts 0.00% 3 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main   #17571   +/-   ##
=======================================
  Coverage   35.57%   35.57%           
=======================================
  Files        7027     7027           
  Lines      150428   150429    +1     
  Branches    42940    42940           
=======================================
+ Hits        53516    53518    +2     
+ Misses      96912    96911    -1     
Flag Coverage Δ
air-discount-scheme-backend 48.26% <100.00%> (+0.01%) ⬆️
air-discount-scheme-web 0.00% <ø> (ø)
api 3.33% <ø> (ø)
api-catalogue-services 75.81% <ø> (ø)
api-domains-air-discount-scheme 38.14% <100.00%> (+0.02%) ⬆️
api-domains-assets 26.71% <ø> (ø)
api-domains-auth-admin 48.49% <ø> (ø)
api-domains-communications 39.52% <ø> (ø)
api-domains-criminal-record 48.11% <ø> (ø)
api-domains-driving-license 44.89% <100.00%> (+0.01%) ⬆️
api-domains-education 31.35% <ø> (ø)
api-domains-health-insurance 35.56% <ø> (ø)
api-domains-mortgage-certificate 35.18% <ø> (ø)
api-domains-payment-schedule 42.26% <100.00%> (+0.02%) ⬆️
application-api-files 62.06% <ø> (ø)
application-core 75.68% <100.00%> (+0.01%) ⬆️
application-system-api 38.67% <25.00%> (+<0.01%) ⬆️
application-template-api-modules 27.56% <25.00%> (+<0.01%) ⬆️
application-templates-accident-notification 27.60% <ø> (ø)
application-templates-car-recycling 3.12% <ø> (ø)
application-templates-criminal-record 25.79% <ø> (ø)
application-templates-driving-license 18.15% <ø> (ø)
application-templates-estate 13.58% <ø> (ø)
application-templates-example-payment 24.66% <ø> (ø)
application-templates-financial-aid 14.62% <ø> (ø)
application-templates-general-petition 23.13% <ø> (ø)
application-templates-inheritance-report 6.59% <ø> (ø)
application-templates-marriage-conditions 14.80% <ø> (ø)
application-templates-mortgage-certificate 43.73% <ø> (ø)
application-templates-new-primary-school 21.02% <ø> (ø)
application-templates-parental-leave 29.92% <ø> (ø)
application-types 6.47% <ø> (ø)
application-ui-components 1.17% <ø> (ø)
application-ui-shell 22.01% <ø> (ø)
auth-admin-web 2.43% <ø> (ø)
auth-nest-tools 31.69% <ø> (ø)
auth-shared 75.00% <ø> (ø)
clients-charge-fjs-v2 28.88% <ø> (ø)
clients-driving-license 40.99% <ø> (ø)
clients-driving-license-book 43.98% <ø> (ø)
clients-financial-statements-inao 49.78% <ø> (ø)
clients-license-client 1.26% <ø> (ø)
clients-regulations 43.08% <ø> (ø)
clients-rsk-company-registry 31.18% <ø> (ø)
clients-rsk-personal-tax-return 38.32% <ø> (ø)
clients-smartsolutions 12.77% <ø> (ø)
clients-syslumenn 49.35% <ø> (ø)
clients-zendesk 50.81% <ø> (ø)
cms 0.39% <ø> (ø)
cms-translations 38.86% <ø> (ø)
content-search-index-manager 95.65% <ø> (ø)
content-search-toolkit 8.16% <ø> (ø)
contentful-apps 4.56% <ø> (ø)
dokobit-signing 62.35% <ø> (ø)
email-service 60.31% <ø> (ø)
feature-flags 90.97% <ø> (ø)
file-storage 46.18% <ø> (ø)
financial-aid-backend 51.48% <100.00%> (+0.01%) ⬆️
icelandic-names-registry-backend 54.44% <100.00%> (+0.03%) ⬆️
infra-nest-server 48.06% <ø> (ø)
infra-tracing 69.94% <ø> (ø)
island-ui-core 30.32% <ø> (ø)
judicial-system-api 20.07% <ø> (ø)
judicial-system-audit-trail 69.19% <ø> (ø)
judicial-system-backend 55.84% <ø> (ø)
judicial-system-formatters 78.86% <ø> (ø)
judicial-system-message 66.78% <ø> (ø)
judicial-system-message-handler 48.59% <ø> (ø)
judicial-system-scheduler 71.42% <ø> (ø)
judicial-system-types 37.77% <ø> (ø)
judicial-system-web 27.97% <ø> (ø)
license-api 43.07% <100.00%> (+0.08%) ⬆️
localization 10.15% <ø> (ø)
logging 58.02% <ø> (ø)
message-queue 67.05% <ø> (ø)
nest-audit 65.78% <ø> (ø)
nest-aws 51.93% <ø> (ø)
nest-config 76.58% <ø> (ø)
nest-core 53.16% <ø> (ø)
nest-feature-flags 51.18% <ø> (ø)
nest-problem 45.64% <ø> (ø)
nest-sequelize 94.44% <ø> (ø)
nest-swagger 51.13% <ø> (ø)
nova-sms 61.70% <ø> (ø)
portals-admin-regulations-admin 1.80% <ø> (ø)
portals-core 19.60% <ø> (ø)
regulations 16.78% <ø> (ø)
residence-history 85.00% <ø> (ø)
services-auth-admin-api 52.51% <100.00%> (+<0.01%) ⬆️
services-auth-delegation-api 58.42% <100.00%> (+0.01%) ⬆️
services-auth-ids-api 52.54% <100.00%> (+0.01%) ⬆️
services-auth-public-api 49.40% <100.00%> (+<0.01%) ⬆️
services-sessions 65.45% <100.00%> (+0.01%) ⬆️
services-university-gateway 49.49% <ø> (ø)
services-user-notification 46.57% <100.00%> (+<0.01%) ⬆️
services-user-profile 56.93% <100.00%> (-0.06%) ⬇️
shared-components 29.47% <ø> (ø)
shared-form-fields 33.38% <ø> (ø)
shared-mocking 58.64% <ø> (ø)
shared-pii 92.85% <ø> (ø)
shared-problem 87.50% <ø> (ø)
shared-utils 28.67% <ø> (ø)
skilavottord-ws 23.97% <ø> (ø)
web 2.39% <ø> (ø)

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

Files with missing lines Coverage Δ
libs/auth/scopes/src/lib/api.scope.ts 100.00% <100.00%> (ø)
...notification/work-accident-notification.service.ts 28.94% <0.00%> (ø)

... and 1 file 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 50310aa...9882093. Read the comment docs.

@Ballioli Ballioli enabled auto-merge January 20, 2025 14:28
@Ballioli Ballioli added this pull request to the merge queue Jan 20, 2025
@Ballioli Ballioli added this pull request to the merge queue Jan 20, 2025
Merged via the queue into main with commit b4e88ca Jan 20, 2025
259 checks passed
@Ballioli Ballioli deleted the fix/aosh-accidents-after-testing branch January 20, 2025 21:27
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to an unknown Git error Jan 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants