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): Allow multiple subtypes in indictments #17192

Merged
merged 98 commits into from
Jan 10, 2025
Merged

Conversation

oddsson
Copy link
Member

@oddsson oddsson commented Dec 10, 2024

Allow multiple subtypes in indictments

Asana

What

The changes in this PR enable users to create indictments with multiple subtypes. The main complexity with this change is

  1. Users can create indictment counts with one or more subtypes. Furthermore, if an indictment count has multiple subtypes, users can select individual indictment counts to work with.
  2. The indictment description should be autofilled with appropriate text based on what subtypes an indictment count is created with and what subtype is selected in the indictment count.
  3. The requestDriversLicenseSuspension and demands should be correctly autofilled based on whether or not there are traffic violation indictment counts.
  4. The Indictment screen (prev TrafficViolation screen) should be correctly validated.
  5. Please refer to the Asana task to see what exactly should happen when certain subtypes are selected.

There are also other, smaller changes implemented

  • Fix a typo in one of our Slack messages: Beðið um aftuköllun ✍️ Beðið um afturköllun
  • Rename stepHelper file in utils to utils. stepHelper is a bit outdated and utils is a bit clearer IMO. This change is responsible for most of the files changed in this PR.

Why

This is crucial for us to be able to offer combo indictments.

Screenshots / Gifs

Checklist:

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

Summary by CodeRabbit

Release Notes

  • Refactoring

    • Consolidated utility functions from stepHelper to utils module across multiple components.
    • Updated import paths for various utility functions like hasSentNotification, isBusiness, and shouldUseAppealWithdrawnRoutes.
  • Localization

    • Added new localization messages for indictment and substances-related fields.
    • Enhanced titles and labels for legal process input fields.
  • Indictment Handling

    • Improved validation and handling of indictment counts.
    • Added new utility functions for traffic violation and indictment count processing.
    • Enhanced logic for managing police case information and subtypes.
  • Testing

    • Expanded test coverage for utility functions and incident descriptions.
    • Added new test scenarios for handling various indictment subtypes.
  • Minor Improvements

    • Updated function signatures to support more flexible parameter handling.
    • Simplified some code structures using shorthand property names.

oddsson and others added 30 commits December 4, 2024 12:39
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, left some comments. Mostly questions and non-blocking nits ☺️

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 (1)
apps/judicial-system/web/src/utils/validate.ts (1)

311-327: Consider renaming validation functions to follow isValid pattern.

Following the suggestion from @thorhildurt, consider renaming these functions to follow the isValid pattern since they return booleans:

  • validateTrafficViolationisValidTrafficViolation
  • validateNonTrafficViolationisValidNonTrafficViolation
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 0b7a452 and a20095d.

