Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(j-s): Speeding #17589

Merged
merged 23 commits into from
Jan 29, 2025
Merged

feat(j-s): Speeding #17589

merged 23 commits into from
Jan 29, 2025

Conversation

oddsson
Copy link
Member

@oddsson oddsson commented Jan 21, 2025

Speeding

Asana

What

Add a new offence to indictment counts, speeding.

When speeding is selected, prosecutors need to input two values into new fields on the indictment count, recorded speed and speed limit. The rest of the indictment takes note of that and generates a description and everything else accordingly.

Why

An indictment is issued when people don't pay the fines for speeding. This enables users to handle these types of cases in RVG.

Screenshots / Gifs

Screenshot 2025-01-21 at 13 49 09

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 support for recording speed and speed limit in indictment counts.
    • Introduced a new offense type for speeding.
    • Enhanced validation for speeding-related indictment details.
  • Documentation

    • Updated string resources to include speeding-related labels and messages.
    • Added GraphQL schema updates to support new speed-related fields.
  • Refactor

    • Modified validation logic to handle speeding offense details.
    • Updated hooks and utility functions to support new speed-related properties.

Copy link
Contributor

coderabbitai bot commented Jan 21, 2025

Walkthrough

This pull request introduces support for speeding offenses in the judicial system by adding new properties and handling mechanisms across multiple files. The changes include adding recordedSpeed and speedLimit to various data models, input DTOs, and GraphQL schemas. A new SPEEDING offense type is introduced, and the application logic is updated to handle speed-related information for indictment counts, including validation, UI rendering, and database migration.

Changes

File Path Change Summary
api/src/app/modules/indictment-count/dto/updateIndictmentCount.input.ts Added optional recordedSpeed and speedLimit properties with number validation
api/src/app/modules/indictment-count/models/indictmentCount.model.ts Added recordedSpeed and speedLimit fields to GraphQL model
backend/migrations/20250120150345-update-indictment-count.js Created database migration to add recorded_speed and speed_limit columns
backend/src/app/modules/indictment-count/dto/updateIndictmentCount.dto.ts Added optional recordedSpeed and speedLimit properties with API documentation
backend/src/app/modules/indictment-count/models/indictmentCount.model.ts Added recordedSpeed and speedLimit properties with API annotations
web/src/components/FormProvider/case.graphql Added recordedSpeed and speedLimit to GraphQL query
web/src/routes/Prosecutor/Indictments/Indictment/IndictmentCount.tsx Enhanced component to handle speeding offense inputs and validation
web/src/routes/Prosecutor/Indictments/IndictmentCountEnum.strings.ts Added new entry for SPEEDING offense in enum
web/src/utils/hooks/useIndictmentCounts/updateIndictmentCount.graphql Updated mutation to include recordedSpeed and speedLimit in response
web/src/utils/validate.ts Introduced validation logic for speeding offenses
libs/judicial-system/types/src/lib/indictmentCount.ts Added SPEEDING to IndictmentCountOffense enum

Possibly related PRs

Suggested Labels

automerge

Suggested Reviewers

  • thorhildurt
  • unakb

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.

@oddsson oddsson marked this pull request as ready for review January 21, 2025 13:54
@oddsson oddsson requested review from a team as code owners January 21, 2025 13:54
@oddsson oddsson requested a review from disaerna January 21, 2025 13:54
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: 7

🧹 Nitpick comments (5)
apps/judicial-system/api/src/app/modules/indictment-count/dto/updateIndictmentCount.input.ts (1)

67-77: Enhance validation for speed-related fields.

Consider adding custom validation to ensure that recordedSpeed and speedLimit contain valid numeric values when provided.

+import { IsNumberString } from 'class-validator'

 @Allow()
 @IsOptional()
 @IsString()
+@IsNumberString()
 @Field(() => String, { nullable: true })
 readonly recordedSpeed?: string

 @Allow()
 @IsOptional()
 @IsString()
+@IsNumberString()
 @Field(() => String, { nullable: true })
 readonly speedLimit?: string
apps/judicial-system/backend/src/app/modules/indictment-count/models/indictmentCount.model.ts (1)

84-90: Consider adding database-level constraints for speed values.

While the application validates these fields, consider adding database-level CHECK constraints to ensure data integrity.

Example migration:

ALTER TABLE indictment_count
ADD CONSTRAINT chk_recorded_speed CHECK (recorded_speed ~ '^[0-9]+$'),
ADD CONSTRAINT chk_speed_limit CHECK (speed_limit ~ '^[0-9]+$');
apps/judicial-system/web/src/utils/hooks/useIndictmentCounts/index.ts (1)

131-145: Consider using a more concise implementation.

The function logic is correct but could be more concise using a ternary operator.

-    (law: number[]) => {
-      const article = law[0]
-      const paragraph = law[1]
-
-      if (paragraph === 0) {
-        return formatMessage(indictmentCount.lawsBrokenTagArticleOnly, {
-          article,
-        })
-      } else {
-        return formatMessage(indictmentCount.lawsBrokenTag, {
-          article,
-          paragraph,
-        })
-      }
-    },
+    ([article, paragraph]: number[]) =>
+      formatMessage(
+        paragraph === 0
+          ? indictmentCount.lawsBrokenTagArticleOnly
+          : indictmentCount.lawsBrokenTag,
+        paragraph === 0 ? { article } : { article, paragraph },
+      ),
apps/judicial-system/web/src/components/FormProvider/case.graphql (1)

222-223: Add GraphQL type definitions for the new fields.

The new fields recordedSpeed and speedLimit should have their types explicitly defined in the schema. Consider adding scalar type annotations (e.g., String!) to ensure type safety and proper validation.

-      recordedSpeed
-      speedLimit
+      recordedSpeed: String!
+      speedLimit: String!
apps/judicial-system/web/src/utils/validate.ts (1)

309-316: Improve maintainability of traffic violation validation.

Consider extracting the validation checks into separate functions for better maintainability and testability. This would make it easier to add new types of traffic violations in the future.

+const hasRequiredTrafficViolationFields = (indictmentCount: IndictmentCount) =>
+  Boolean(indictmentCount.policeCaseNumber) &&
+  Boolean(indictmentCount.offenses && indictmentCount.offenses?.length > 0) &&
+  Boolean(indictmentCount.vehicleRegistrationNumber) &&
+  Boolean(indictmentCount.lawsBroken) &&
+  Boolean(indictmentCount.incidentDescription) &&
+  Boolean(indictmentCount.legalArguments)

 const isValidTrafficViolation = (indictmentCount: IndictmentCount) =>
-  Boolean(indictmentCount.policeCaseNumber) &&
-  Boolean(indictmentCount.offenses && indictmentCount.offenses?.length > 0) &&
-  Boolean(indictmentCount.vehicleRegistrationNumber) &&
-  Boolean(indictmentCount.lawsBroken) &&
-  Boolean(indictmentCount.incidentDescription) &&
-  Boolean(indictmentCount.legalArguments) &&
-  isValidSpeedingIndictmentCount(indictmentCount)
+  hasRequiredTrafficViolationFields(indictmentCount) &&
+  isValidSpeedingIndictmentCount(indictmentCount)
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 328b65d and cd909aa.

📒 Files selected for processing (15)
  • apps/judicial-system/api/src/app/modules/indictment-count/dto/updateIndictmentCount.input.ts (2 hunks)
  • apps/judicial-system/api/src/app/modules/indictment-count/models/indictmentCount.model.ts (1 hunks)
  • apps/judicial-system/backend/migrations/20250120150345-update-indictment-count.js (1 hunks)
  • apps/judicial-system/backend/src/app/modules/indictment-count/dto/updateIndictmentCount.dto.ts (1 hunks)
  • apps/judicial-system/backend/src/app/modules/indictment-count/models/indictmentCount.model.ts (1 hunks)
  • apps/judicial-system/web/src/components/FormProvider/case.graphql (1 hunks)
  • apps/judicial-system/web/src/routes/Prosecutor/Indictments/Indictment/IndictmentCount.strings.ts (2 hunks)
  • apps/judicial-system/web/src/routes/Prosecutor/Indictments/Indictment/IndictmentCount.tsx (7 hunks)
  • apps/judicial-system/web/src/routes/Prosecutor/Indictments/Indictment/IndictmentCountEnum.strings.ts (1 hunks)
  • apps/judicial-system/web/src/routes/Prosecutor/Indictments/Indictment/Substance/Substance.tsx (1 hunks)
  • apps/judicial-system/web/src/utils/hooks/useIndictmentCounts/index.ts (1 hunks)
  • apps/judicial-system/web/src/utils/hooks/useIndictmentCounts/updateIndictmentCount.graphql (1 hunks)
  • apps/judicial-system/web/src/utils/validate.ts (2 hunks)
  • libs/island-ui/core/src/lib/Input/Input.mixins.ts (1 hunks)
  • libs/judicial-system/types/src/lib/indictmentCount.ts (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • apps/judicial-system/web/src/routes/Prosecutor/Indictments/Indictment/Substance/Substance.tsx
🧰 Additional context used
📓 Path-based instructions (14)
apps/judicial-system/backend/src/app/modules/indictment-count/dto/updateIndictmentCount.dto.ts (1)

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

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/judicial-system/web/src/utils/hooks/useIndictmentCounts/updateIndictmentCount.graphql (1)

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

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/judicial-system/api/src/app/modules/indictment-count/dto/updateIndictmentCount.input.ts (1)

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

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/judicial-system/api/src/app/modules/indictment-count/models/indictmentCount.model.ts (1)

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

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
libs/judicial-system/types/src/lib/indictmentCount.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."
apps/judicial-system/web/src/routes/Prosecutor/Indictments/Indictment/IndictmentCountEnum.strings.ts (1)

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

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/judicial-system/web/src/components/FormProvider/case.graphql (1)

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

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
libs/island-ui/core/src/lib/Input/Input.mixins.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."
apps/judicial-system/web/src/utils/validate.ts (1)

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

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/judicial-system/backend/migrations/20250120150345-update-indictment-count.js (1)

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

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/judicial-system/backend/src/app/modules/indictment-count/models/indictmentCount.model.ts (1)

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

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/judicial-system/web/src/utils/hooks/useIndictmentCounts/index.ts (1)

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

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/judicial-system/web/src/routes/Prosecutor/Indictments/Indictment/IndictmentCount.strings.ts (1)

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

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/judicial-system/web/src/routes/Prosecutor/Indictments/Indictment/IndictmentCount.tsx (1)

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

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
📓 Learnings (5)
apps/judicial-system/web/src/routes/Prosecutor/Indictments/Indictment/IndictmentCountEnum.strings.ts (1)
Learnt from: oddsson
PR: island-is/island.is#17192
File: apps/judicial-system/web/src/routes/Prosecutor/Indictments/Indictment/IndictmentCount.tsx:579-587
Timestamp: 2024-12-17T20:28:47.549Z
Learning: In the `IndictmentCount.tsx` file of the `apps/judicial-system/web` project, constraints on the vehicle registration number are planned to be removed. Avoid suggesting changes related to vehicle registration number validation for now.
apps/judicial-system/web/src/utils/validate.ts (1)
Learnt from: oddsson
PR: island-is/island.is#17192
File: apps/judicial-system/web/src/routes/Prosecutor/Indictments/Indictment/IndictmentCount.tsx:579-587
Timestamp: 2024-12-17T20:28:47.549Z
Learning: In the `IndictmentCount.tsx` file of the `apps/judicial-system/web` project, constraints on the vehicle registration number are planned to be removed. Avoid suggesting changes related to vehicle registration number validation for now.
apps/judicial-system/backend/migrations/20250120150345-update-indictment-count.js (1)
Learnt from: oddsson
PR: island-is/island.is#16495
File: apps/judicial-system/backend/migrations/20241022142128-update-defendant.js:1-2
Timestamp: 2024-11-12T15:15:20.157Z
Learning: In the 'judicial-system' application, it is a convention to include `'use strict'` directives at the top of migration files in `apps/judicial-system/backend/migrations/*.js`.
apps/judicial-system/web/src/routes/Prosecutor/Indictments/Indictment/IndictmentCount.strings.ts (1)
Learnt from: oddsson
PR: island-is/island.is#17192
File: apps/judicial-system/web/src/routes/Prosecutor/Indictments/Indictment/IndictmentCount.tsx:579-587
Timestamp: 2024-12-17T20:28:47.549Z
Learning: In the `IndictmentCount.tsx` file of the `apps/judicial-system/web` project, constraints on the vehicle registration number are planned to be removed. Avoid suggesting changes related to vehicle registration number validation for now.
apps/judicial-system/web/src/routes/Prosecutor/Indictments/Indictment/IndictmentCount.tsx (4)
Learnt from: oddsson
PR: island-is/island.is#17192
File: apps/judicial-system/web/src/routes/Prosecutor/Indictments/Indictment/IndictmentCount.tsx:579-587
Timestamp: 2024-12-17T20:28:47.549Z
Learning: In the `IndictmentCount.tsx` file of the `apps/judicial-system/web` project, constraints on the vehicle registration number are planned to be removed. Avoid suggesting changes related to vehicle registration number validation for now.
Learnt from: oddsson
PR: island-is/island.is#17192
File: apps/judicial-system/web/src/routes/Prosecutor/Indictments/Indictment/IndictmentCount.tsx:700-758
Timestamp: 2024-12-17T14:33:50.960Z
Learning: In the file `apps/judicial-system/web/src/routes/Prosecutor/Indictments/Indictment/IndictmentCount.tsx`, the user prefers not to add range validation for the blood alcohol content input.
Learnt from: thorhildurt
PR: island-is/island.is#17198
File: apps/judicial-system/web/src/routes/Prison/IndictmentOverview/IndictmentOverview.tsx:42-50
Timestamp: 2024-12-11T14:25:44.741Z
Learning: In `IndictmentOverview.tsx`, when updating the punishment type, update the UI state before making the API call to immediately reflect the change.
Learnt from: oddsson
PR: island-is/island.is#16731
File: apps/judicial-system/web/src/routes/Shared/IndictmentOverview/IndictmentOverview.tsx:172-186
Timestamp: 2024-11-12T15:15:20.157Z
Learning: In `IndictmentOverview.tsx`, since the defendants data does not change, using `useMemo` to memoize the filtering logic is unnecessary.
🔇 Additional comments (7)
apps/judicial-system/backend/migrations/20250120150345-update-indictment-count.js (1)

26-37: LGTM! Transaction handling is correct.

The down migration properly removes the columns within a transaction, ensuring data consistency.

apps/judicial-system/web/src/routes/Prosecutor/Indictments/Indictment/IndictmentCountEnum.strings.ts (1)

24-28: LGTM! Consistent with existing patterns.

The new SPEEDING enum follows the established pattern and naming convention used for other driving offenses.

libs/judicial-system/types/src/lib/indictmentCount.ts (1)

6-6: LGTM!

The addition of SPEEDING to the offense types and its corresponding empty substances array is well-structured and maintains type safety.

Also applies to: 102-102

apps/judicial-system/web/src/routes/Prosecutor/Indictments/Indictment/IndictmentCount.strings.ts (1)

98-115: LGTM! The message definitions are well-structured.

The new messages for speeding-related fields follow the existing naming conventions, and the descriptions are clear and helpful. The version suffix in the incidentDescriptionAutofill message ID correctly indicates a breaking change.

Also applies to: 139-143, 145-147

apps/judicial-system/web/src/routes/Prosecutor/Indictments/Indictment/IndictmentCount.tsx (1)

Line range hint 85-107: LGTM! Well-documented and properly handles edge cases.

The offenseLawsMap documentation is clear, and the legal arguments formatting correctly handles cases with no article number.

Also applies to: 279-285

apps/judicial-system/web/src/utils/hooks/useIndictmentCounts/updateIndictmentCount.graphql (1)

15-16: LGTM! The GraphQL schema is properly updated.

The new fields recordedSpeed and speedLimit are correctly added to the mutation response type.

apps/judicial-system/web/src/utils/validate.ts (1)

Line range hint 1-1: Address the TODO comment by adding tests.

The file lacks tests which is particularly concerning given the critical nature of validation logic in a judicial system. Consider adding comprehensive test cases for all validation scenarios.

Would you like me to help generate test cases for the validation functions?

@oddsson oddsson removed request for disaerna and a team January 21, 2025 14:32
@datadog-island-is
Copy link

datadog-island-is bot commented Jan 21, 2025

Datadog Report

All test runs acde9fe 🔗

8 Total Test Services: 0 Failed, 7 Passed
🔻 Test Sessions change in coverage: 2 decreased, 11 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 14.85s 1 no change Link
application-system-api 0 0 0 46 0 2m 34.53s 1 no change Link
auth-admin-web 0 0 0 1 0 56.72s 1 no change Link
judicial-system-api 0 0 0 61 0 32.14s 1 decreased (-0.03%) Link
judicial-system-backend 0 0 0 21336 0 19m 11.39s 1 no change Link
judicial-system-web 0 0 0 67 0 0s N/A Link
services-auth-delegation-api 0 0 0 270 0 2m 58.44s 1 decreased (-0.04%) Link
services-auth-personal-representative 0 0 0 0 0 295.11ms 1 no change Link

🔻 Code Coverage Decreases vs Default Branch (2)

  • services-auth-delegation-api - jest 50.41% (-0.04%) - Details
  • judicial-system-api - jest 21.2% (-0.03%) - Details

Copy link

codecov bot commented Jan 21, 2025

Codecov Report

Attention: Patch coverage is 17.24138% with 48 lines in your changes missing coverage. Please review.

Project coverage is 35.57%. Comparing base (37e5a91) to head (1dcbfad).

Files with missing lines Patch % Lines
...secutor/Indictments/Indictment/IndictmentCount.tsx 17.85% 23 Missing ⚠️
...m/web/src/utils/hooks/useIndictmentCounts/index.ts 0.00% 7 Missing ⚠️
apps/judicial-system/web/src/utils/validate.ts 0.00% 7 Missing ⚠️
...ndictment-count/dto/updateIndictmentCount.input.ts 0.00% 6 Missing ⚠️
...s/indictment-count/models/indictmentCount.model.ts 0.00% 5 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #17589      +/-   ##
==========================================
- Coverage   35.57%   35.57%   -0.01%     
==========================================
  Files        7032     7032              
  Lines      150498   150550      +52     
  Branches    42970    42984      +14     
==========================================
+ Hits        53543    53551       +8     
- Misses      96955    96999      +44     
Flag Coverage Δ
air-discount-scheme-web 0.00% <ø> (ø)
api 3.33% <ø> (ø)
api-catalogue-services 75.81% <ø> (ø)
api-domains-air-discount-scheme 37.90% <ø> (ø)
api-domains-assets 26.71% <ø> (ø)
api-domains-auth-admin 48.49% <ø> (ø)
api-domains-criminal-record 47.81% <ø> (ø)
api-domains-driving-license 44.77% <ø> (ø)
api-domains-education 31.09% <ø> (ø)
api-domains-health-insurance 35.19% <ø> (ø)
api-domains-mortgage-certificate 34.96% <ø> (ø)
api-domains-payment-schedule 42.04% <ø> (ø)
application-api-files 61.80% <ø> (ø)
application-core 75.68% <ø> (ø)
application-system-api 38.66% <ø> (-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.99% <ø> (ø)
application-templates-general-petition 23.11% <ø> (ø)
application-templates-marriage-conditions 14.80% <ø> (ø)
application-templates-mortgage-certificate 43.73% <ø> (ø)
application-templates-parental-leave 29.92% <ø> (ø)
application-types 6.47% <ø> (ø)
application-ui-components 1.17% <ø> (ø)
application-ui-shell 21.99% <ø> (ø)
clients-charge-fjs-v2 28.88% <ø> (ø)
clients-driving-license 40.68% <ø> (ø)
clients-driving-license-book 43.75% <ø> (ø)
clients-financial-statements-inao 49.48% <ø> (ø)
clients-license-client 1.26% <ø> (ø)
clients-regulations 42.75% <ø> (ø)
clients-rsk-company-registry 31.18% <ø> (ø)
clients-rsk-personal-tax-return 38.32% <ø> (ø)
clients-smartsolutions 12.77% <ø> (ø)
clients-syslumenn 49.18% <ø> (ø)
clients-zendesk 49.88% <ø> (ø)
cms 0.39% <ø> (ø)
cms-translations 38.81% <ø> (ø)
content-search-index-manager 95.65% <ø> (ø)
content-search-toolkit 8.16% <ø> (ø)
feature-flags 90.40% <ø> (ø)
file-storage 45.32% <ø> (ø)
financial-aid-backend 51.38% <ø> (ø)
financial-aid-shared 17.88% <ø> (ø)
icelandic-names-registry-backend 54.44% <ø> (ø)
infra-nest-server 48.06% <ø> (ø)
infra-tracing 69.94% <ø> (ø)
island-ui-core 30.32% <ø> (ø)
judicial-system-api 20.05% <8.33%> (-0.03%) ⬇️
judicial-system-backend 55.82% <100.00%> (+0.01%) ⬆️
judicial-system-formatters 78.88% <100.00%> (+0.02%) ⬆️
judicial-system-message 66.29% <ø> (ø)
judicial-system-message-handler 47.89% <ø> (ø)
judicial-system-scheduler 71.26% <100.00%> (+0.02%) ⬆️
judicial-system-web 27.92% <11.90%> (-0.05%) ⬇️
license-api 42.88% <ø> (+0.07%) ⬆️
localization 10.15% <ø> (ø)
logging 58.02% <ø> (ø)
nest-audit 65.78% <ø> (ø)
nest-aws 51.93% <ø> (ø)
nest-core 53.16% <ø> (ø)
nest-feature-flags 50.69% <ø> (ø)
nest-swagger 51.29% <ø> (ø)
regulations 16.78% <ø> (ø)
residence-history 85.00% <ø> (ø)
services-auth-delegation-api 58.49% <ø> (+0.08%) ⬆️
services-auth-public-api 49.37% <ø> (-0.01%) ⬇️
services-sessions 65.35% <ø> (ø)
services-university-gateway 49.39% <ø> (ø)
shared-form-fields 33.36% <ø> (ø)
shared-mocking 58.64% <ø> (ø)
shared-pii 92.85% <ø> (ø)
shared-utils 28.67% <ø> (ø)
web 2.39% <ø> (ø)

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

Files with missing lines Coverage Δ
.../indictment-count/dto/updateIndictmentCount.dto.ts 100.00% <100.00%> (ø)
...s/indictment-count/models/indictmentCount.model.ts 95.00% <100.00%> (+0.55%) ⬆️
.../Indictments/Indictment/IndictmentCount.strings.ts 100.00% <ø> (ø)
...ictments/Indictment/IndictmentCountEnum.strings.ts 100.00% <ø> (ø)
...tor/Indictments/Indictment/Substance/Substance.tsx 6.25% <ø> (ø)
...s/judicial-system/types/src/lib/indictmentCount.ts 100.00% <100.00%> (ø)
...s/indictment-count/models/indictmentCount.model.ts 0.00% <0.00%> (ø)
...ndictment-count/dto/updateIndictmentCount.input.ts 0.00% <0.00%> (ø)
...m/web/src/utils/hooks/useIndictmentCounts/index.ts 2.17% <0.00%> (-0.33%) ⬇️
apps/judicial-system/web/src/utils/validate.ts 35.74% <0.00%> (-0.80%) ⬇️
... and 1 more

... 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 37e5a91...1dcbfad. Read the comment docs.

@oddsson oddsson requested review from a team and sigruntg and removed request for a team January 21, 2025 15:28
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

🧹 Nitpick comments (2)
apps/judicial-system/web/src/routes/Prosecutor/Indictments/Indictment/IndictmentCount.tsx (2)

348-362: Extract placeholder strings into constants.

Consider extracting the placeholder strings into named constants for better maintainability and reusability.

+const SPEED_PLACEHOLDERS = {
+  RECORDED_SPEED: '[Mældur hraði]',
+  SPEED_LIMIT: '[Leyfilegur hraði]',
+} as const

-    const recordedSpeed = indictmentCount.recordedSpeed ?? '[Mældur hraði]'
-    const speedLimit = indictmentCount.speedLimit ?? '[Leyfilegur hraði]'
+    const recordedSpeed = indictmentCount.recordedSpeed ?? SPEED_PLACEHOLDERS.RECORDED_SPEED
+    const speedLimit = indictmentCount.speedLimit ?? SPEED_PLACEHOLDERS.SPEED_LIMIT

713-716: Extract speed-related cleanup into a function.

Consider extracting the speed-related cleanup logic into a separate function for better readability and reusability.

+const clearSpeedingData = (offense: IndictmentCountOffense) => {
+  return offense === IndictmentCountOffense.SPEEDING
+    ? { recordedSpeed: null, speedLimit: null }
+    : {}
+}

-...(offense === IndictmentCountOffense.SPEEDING && {
-  recordedSpeed: null,
-  speedLimit: null,
-}),
+...clearSpeedingData(offense),
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between cd909aa and f038a57.

📒 Files selected for processing (2)
  • apps/judicial-system/web/src/routes/Prosecutor/Indictments/Indictment/IndictmentCount.tsx (7 hunks)
  • libs/island-ui/core/src/lib/Input/Input.css.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
libs/island-ui/core/src/lib/Input/Input.css.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."
apps/judicial-system/web/src/routes/Prosecutor/Indictments/Indictment/IndictmentCount.tsx (1)

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

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
📓 Learnings (1)
apps/judicial-system/web/src/routes/Prosecutor/Indictments/Indictment/IndictmentCount.tsx (6)
Learnt from: oddsson
PR: island-is/island.is#17589
File: apps/judicial-system/web/src/routes/Prosecutor/Indictments/Indictment/IndictmentCount.tsx:0-0
Timestamp: 2025-01-21T15:32:24.472Z
Learning: In the judicial-system web app, speed-related values (recordedSpeed, speedLimit) should be stored and handled as strings rather than numbers to maintain consistency with other similar fields and the backend data model.
Learnt from: oddsson
PR: island-is/island.is#17192
File: apps/judicial-system/web/src/routes/Prosecutor/Indictments/Indictment/IndictmentCount.tsx:579-587
Timestamp: 2024-12-17T20:28:47.549Z
Learning: In the `IndictmentCount.tsx` file of the `apps/judicial-system/web` project, constraints on the vehicle registration number are planned to be removed. Avoid suggesting changes related to vehicle registration number validation for now.
Learnt from: oddsson
PR: island-is/island.is#17192
File: apps/judicial-system/web/src/routes/Prosecutor/Indictments/Indictment/IndictmentCount.tsx:700-758
Timestamp: 2024-12-17T14:33:50.960Z
Learning: In the file `apps/judicial-system/web/src/routes/Prosecutor/Indictments/Indictment/IndictmentCount.tsx`, the user prefers not to add range validation for the blood alcohol content input.
Learnt from: oddsson
PR: island-is/island.is#17589
File: apps/judicial-system/api/src/app/modules/indictment-count/models/indictmentCount.model.ts:51-56
Timestamp: 2025-01-21T15:32:09.727Z
Learning: In the judicial-system application, speed-related values (recordedSpeed and speedLimit) in IndictmentCount models should be stored as strings rather than numbers.
Learnt from: oddsson
PR: island-is/island.is#17589
File: apps/judicial-system/backend/src/app/modules/indictment-count/dto/updateIndictmentCount.dto.ts:62-71
Timestamp: 2025-01-21T15:32:15.618Z
Learning: In the judicial-system application, speed-related values (recordedSpeed, speedLimit) should be stored as strings rather than numbers.
Learnt from: oddsson
PR: island-is/island.is#16731
File: apps/judicial-system/web/src/routes/Shared/IndictmentOverview/IndictmentOverview.tsx:172-186
Timestamp: 2024-11-12T15:15:20.157Z
Learning: In `IndictmentOverview.tsx`, since the defendants data does not change, using `useMemo` to memoize the filtering logic is unnecessary.
🔇 Additional comments (3)
apps/judicial-system/web/src/routes/Prosecutor/Indictments/Indictment/IndictmentCount.tsx (3)

Line range hint 85-107: LGTM! Well-documented law mapping.

The addition of the speeding offense to offenseLawsMap is clear and follows the established pattern.


404-407: LGTM! Consistent error state management.

The error message states for speed inputs follow the established pattern.


799-899: ⚠️ Potential issue

Add validation for speed values.

The speed inputs need validation to ensure:

  1. The recorded speed is greater than the speed limit
  2. Both values are reasonable (e.g., within typical road speed ranges)

Add validation in the onBlur handler:

onBlur={(event) => {
  const recordedSpeed = event.target.value
+ const speedLimit = indictmentCount.speedLimit
+ const recordedSpeedNum = parseInt(recordedSpeed, 10)
+ const speedLimitNum = speedLimit ? parseInt(speedLimit, 10) : 0

  validateAndSetErrorMessage(
-   ['empty'],
+   ['empty', 'numeric'],
    recordedSpeed,
    setRecordedSpeedErrorMessage,
+   {
+     customMessage:
+       recordedSpeedNum <= speedLimitNum
+         ? 'Recorded speed must be greater than speed limit'
+         : recordedSpeedNum > 250
+         ? 'Recorded speed seems unreasonably high'
+         : undefined,
+   }
  )

  handleIndictmentCountChanges({
    recordedSpeed,
  })
}}

Likely invalid or redundant comment.

libs/island-ui/core/src/lib/Input/Input.css.ts Outdated Show resolved Hide resolved
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 comments (3)
apps/auth-admin-web/components/Client/nav/ClientTabNav.tsx (1)

Line range hint 53-66: Use localization for help text.

The help text is hardcoded in English. For consistency with the rest of the component that uses localization, these strings should be moved to the localization system.

      <div className="client-tab-nav__container__help">
-        Use either the simplified form or the detailed form to create a new
-        client
+        {localization.navigations['clientTabNav'].items['helpText'].text}
        <div className="client-tab-nav__container__help__selected">
-          {activetab === ClientTab.BasicForm
-            ? 'You are using the simplified form'
-            : 'You are using the detailed form'}
+          {activetab === ClientTab.BasicForm
+            ? localization.navigations['clientTabNav'].items['basicFormSelected'].text
+            : localization.navigations['clientTabNav'].items['detailedFormSelected'].text}
        </div>
      </div>
apps/skilavottord/ws/src/app/modules/samgongustofa/samgongustofa.service.ts (2)

Line range hint 76-102: Add type safety and improve error handling for SOAP response parsing.

The current implementation has several areas for improvement:

  1. Define TypeScript interfaces for SOAP response structure to prevent runtime errors.
  2. Add null checks for nested property access.
  3. Use template literals for error messages.

Example implementation:

+ interface SoapEnvelope {
+   'soapenv:Envelope': {
+     'soapenv:Body': [{
+       'soapenv:Fault'?: [{
+         'faultstring': string[];
+       }];
+       'ns1:allVehiclesForPersidnoResponse'?: [{
+         'allVehiclesForPersidnoReturn': [{
+           '_': string;
+         }];
+       }];
+     }];
+   };
+ }

- .then((allCarsResult) => {
+ .then((allCarsResult: SoapEnvelope) => {
   // ... rest of the code
-  logger.error(
-    allCarsResult['soapenv:Envelope']['soapenv:Body'][0]['soapenv:Fault'][0]['faultstring'][0],
-  )
+  const faultString = allCarsResult?.['soapenv:Envelope']?.['soapenv:Body']?.[0]?.['soapenv:Fault']?.[0]?.['faultstring']?.[0];
+  logger.error(`SOAP fault: ${faultString}`);

Line range hint 147-156: Improve error handling strategy.

The current error handling implementation has several issues:

  1. Duplicate error handling logic across catch blocks.
  2. Generic error messages that could be more specific.
  3. No custom error types for different failure scenarios.
+ class XmlParsingError extends Error {
+   constructor(stage: string, originalError: Error) {
+     super(`XML parsing failed during ${stage}: ${originalError.message}`);
+     this.name = 'XmlParsingError';
+   }
+ }

+ private handleXmlParsingError(stage: string, error: Error): never {
+   logger.error(`Failed while parsing XML to JSON during ${stage}`, {
+     error: error.message,
+     stage,
+   });
+   throw new XmlParsingError(stage, error);
+ }

- .catch((err) => {
-   logger.error(
-     `Failed while parsing xml to json on getUserVehiclesInformation request with error: ${err}`,
-   );
-   throw new Error(
-     `Failed while parsing xml to json on getUserVehiclesInformation request with error: ${err}`,
-   );
- })
+ .catch((err) => this.handleXmlParsingError('getUserVehiclesInformation', err))

Also applies to: 269-278

🧹 Nitpick comments (6)
libs/api/domains/disability-license/src/lib/disability-license.resolver.ts (1)

22-22: Great improvement using the primitive boolean type!

The change from Promise<Boolean> to Promise<boolean> aligns with TypeScript best practices. Using the primitive boolean type instead of the boxed Boolean type provides better type safety and can lead to improved performance.

Consider updating the GraphQL return type decorator to match:

-  @Query(() => Boolean)
+  @Query(() => Boolean, { description: 'Check if user has a disability license' })

This adds helpful documentation for GraphQL clients.

libs/api/domains/directorate-of-labour/src/lib/parentalLeavePregnancyStatus.model.ts (1)

9-9: LGTM! Good improvement in type safety.

The change from String to string is correct as it follows TypeScript best practices by using primitive types instead of object constructors.

Consider adding JSDoc comments to document the class and its properties for better maintainability:

 @ObjectType()
+/**
+ * Represents the pregnancy status for parental leave applications.
+ */
 export class ParentalLeavePregnancyStatus {
   @Field(() => Boolean)
+  /** Indicates if there is an active pregnancy case. */
   hasActivePregnancy!: boolean

   @Field(() => String)
+  /** The expected date when the child will be born. */
   expectedDateOfBirth!: string
 }
apps/financial-aid/backend/src/app/modules/staff/test/numberOfUsersForMunicipality.spec.ts (1)

Line range hint 1-89: Consider adding boundary value test cases.

While the current test coverage is good, consider adding test cases for:

  • Edge cases (e.g., zero users)
  • Invalid municipality IDs
  • Large number of users

Example test case structure:

describe('edge cases', () => {
  it('should handle zero users', async () => {
    const municipalityId = uuid()
    const mockNumberOfUsers = mockStaffModel.count as jest.Mock
    mockNumberOfUsers.mockResolvedValueOnce(0)

    const then = await givenWhenThen(municipalityId)
    expect(then.result).toBe(0)
  })
})
apps/auth-admin-web/components/Client/nav/ClientTabNav.tsx (1)

12-14: Maintain consistent casing in prop names.

The renaming of activeTab to activetab breaks the camelCase naming convention used throughout the codebase. Consider keeping the original casing.

- activeTab: activetab,
+ activeTab,
apps/skilavottord/ws/src/app/modules/samgongustofa/samgongustofa.service.ts (2)

Line range hint 102-147: Refactor vehicle processing logic for better maintainability.

The vehicle processing logic is complex and could benefit from:

  1. Extracting vehicle status and recyclability checks into separate methods.
  2. Using appropriate log levels (debug vs info).
  3. Using immutable array operations.

Example implementation:

+ private isVehicleDeregistered(status: string): boolean {
+   return status === 'Afskráð';
+ }

+ private determineVehicleRecyclability(vehicle: any): { isRecyclable: boolean; status: string } {
+   const isDeregistered = this.isVehicleDeregistered(vehicle.vehiclestatus[0]);
+   const hasCoOwner = vehicle.otherowners[0] !== '0';
+   
+   return {
+     isRecyclable: !isDeregistered && !hasCoOwner,
+     status: isDeregistered ? 'deregistered' : 'inUse'
+   };
+ }

- allCars['persidnolookup']['vehicleList'][0]['vehicle'].forEach((car) => {
+ const vehicleArr = allCars?.['persidnolookup']?.['vehicleList']?.[0]?.['vehicle']?.map((car) => {
+   const { isRecyclable, status } = this.determineVehicleRecyclability(car);
+   
+   logger.debug(`Vehicle ${car.permno[0]} status: ${status}, recyclable: ${isRecyclable}`);
+   
+   return new VehicleInformation(
+     car.permno[0],
+     car.type[0],
+     car.color[0],
+     car.vin[0],
+     car.firstregdate[0],
+     isRecyclable,
+     !car.otherowners[0],
+     status
+   );
+ }) ?? [];

Line range hint 206-227: Simplify vehicle information update logic.

The current implementation has complex nested conditions and type checks that could be simplified:

  1. Use TypeScript types for vehicle information structure.
  2. Extract update logic into separate methods.
  3. Use early returns to reduce nesting.
+ interface VehicleBasicInfo {
+   vehicle: {
+     ownerregistrationerrors: [{ ownerregistrationerror?: any[] }];
+     stolens: [{ stolen?: { enddate: [string] }[] }];
+     updatelocks: [{ updatelock?: { enddate: [string] }[] }];
+   };
+ }

+ private hasActiveRegistrationErrors(info: VehicleBasicInfo): boolean {
+   return typeof info.vehicle.ownerregistrationerrors[0].ownerregistrationerror !== 'undefined';
+ }

+ private hasActiveStolenStatus(info: VehicleBasicInfo): boolean {
+   return info.vehicle.stolens[0].stolen?.some(stolen => !stolen.enddate[0].trim()) ?? false;
+ }

+ private hasActiveUpdateLocks(info: VehicleBasicInfo): boolean {
+   return info.vehicle.updatelocks[0].updatelock?.some(lock => !lock.enddate[0].trim()) ?? false;
+ }

- .then((basicInfo) => {
+ .then((basicInfo: VehicleBasicInfo) => {
+   if (hasActiveRegistrationErrors(basicInfo)) {
+     logger.debug('Vehicle not recyclable: has registration errors');
+     newVehicleArr[i].isRecyclable = false;
+     return newVehicleArr[i];
+   }
+   
+   if (hasActiveStolenStatus(basicInfo)) {
+     logger.debug('Vehicle not recyclable: marked as stolen');
+     newVehicleArr[i].isRecyclable = false;
+     return newVehicleArr[i];
+   }
+   
+   if (hasActiveUpdateLocks(basicInfo)) {
+     logger.debug('Vehicle not recyclable: has active update locks');
+     newVehicleArr[i].isRecyclable = false;
+     return newVehicleArr[i];
+   }
+   
+   return newVehicleArr[i];
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between f3f78fe and fe17d02.

📒 Files selected for processing (32)
  • apps/auth-admin-web/components/Admin/nav/AdminTabNav.tsx (1 hunks)
  • apps/auth-admin-web/components/Client/nav/ClientTabNav.tsx (1 hunks)
  • apps/contentful-apps/components/Layout.tsx (1 hunks)
  • apps/contentful-apps/components/LocalhostWarning.tsx (1 hunks)
  • apps/contentful-apps/components/MideindTranslationSidebar/fieldUtils/index.tsx (1 hunks)
  • apps/contentful-apps/pages/fields/active-translations-field.tsx (1 hunks)
  • apps/contentful-apps/pages/fields/admin-only-json-field.tsx (1 hunks)
  • apps/contentful-apps/pages/fields/admin-only-short-text-checkbox-list-field.tsx (1 hunks)
  • apps/contentful-apps/pages/fields/admin-only-short-text-dropdown-field.tsx (1 hunks)
  • apps/contentful-apps/pages/fields/admin-only-short-text-field.tsx (1 hunks)
  • apps/contentful-apps/pages/fields/admin-only-single-reference-field.tsx (1 hunks)
  • apps/contentful-apps/pages/fields/article-related-articles-field.tsx (2 hunks)
  • apps/contentful-apps/pages/fields/article-subarticles-field.tsx (1 hunks)
  • apps/contentful-apps/pages/fields/content-type-notifications-field.tsx (1 hunks)
  • apps/contentful-apps/pages/fields/embed-link-field.tsx (1 hunks)
  • apps/contentful-apps/pages/fields/form-default-namespace-field.tsx (1 hunks)
  • apps/contentful-apps/pages/fields/formatted-location-input-field.tsx (1 hunks)
  • apps/contentful-apps/pages/fields/publish-date-field.tsx (1 hunks)
  • apps/contentful-apps/pages/fields/theme-properties-field.tsx (1 hunks)
  • apps/contentful-apps/pages/fields/time-duration-field.tsx (1 hunks)
  • apps/contentful-apps/pages/fields/vacancy-contacts-field.tsx (1 hunks)
  • apps/financial-aid/backend/src/app/modules/staff/test/numberOfUsersForMunicipality.spec.ts (1 hunks)
  • apps/skilavottord/web/screens/Overview/components/ActionCard/ActionCard.tsx (1 hunks)
  • apps/skilavottord/ws/src/app/modules/samgongustofa/samgongustofa.service.ts (8 hunks)
  • apps/tools/contentful-role-permissions/utils/index.ts (1 hunks)
  • apps/web/screens/PetitionView/PetitionView.tsx (1 hunks)
  • libs/api/domains/auth-admin/src/lib/client/clients.service.spec.ts (8 hunks)
  • libs/api/domains/directorate-of-labour/src/lib/parentalLeavePregnancyStatus.model.ts (1 hunks)
  • libs/api/domains/disability-license/src/lib/disability-license.resolver.ts (1 hunks)
  • libs/api/domains/driving-license/src/lib/graphql/qualityPhoto.resolver.ts (1 hunks)
  • libs/api/domains/driving-license/src/lib/graphql/qualitySignature.resolver.ts (1 hunks)
  • libs/application/templates/financial-aid/src/fields/TaxReturnFilesForm/taxFormContent.tsx (1 hunks)
✅ Files skipped from review due to trivial changes (24)
  • apps/contentful-apps/pages/fields/admin-only-short-text-field.tsx
  • apps/contentful-apps/components/Layout.tsx
  • apps/contentful-apps/pages/fields/active-translations-field.tsx
  • apps/contentful-apps/pages/fields/time-duration-field.tsx
  • apps/contentful-apps/pages/fields/admin-only-json-field.tsx
  • apps/contentful-apps/pages/fields/admin-only-short-text-dropdown-field.tsx
  • apps/contentful-apps/pages/fields/content-type-notifications-field.tsx
  • apps/contentful-apps/pages/fields/publish-date-field.tsx
  • apps/contentful-apps/components/MideindTranslationSidebar/fieldUtils/index.tsx
  • apps/contentful-apps/pages/fields/admin-only-short-text-checkbox-list-field.tsx
  • apps/contentful-apps/pages/fields/theme-properties-field.tsx
  • apps/tools/contentful-role-permissions/utils/index.ts
  • apps/contentful-apps/components/LocalhostWarning.tsx
  • apps/auth-admin-web/components/Admin/nav/AdminTabNav.tsx
  • apps/contentful-apps/pages/fields/admin-only-single-reference-field.tsx
  • apps/contentful-apps/pages/fields/embed-link-field.tsx
  • libs/api/domains/auth-admin/src/lib/client/clients.service.spec.ts
  • apps/contentful-apps/pages/fields/formatted-location-input-field.tsx
  • libs/application/templates/financial-aid/src/fields/TaxReturnFilesForm/taxFormContent.tsx
  • apps/web/screens/PetitionView/PetitionView.tsx
  • apps/contentful-apps/pages/fields/article-related-articles-field.tsx
  • apps/contentful-apps/pages/fields/article-subarticles-field.tsx
  • apps/contentful-apps/pages/fields/form-default-namespace-field.tsx
  • apps/contentful-apps/pages/fields/vacancy-contacts-field.tsx
🧰 Additional context used
📓 Path-based instructions (8)
apps/auth-admin-web/components/Client/nav/ClientTabNav.tsx (1)

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

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
libs/api/domains/disability-license/src/lib/disability-license.resolver.ts (1)

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

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
libs/api/domains/directorate-of-labour/src/lib/parentalLeavePregnancyStatus.model.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."
apps/financial-aid/backend/src/app/modules/staff/test/numberOfUsersForMunicipality.spec.ts (1)

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

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
libs/api/domains/driving-license/src/lib/graphql/qualityPhoto.resolver.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."
apps/skilavottord/web/screens/Overview/components/ActionCard/ActionCard.tsx (1)

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

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/skilavottord/ws/src/app/modules/samgongustofa/samgongustofa.service.ts (1)

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

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
libs/api/domains/driving-license/src/lib/graphql/qualitySignature.resolver.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."
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: prepare
🔇 Additional comments (4)
apps/financial-aid/backend/src/app/modules/staff/test/numberOfUsersForMunicipality.spec.ts (1)

9-9: Good change! Using primitive number type instead of Number.

This change aligns with TypeScript best practices by using the primitive number type instead of the Number object wrapper type, which improves type safety and performance.

libs/api/domains/driving-license/src/lib/graphql/qualityPhoto.resolver.ts (1)

25-25: Good use of TypeScript primitive type!

The change from Promise<String> to Promise<string> follows TypeScript best practices by using the primitive type instead of the wrapper object type. This improves type safety and performance.

Let's check if there are other instances of Promise<String> that should be updated for consistency:

✅ Verification successful

Verified: Codebase consistently uses primitive type string

The change from Promise<String> to Promise<string> aligns with the existing codebase conventions. A thorough search confirms that all Promise return types consistently use the TypeScript primitive type string rather than the object type String.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for Promise<String> type annotations that might need similar updates
rg "Promise<String>" --type ts

Length of output: 32


Script:

#!/bin/bash
# Search with multiple patterns and case variations
echo "=== Searching for Promise<String> variations ==="
rg -i "promise\s*<\s*string" --type ts

echo -e "\n=== Checking return type declarations ==="
ast-grep --pattern 'Promise<String>' --lang ts
ast-grep --pattern 'Promise < String >' --lang ts

Length of output: 24022

libs/api/domains/driving-license/src/lib/graphql/qualitySignature.resolver.ts (1)

25-25: Consistent type usage across resolvers!

The change from Promise<String> to Promise<string> maintains consistency with the similar change in QualityPhotoResolver, following TypeScript best practices.

apps/skilavottord/ws/src/app/modules/samgongustofa/samgongustofa.service.ts (1)

Line range hint 1-24: Consider modernizing the deprecated service.

This service is marked as deprecated but contains critical business logic for vehicle recycling. Consider:

  1. Creating a migration plan to a modern REST-based service.
  2. Implementing caching for frequently accessed vehicle information.
  3. Using XML parsing libraries optimized for large SOAP responses.
  4. Adding comprehensive API documentation for the replacement service.

@datadog-island-is
Copy link

datadog-island-is bot commented Jan 23, 2025

Datadog Report

All test runs 3f20eb2 🔗

10 Total Test Services: 1 Failed, 9 Passed
🔻 Test Sessions change in coverage: 6 decreased, 5 increased, 189 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-user-notification 11 0 0 40 0 1m 27.4s 1 decreased (-0.56%) Link
air-discount-scheme-web 0 0 0 2 0 9.82s N/A Link
api 0 0 0 4 0 3.71s N/A Link
api-catalogue-services 0 0 0 23 0 19.81s 1 no change Link
api-domains-air-discount-scheme 0 0 0 6 0 17.81s N/A Link
api-domains-assets 0 0 0 3 0 13.72s N/A Link
api-domains-auth-admin 0 0 0 18 0 17.63s 1 no change Link
api-domains-communications 0 0 0 5 0 45.7s 1 no change Link
api-domains-criminal-record 0 0 0 5 0 12.22s 1 no change Link
api-domains-driving-license 0 0 0 23 0 32.08s N/A Link

❌ Failed Tests (11)

This report shows up to 5 failed tests.

  • NotificationsWorkerService should call company registry for companies - apps/services/user-notification/src/app/modules/notifications/notificationsWorker/notificationsWorker.service.spec.ts - Details

    Expand for error
     expect(jest.fn()).toHaveBeenCalledTimes(expected)
     
     Expected number of calls: 1
     Received number of calls: 0
    
  • NotificationsWorkerService should call national registry for persons - apps/services/user-notification/src/app/modules/notifications/notificationsWorker/notificationsWorker.service.spec.ts - Details

    Expand for error
     expect(jest.fn()).toHaveBeenCalledTimes(expected)
     
     Expected number of calls: 1
     Received number of calls: 0
    
  • NotificationsWorkerService should not send email if feature flag is turned off - apps/services/user-notification/src/app/modules/notifications/notificationsWorker/notificationsWorker.service.spec.ts - Details

    Expand for error
     expect(jest.fn()).toHaveBeenCalledTimes(expected)
     
     Expected number of calls: 1
     Received number of calls: 0
    
  • NotificationsWorkerService should not send email if user has email notifications disabled - apps/services/user-notification/src/app/modules/notifications/notificationsWorker/notificationsWorker.service.spec.ts - Details

    Expand for error
     expect(jest.fn()).toHaveBeenCalledTimes(expected)
     
     Expected number of calls: 1
     Received number of calls: 0
    
  • NotificationsWorkerService should not send email if user has no email registered - apps/services/user-notification/src/app/modules/notifications/notificationsWorker/notificationsWorker.service.spec.ts - Details

    Expand for error
     expect(jest.fn()).toHaveBeenCalledTimes(expected)
     
     Expected number of calls: 1
     Received number of calls: 0
    

🔻 Code Coverage Decreases vs Default Branch (6)

This report shows up to 5 code coverage decreases.

  • message-queue - jest 67.46% (-0.8%) - Details
  • services-user-notification - jest 68.26% (-0.56%) - Details
  • judicial-system-types - jest 39.9% (-0.06%) - Details
  • judicial-system-web - jest 32.43% (-0.04%) - Details
  • judicial-system-api - jest 21.2% (-0.03%) - Details

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/infra-express-server/src/lib/infra-express-server.ts (1)

Line range hint 33-41: Add type declaration for res.locals.startEpoch.

For better type safety, consider declaring the custom property in res.locals:

// Add this at the top of the file
declare global {
  namespace Express {
    interface Locals {
      startEpoch: number;
    }
  }
}
libs/island-ui/core/src/lib/DatePicker/DatePicker.stories.tsx (6)

46-54: Improve type safety and testability of the WithSelectedDate story.

Consider these improvements:

  1. Extract the date initialization to make testing deterministic
  2. Add proper type annotations for better type safety
+const defaultDate = new Date('2024-01-01T00:00:00.000Z')
+
 export const WithSelectedDate = () => (
   <Wrap>
     <DatePicker
       label="Date"
       placeholderText="Pick a date"
-      selected={new Date()}
+      selected={defaultDate}
       handleChange={(date: Date) => console.log(date)}
     />
   </Wrap>
 )

56-67: Simplify the LocaleIS story and improve type safety.

The story can be simplified and made more type-safe:

-export const LocaleIS = () => {
-  return (
+export const LocaleIS = () => (
     <Wrap>
       <DatePicker
         label="Dagsetning"
         placeholderText="Veldu dagsetningu"
         locale="is"
-        handleChange={(date: Date) => console.log(date)}
+        handleChange={(date: Date): void => console.log(date)}
       />
     </Wrap>
-  )
-}
+)

72-85: Fix typo and improve type safety in the SelectYear story.

The story has the following issues:

  1. There's a typo in the text message: "then" should be "than"
  2. Missing type annotations
  3. Date initialization should be extracted for better testability
+const currentDate = new Date('2024-01-01T00:00:00.000Z')
+
 export const SelectYear = () => {
-  const toDay = new Date()
+  const toDay = currentDate
   return (
     <Wrap>
       <DatePicker
         label="Date"
         placeholderText="Pick a year"
         minYear={toDay.getFullYear() - 10}
         maxYear={toDay.getFullYear() + 2}
-        handleChange={(date: Date) => console.log(date)}
+        handleChange={(date: Date): void => console.log(date)}
       />
       <Text variant="small" marginTop={3}>
         Selecting a year will only work if <code>minYear</code> and{' '}
         <code>maxYear</code> are set and <code>maxYear</code> is higher{' '}
-        <code>then</code>{' '}
+        <code>than</code>{' '}
         <code>minYear</code>
       </Text>
     </Wrap>
   )
 }

142-152: Improve testability and type safety of the WithErrors story.

Consider extracting the date initialization and adding proper type annotations:

+const errorDate = new Date('2024-01-01T00:00:00.000Z')
+
 export const WithErrors = () => (
   <Wrap>
     <DatePicker
       id="TestError"
       label="Date"
       placeholderText="Pick a date"
-      selected={new Date()}
+      selected={errorDate}
       hasError
       errorMessage="This date is somewhat incorrect"
-      handleChange={(date: Date) => console.log(date)}
+      handleChange={(date: Date): void => console.log(date)}
     />
   </Wrap>
 )

156-164: Improve testability and type safety of the Disabled story.

Consider extracting the date initialization and adding proper type annotations:

+const disabledDate = new Date('2024-01-01T00:00:00.000Z')
+
 export const Disabled = () => (
   <Wrap>
     <DatePicker
       label="Date"
       placeholderText="Pick a date"
-      selected={new Date()}
+      selected={disabledDate}
-      handleChange={(date: Date) => console.log(date)}
+      handleChange={(date: Date): void => console.log(date)}
       disabled
     />
   </Wrap>
 )

Line range hint 1-164: Improve overall component reusability and maintainability.

The DatePicker stories demonstrate good practices for component documentation and reusability. However, consider these improvements:

  1. Extract common date initialization logic into a shared utility
  2. Add proper TypeScript return type annotations for all stories
  3. Consider adding more complex use cases demonstrating integration with forms

Example utility for date initialization:

// utils/testDates.ts
export const getTestDate = (dateString: string = '2024-01-01T00:00:00.000Z'): Date => 
  new Date(dateString)
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between fe17d02 and 7858f5f.

📒 Files selected for processing (10)
  • apps/contentful-apps/components/LocalhostWarning.tsx (1 hunks)
  • apps/contentful-apps/pages/fields/article-related-articles-field.tsx (2 hunks)
  • apps/contentful-apps/pages/fields/embed-link-field.tsx (1 hunks)
  • apps/contentful-apps/pages/fields/time-duration-field.tsx (1 hunks)
  • apps/contentful-apps/pages/fields/vacancy-contacts-field.tsx (1 hunks)
  • apps/skilavottord/web/screens/Overview/components/ActionCard/ActionCard.tsx (1 hunks)
  • libs/application/templates/financial-aid/src/fields/TaxReturnFilesForm/taxFormContent.tsx (1 hunks)
  • libs/infra-express-server/src/lib/infra-express-server.ts (3 hunks)
  • libs/island-ui/core/src/lib/DatePicker/DatePicker.stories.tsx (2 hunks)
  • libs/portals/shared-modules/delegations/src/hooks/useDynamicShadow.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (7)
  • apps/contentful-apps/pages/fields/vacancy-contacts-field.tsx
  • apps/contentful-apps/pages/fields/time-duration-field.tsx
  • apps/contentful-apps/components/LocalhostWarning.tsx
  • libs/application/templates/financial-aid/src/fields/TaxReturnFilesForm/taxFormContent.tsx
  • apps/contentful-apps/pages/fields/embed-link-field.tsx
  • apps/skilavottord/web/screens/Overview/components/ActionCard/ActionCard.tsx
  • apps/contentful-apps/pages/fields/article-related-articles-field.tsx
🧰 Additional context used
📓 Path-based instructions (3)
libs/portals/shared-modules/delegations/src/hooks/useDynamicShadow.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/infra-express-server/src/lib/infra-express-server.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/island-ui/core/src/lib/DatePicker/DatePicker.stories.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 (2)
libs/portals/shared-modules/delegations/src/hooks/useDynamicShadow.tsx (1)

Line range hint 40-52: LGTM! Well-structured and reusable hook implementation.

The conversion to arrow function syntax maintains consistency while preserving the functionality. The hook demonstrates good practices:

  • Strong TypeScript typing with proper interfaces
  • Clean exports for effective tree-shaking
  • Reusable design that can be shared across NextJS apps
libs/infra-express-server/src/lib/infra-express-server.ts (1)

44-46: LGTM! Clean and reusable health check implementation.

The liveness endpoint follows RESTful practices and provides a clear health check interface.

libs/infra-express-server/src/lib/infra-express-server.ts Outdated Show resolved Hide resolved
libs/infra-express-server/src/lib/infra-express-server.ts Outdated Show resolved Hide resolved
@oddsson oddsson removed request for a team January 24, 2025 06:46
Copy link
Member

@thorhildurt thorhildurt left a comment

Choose a reason for hiding this comment

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

Nice! Looks good 🚀 Just left one small comment and then when testing I noticed that we don't highlight the new fields in the same way as other required fields. See screenshot when "ölvunarakstur" is selected with speeding. Wrote something in the speeding limit filed and then removed it, and would expect it to be highlighted in the same way as "Vínandamagn".
Screenshot 2025-01-27 at 11 18 44

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 (1)
apps/judicial-system/web/src/routes/Prosecutor/Indictments/Indictment/IndictmentCount.tsx (1)

348-362: Consider internationalizing the fallback values.

The fallback values for recordedSpeed and speedLimit are hardcoded in Icelandic. Consider moving these to the string resources for better internationalization support.

-    const recordedSpeed = indictmentCount.recordedSpeed ?? '[Mældur hraði]'
-    const speedLimit = indictmentCount.speedLimit ?? '[Leyfilegur hraði]'
+    const recordedSpeed = indictmentCount.recordedSpeed ?? formatMessage(strings.recordedSpeedPlaceholder)
+    const speedLimit = indictmentCount.speedLimit ?? formatMessage(strings.speedLimitPlaceholder)
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 2e6d545 and 7f420b7.

📒 Files selected for processing (1)
  • apps/judicial-system/web/src/routes/Prosecutor/Indictments/Indictment/IndictmentCount.tsx (7 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
apps/judicial-system/web/src/routes/Prosecutor/Indictments/Indictment/IndictmentCount.tsx (1)

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

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
📓 Learnings (1)
apps/judicial-system/web/src/routes/Prosecutor/Indictments/Indictment/IndictmentCount.tsx (6)
Learnt from: oddsson
PR: island-is/island.is#17589
File: apps/judicial-system/web/src/routes/Prosecutor/Indictments/Indictment/IndictmentCount.tsx:0-0
Timestamp: 2025-01-21T15:32:24.472Z
Learning: In the judicial-system web app, speed-related values (recordedSpeed, speedLimit) should be stored and handled as strings rather than numbers to maintain consistency with other similar fields and the backend data model.
Learnt from: oddsson
PR: island-is/island.is#17192
File: apps/judicial-system/web/src/routes/Prosecutor/Indictments/Indictment/IndictmentCount.tsx:579-587
Timestamp: 2024-12-17T20:28:47.549Z
Learning: In the `IndictmentCount.tsx` file of the `apps/judicial-system/web` project, constraints on the vehicle registration number are planned to be removed. Avoid suggesting changes related to vehicle registration number validation for now.
Learnt from: oddsson
PR: island-is/island.is#17192
File: apps/judicial-system/web/src/routes/Prosecutor/Indictments/Indictment/IndictmentCount.tsx:700-758
Timestamp: 2024-12-17T14:33:50.960Z
Learning: In the file `apps/judicial-system/web/src/routes/Prosecutor/Indictments/Indictment/IndictmentCount.tsx`, the user prefers not to add range validation for the blood alcohol content input.
Learnt from: oddsson
PR: island-is/island.is#17589
File: apps/judicial-system/api/src/app/modules/indictment-count/models/indictmentCount.model.ts:51-56
Timestamp: 2025-01-21T15:32:09.727Z
Learning: In the judicial-system application, speed-related values (recordedSpeed and speedLimit) in IndictmentCount models should be stored as strings rather than numbers.
Learnt from: oddsson
PR: island-is/island.is#16731
File: apps/judicial-system/web/src/routes/Shared/IndictmentOverview/IndictmentOverview.tsx:172-186
Timestamp: 2024-11-12T15:15:20.157Z
Learning: In `IndictmentOverview.tsx`, since the defendants data does not change, using `useMemo` to memoize the filtering logic is unnecessary.
Learnt from: thorhildurt
PR: island-is/island.is#17198
File: apps/judicial-system/web/src/routes/Prison/IndictmentOverview/IndictmentOverview.tsx:42-50
Timestamp: 2024-12-11T14:25:44.741Z
Learning: In `IndictmentOverview.tsx`, when updating the punishment type, update the UI state before making the API call to immediately reflect the change.
🪛 Biome (1.9.4)
apps/judicial-system/web/src/routes/Prosecutor/Indictments/Indictment/IndictmentCount.tsx

[error] 832-832: isNaN is unsafe. It attempts a type coercion. Use Number.isNaN instead.

See the MDN documentation for more details.
Unsafe fix: Use Number.isNaN instead.

(lint/suspicious/noGlobalIsNan)


[error] 876-876: isNaN is unsafe. It attempts a type coercion. Use Number.isNaN instead.

See the MDN documentation for more details.
Unsafe fix: Use Number.isNaN instead.

(lint/suspicious/noGlobalIsNan)

🔇 Additional comments (2)
apps/judicial-system/web/src/routes/Prosecutor/Indictments/Indictment/IndictmentCount.tsx (2)

Line range hint 85-107: LGTM! Clear documentation and consistent implementation.

The addition of the SPEEDING offense to the offenseLawsMap follows the established pattern and is well-documented.


713-716: LGTM! Clean reset implementation.

The speed values are properly reset when the speeding offense is removed, maintaining data consistency.

@oddsson oddsson enabled auto-merge January 28, 2025 22:04
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

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 7f420b7 and 1a01f73.

📒 Files selected for processing (1)
  • apps/judicial-system/web/src/routes/Prosecutor/Indictments/Indictment/IndictmentCount.tsx (7 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
apps/judicial-system/web/src/routes/Prosecutor/Indictments/Indictment/IndictmentCount.tsx (1)

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

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
📓 Learnings (1)
apps/judicial-system/web/src/routes/Prosecutor/Indictments/Indictment/IndictmentCount.tsx (6)
Learnt from: oddsson
PR: island-is/island.is#17589
File: apps/judicial-system/web/src/routes/Prosecutor/Indictments/Indictment/IndictmentCount.tsx:0-0
Timestamp: 2025-01-21T15:32:24.472Z
Learning: In the judicial-system web app, speed-related values (recordedSpeed, speedLimit) should be stored and handled as strings rather than numbers to maintain consistency with other similar fields and the backend data model.
Learnt from: oddsson
PR: island-is/island.is#17192
File: apps/judicial-system/web/src/routes/Prosecutor/Indictments/Indictment/IndictmentCount.tsx:579-587
Timestamp: 2024-12-17T20:28:47.549Z
Learning: In the `IndictmentCount.tsx` file of the `apps/judicial-system/web` project, constraints on the vehicle registration number are planned to be removed. Avoid suggesting changes related to vehicle registration number validation for now.
Learnt from: oddsson
PR: island-is/island.is#17192
File: apps/judicial-system/web/src/routes/Prosecutor/Indictments/Indictment/IndictmentCount.tsx:700-758
Timestamp: 2024-12-17T14:33:50.960Z
Learning: In the file `apps/judicial-system/web/src/routes/Prosecutor/Indictments/Indictment/IndictmentCount.tsx`, the user prefers not to add range validation for the blood alcohol content input.
Learnt from: oddsson
PR: island-is/island.is#17589
File: apps/judicial-system/api/src/app/modules/indictment-count/models/indictmentCount.model.ts:51-56
Timestamp: 2025-01-21T15:32:09.727Z
Learning: In the judicial-system application, speed-related values (recordedSpeed and speedLimit) in IndictmentCount models should be stored as strings rather than numbers.
Learnt from: oddsson
PR: island-is/island.is#16731
File: apps/judicial-system/web/src/routes/Shared/IndictmentOverview/IndictmentOverview.tsx:172-186
Timestamp: 2024-11-12T15:15:20.157Z
Learning: In `IndictmentOverview.tsx`, since the defendants data does not change, using `useMemo` to memoize the filtering logic is unnecessary.
Learnt from: thorhildurt
PR: island-is/island.is#17198
File: apps/judicial-system/web/src/routes/Prison/IndictmentOverview/IndictmentOverview.tsx:42-50
Timestamp: 2024-12-11T14:25:44.741Z
Learning: In `IndictmentOverview.tsx`, when updating the punishment type, update the UI state before making the API call to immediately reflect the change.
🔇 Additional comments (4)
apps/judicial-system/web/src/routes/Prosecutor/Indictments/Indictment/IndictmentCount.tsx (4)

Line range hint 85-107: Well-documented law mapping for speeding offense!

The addition of the SPEEDING offense to the offenseLawsMap is clean and follows the established pattern. The comment clearly explains the structure of the law references.


348-362: Good handling of optional speed values!

The implementation gracefully handles missing speed values by using placeholders, maintaining a consistent user experience.


404-407: Consistent error state management!

The error message state management for speed-related fields follows the established pattern in the codebase.


713-716: Clean state reset when removing speeding offense!

Good practice to reset the speed-related fields when the speeding offense is removed.

@oddsson oddsson added this pull request to the merge queue Jan 29, 2025
Merged via the queue into main with commit 50b7354 Jan 29, 2025
34 checks passed
@oddsson oddsson deleted the j-s/speeding branch January 29, 2025 09:10
robertaandersen pushed a commit that referenced this pull request Jan 29, 2025
* Add option SPEEDING

* Add legal arguments

* Add input fields

* Add recordedSpeed and speedLimit to db

* Enable seedLimit update

* Add validation

* Update indictment description

* Clear recorded speed and speed limit when removing speedig

* Add error handling

* Fix comment

* Fix lint

* Remove css

* Make Icon position abs

* Rec speed and speed limit is now number

* Remove island-ui change

* Improve validation

* Use Number.isNaN instead of isNaN
RunarVestmann pushed a commit that referenced this pull request Jan 29, 2025
* Add option SPEEDING

* Add legal arguments

* Add input fields

* Add recordedSpeed and speedLimit to db

* Enable seedLimit update

* Add validation

* Update indictment description

* Clear recorded speed and speed limit when removing speedig

* Add error handling

* Fix comment

* Fix lint

* Remove css

* Make Icon position abs

* Rec speed and speed limit is now number

* Remove island-ui change

* Improve validation

* Use Number.isNaN instead of isNaN
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.

2 participants