📒 Files selected for processing (3)
  • apps/judicial-system/web/src/routes/Prosecutor/Indictments/Defendant/PoliceCaseInfo/PoliceCaseInfo.tsx (8 hunks)
  • apps/judicial-system/web/src/utils/validate.spec.ts (2 hunks)
  • apps/judicial-system/web/src/utils/validate.ts (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/judicial-system/web/src/routes/Prosecutor/Indictments/Defendant/PoliceCaseInfo/PoliceCaseInfo.tsx
🧰 Additional context used
📓 Path-based instructions (2)
apps/judicial-system/web/src/utils/validate.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."
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."
📓 Learnings (1)
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.
🔇 Additional comments (7)
apps/judicial-system/web/src/utils/validate.spec.ts (5)

308-317: LGTM! Basic validation test cases are comprehensive.

The test cases for basic validation (demands, civil claims) cover the essential edge cases and error conditions.


331-342: LGTM! Indictment subtypes validation is well tested.

The test case properly verifies that the function returns false when there are no indictment subtypes in a case.


344-378: LGTM! Pure traffic violations test case is thorough.

The test case for pure traffic violations is comprehensive, covering:

  • Multiple indictment counts
  • Required fields for traffic violations
  • Proper subtype assignment

380-415: LGTM! Invalid traffic violation test case is well structured.

The test case properly verifies that a single invalid indictment count (empty offenses array) causes the validation to fail.


417-453: LGTM! Mixed case test scenario is comprehensive.

The test case properly verifies that traffic violation validation works correctly when combined with other subtypes.

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

302-309: LGTM! Basic validation checks are clear and concise.

The hasValidDemands check properly validates both regular demands and civil demands when applicable.


328-333: LGTM! Pure traffic violation case handling is clear.

The code properly handles the case where all indictments are traffic violations.

apps/judicial-system/web/src/utils/validate.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: 0

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

311-318: Consider adding JSDoc comments for validation rules

The validation logic for traffic violations is clear, but documenting the business rules would improve maintainability.

+/**
+ * Validates a traffic violation indictment count.
+ * Required fields:
+ * - policeCaseNumber
+ * - offenses (non-empty array)
+ * - vehicleRegistrationNumber
+ * - lawsBroken
+ * - incidentDescription
+ * - legalArguments
+ */
 const isValidTrafficViolation = (indictmentCount: 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 a20095d and 5d17851.

📒 Files selected for processing (1)
  • apps/judicial-system/web/src/utils/validate.ts (3 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
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."
📓 Learnings (1)
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.
🔇 Additional comments (5)
apps/judicial-system/web/src/utils/validate.ts (5)

302-306: LGTM: Demands validation logic is clear and concise

The validation correctly checks for both general demands and civil demands when civil claims are present.


307-310: LGTM: Early validation checks prevent unnecessary processing

Good practice to fail fast by checking required conditions early.


319-322: LGTM: Non-traffic violation validation is appropriately less strict

The validation correctly requires only the essential fields for non-traffic violations.


323-327: LGTM: Clear type checking logic

The function effectively determines if an indictment count is a traffic violation.


328-341: Verify test coverage for mixed indictment scenarios

The logic for handling both traffic and non-traffic violations in the same case looks correct. However, ensure comprehensive test coverage for:

  1. Cases with only traffic violations
  2. Cases with mixed violation types
  3. Edge cases with empty indictment counts
✅ Verification successful

Test coverage for mixed indictment scenarios is adequate

The test suite includes comprehensive coverage for all required scenarios:

  • Pure traffic violation cases (both valid and invalid)
  • Mixed violation types ("should return true if one indictment count has selected traffic violation and another has not")
  • Edge cases with empty or null indictment counts ("should return false if there are no demands in a case")
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check test coverage for mixed indictment scenarios

# Look for test cases covering mixed scenarios
rg -A 5 "describe.*isTrafficViolationStepValidIndictments" apps/judicial-system/web/src/utils/validate.spec.ts

# Check for specific test cases
rg "it.*mixed.*indictment" apps/judicial-system/web/src/utils/validate.spec.ts

Length of output: 412


Script:

#!/bin/bash
# Let's check the entire test file content for traffic violation validation tests
rg -B 2 -A 10 "isTrafficViolationStepValidIndictments|isTrafficViolation|isValidTrafficViolation|isValidNonTrafficViolation" apps/judicial-system/web/src/utils/validate.spec.ts

# Also check for any test cases with multiple indictment counts
rg -B 2 -A 5 "indictmentCounts.*\[" apps/judicial-system/web/src/utils/validate.spec.ts

Length of output: 3872

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

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

292-358: Consider extracting description generation logic into separate functions.

The function has grown complex with multiple nested conditions and different description formats. Consider breaking it down into smaller, focused functions for better maintainability:

  • generateTrafficViolationDescription
  • generateSingleSubtypeDescription
  • generateMultiSubtypeDescription
 export const getIncidentDescription = (
   indictmentCount: TIndictmentCount,
   formatMessage: IntlShape['formatMessage'],
   crimeScene?: CrimeScene,
   subtypesRecord?: Record<string, IndictmentSubtype[]>,
 ) => {
   const {
     offenses,
     substances,
     vehicleRegistrationNumber,
     indictmentCountSubtypes,
     policeCaseNumber,
   } = indictmentCount

   const incidentLocation = crimeScene?.place || '[Vettvangur]'
   const incidentDate = crimeScene?.date
     ? formatDate(crimeScene.date, 'PPPP')?.replace('dagur,', 'daginn') || ''
     : '[Dagsetning]'

   const vehicleRegistration =
     vehicleRegistrationNumber || '[Skráningarnúmer ökutækis]'

   const subtypes =
     (subtypesRecord && policeCaseNumber && subtypesRecord[policeCaseNumber]) ||
     []

   if (
     subtypes.length > 1 &&
     (!indictmentCountSubtypes?.length || indictmentCountSubtypes.length === 0)
   ) {
     return ''
   }

+  const generateTrafficViolationDescription = () => {
+    if (!offenses || offenses.length === 0) {
+      return ''
+    }
+
+    const reason = getIncidentDescriptionReason(
+      offenses,
+      substances || {},
+      formatMessage,
+    )
+
+    return formatMessage(strings.incidentDescriptionAutofill, {
+      incidentDate,
+      vehicleRegistrationNumber: vehicleRegistration,
+      reason,
+      incidentLocation,
+    })
+  }
+
+  const generateSingleSubtypeDescription = () => {
+    return formatMessage(strings.indictmentDescriptionSubtypesAutofill, {
+      subtypes: indictmentSubtypes[subtypes[0]],
+      date: incidentDate,
+    })
+  }
+
+  const generateMultiSubtypeDescription = () => {
+    const allSubtypes = indictmentCountSubtypes
+      ?.map((subtype) => indictmentSubtypes[subtype])
+      .join(', ')
+
+    return formatMessage(strings.indictmentDescriptionSubtypesAutofill, {
+      subtypes: allSubtypes,
+      date: incidentDate,
+    })
+  }

   if (
     isTrafficViolationIndictmentCount(policeCaseNumber, subtypesRecord) ||
     (indictmentCountSubtypes?.length === 1 &&
       indictmentCountSubtypes[0] === IndictmentSubtype.TRAFFIC_VIOLATION)
   ) {
-    if (!offenses || offenses.length === 0) {
-      return ''
-    }
-
-    const reason = getIncidentDescriptionReason(
-      offenses,
-      substances || {},
-      formatMessage,
-    )
-
-    return formatMessage(strings.incidentDescriptionAutofill, {
-      incidentDate,
-      vehicleRegistrationNumber: vehicleRegistration,
-      reason,
-      incidentLocation,
-    })
+    return generateTrafficViolationDescription()
   }

   if (subtypes.length === 1) {
-    return formatMessage(strings.indictmentDescriptionSubtypesAutofill, {
-      subtypes: indictmentSubtypes[subtypes[0]],
-      date: incidentDate,
-    })
+    return generateSingleSubtypeDescription()
   }

-  const allSubtypes = indictmentCountSubtypes
-    ?.map((subtype) => indictmentSubtypes[subtype])
-    .join(', ')
-
-  return formatMessage(strings.indictmentDescriptionSubtypesAutofill, {
-    subtypes: allSubtypes,
-    date: incidentDate,
-  })
+  return generateMultiSubtypeDescription()
 }

470-495: Consider simplifying the visibility check logic.

The shouldShowTrafficViolationFields function could be simplified by combining the conditions.

 const shouldShowTrafficViolationFields = () => {
-  if (isTrafficViolationCase(workingCase)) {
-    return true
-  }
-
-  const policeCaseNumber = indictmentCount.policeCaseNumber
-
-  if (
-    isTrafficViolationIndictmentCount(
-      policeCaseNumber,
-      workingCase.indictmentSubtypes,
-    )
-  ) {
-    return true
-  }
-
-  if (
-    indictmentCount?.indictmentCountSubtypes?.includes(
-      IndictmentSubtype.TRAFFIC_VIOLATION,
-    )
-  ) {
-    return true
-  }
-
-  return false
+  return (
+    isTrafficViolationCase(workingCase) ||
+    isTrafficViolationIndictmentCount(
+      indictmentCount.policeCaseNumber,
+      workingCase.indictmentSubtypes,
+    ) ||
+    indictmentCount?.indictmentCountSubtypes?.includes(
+      IndictmentSubtype.TRAFFIC_VIOLATION,
+    )
+  )
 }
apps/judicial-system/web/src/utils/validate.ts (1)

304-320: Add JSDoc documentation for helper functions.

The helper functions are well-structured but would benefit from JSDoc documentation explaining their purpose and validation rules.

+/**
+ * Validates if an indictment count meets traffic violation requirements
+ * @param indictmentCount The indictment count to validate
+ * @returns true if all required fields are present
+ */
 const isValidTrafficViolation = (indictmentCount: IndictmentCount) =>

+/**
+ * Validates if an indictment count meets non-traffic violation requirements
+ * @param indictmentCount The indictment count to validate
+ * @returns true if all required fields are present
+ */
 const isValidNonTrafficViolation = (indictmentCount: IndictmentCount) =>

+/**
+ * Checks if an indictment count is classified as a traffic violation
+ * @param indictmentCount The indictment count to check
+ * @returns true if the count includes TRAFFIC_VIOLATION subtype
+ */
 const isTrafficViolation = (indictmentCount: 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 5d17851 and 5e7d360.

📒 Files selected for processing (4)
  • apps/judicial-system/web/src/routes/Court/components/ReceptionAndAssignment/ReceptionAndAssignment.tsx (1 hunks)
  • apps/judicial-system/web/src/routes/Prosecutor/Indictments/Indictment/IndictmentCount.spec.tsx (2 hunks)
  • apps/judicial-system/web/src/routes/Prosecutor/Indictments/Indictment/IndictmentCount.tsx (9 hunks)
  • apps/judicial-system/web/src/utils/validate.ts (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • apps/judicial-system/web/src/routes/Prosecutor/Indictments/Indictment/IndictmentCount.spec.tsx
  • apps/judicial-system/web/src/routes/Court/components/ReceptionAndAssignment/ReceptionAndAssignment.tsx
🧰 Additional context used
📓 Path-based instructions (2)
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/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 (2)
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/web/src/routes/Prosecutor/Indictments/Indictment/IndictmentCount.tsx (5)
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#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.
Learnt from: unakb
PR: island-is/island.is#15378
File: apps/judicial-system/web/src/routes/Court/Indictments/Summary/Summary.tsx:86-100
Timestamp: 2024-11-12T15:15:11.835Z
Learning: User unakb prefers explicit case handling in switch statements for key functionalities like `getRulingDecisionTagColor` to ensure clarity and avoid assumptions that a case was overlooked.
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: tests (judicial-system-backend)
  • GitHub Check: build (web)
🔇 Additional comments (8)
apps/judicial-system/web/src/routes/Prosecutor/Indictments/Indictment/IndictmentCount.tsx (5)

22-22: LGTM: New utility imports for traffic violation handling.

The addition of isTrafficViolationCase and isTrafficViolationIndictmentCount utilities aligns with the PR's objective of supporting multiple subtypes in indictments.

Also applies to: 38-38


383-386: LGTM: Clean subtype state initialization.

The subtype state initialization is well-handled with proper null checks and default values.


462-466: LGTM: Proper cleanup of related fields.

Good practice: When traffic violation subtype is removed, all related fields (offenses, substances, vehicle registration) are properly cleaned up.


Line range hint 511-543: LGTM: Well-structured police case number selection.

The police case number selection UI is well-implemented with:

  • Clear section heading
  • Proper label and placeholder
  • Required field validation
  • Proper value handling

544-587: LGTM: Clean implementation of subtype selection.

The subtype selection UI is well-structured with:

  • Conditional rendering based on multiple subtypes
  • Clear section heading
  • Proper checkbox implementation
  • Good TypeScript usage
apps/judicial-system/web/src/utils/validate.ts (3)

Line range hint 3-22: LGTM! Clean import organization.

The new imports and types are well-organized and align with the feature requirements for handling multiple subtypes in indictments.


295-299: LGTM! Clear validation logic for demands.

The validation logic for demands and civil claims is clear and concise.


321-334: Verify mixed case validation logic.

The implementation for mixed cases looks correct, but let's verify the behavior when:

  1. Some counts are traffic violations and others are not
  2. Empty indictment counts array

@oddsson oddsson added the deprecated:automerge (Disabled) Merge this PR as soon as all checks pass label Jan 9, 2025
@oddsson oddsson requested review from thorhildurt and removed request for thorhildurt January 9, 2025 14:33
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

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

292-292: Add type safety for subtypesRecord parameter.

Consider adding a more specific type for subtypesRecord instead of using Record<string, IndictmentSubtype[]>.

-subtypesRecord?: Record<string, IndictmentSubtype[]>
+type IndictmentSubtypesRecord = Record<string, IndictmentSubtype[]>
+subtypesRecord?: IndictmentSubtypesRecord

314-357: Consider breaking down the complex conditional logic.

The function has multiple nested conditions and different formatting paths. Consider extracting these into separate helper functions for better maintainability:

  • formatTrafficViolationDescription
  • formatSingleSubtypeDescription
  • formatMultipleSubtypesDescription

Line range hint 382-386: Consider memoizing the subtypes calculation.

The subtypes calculation could be memoized using useMemo to prevent unnecessary recalculations on re-renders.

-  const subtypes: IndictmentSubtype[] = indictmentCount.policeCaseNumber
-    ? workingCase.indictmentSubtypes[indictmentCount.policeCaseNumber]
-    : []
+  const subtypes = useMemo(() => 
+    indictmentCount.policeCaseNumber
+      ? workingCase.indictmentSubtypes[indictmentCount.policeCaseNumber]
+      : [],
+    [indictmentCount.policeCaseNumber, workingCase.indictmentSubtypes]
+  )
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 5e7d360 and 3e9ab55.

📒 Files selected for processing (1)
  • apps/judicial-system/web/src/routes/Prosecutor/Indictments/Indictment/IndictmentCount.tsx (9 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 (5)
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#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.
Learnt from: unakb
PR: island-is/island.is#15378
File: apps/judicial-system/web/src/routes/Court/Indictments/Summary/Summary.tsx:86-100
Timestamp: 2024-11-12T15:15:11.835Z
Learning: User unakb prefers explicit case handling in switch statements for key functionalities like `getRulingDecisionTagColor` to ensure clarity and avoid assumptions that a case was overlooked.
🔇 Additional comments (2)
apps/judicial-system/web/src/routes/Prosecutor/Indictments/Indictment/IndictmentCount.tsx (2)

22-22: LGTM! New utility imports for traffic violation checks.

The addition of isTrafficViolationCase and isTrafficViolationIndictmentCount utilities aligns with the PR's objective to support multiple subtypes in indictments.

Also applies to: 38-38


469-494: LGTM! Well-structured utility function.

The shouldShowTrafficViolationFields function is well-organized and follows a clear logical flow for determining when to show traffic violation fields.

@kodiakhq kodiakhq bot merged commit acfeb49 into main Jan 10, 2025
37 checks passed
@kodiakhq kodiakhq bot deleted the j-s/multi-subtype-2 branch January 10, 2025 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deprecated:automerge (Disabled) Merge this PR as soon as all checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants