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): Additional info for law and order cases and subpoenas #16132

Merged
merged 9 commits into from
Sep 24, 2024

Conversation

unakb
Copy link
Member

@unakb unakb commented Sep 24, 2024

Birtingar - Mínar Síður - verjandi + alert message

What

  • Connected subpoena acknowledgement info to backend
  • Added boolean to indicate whether user can change defense choice
  • Added info for info bubble if user can no longer change defense
  • Added more info to location of arriagnment
  • Added alert message type to handle alert messages for subpoena

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

  • New Features

    • Introduced a new TagVariant enumeration for standardized color options in case states.
    • Added a StateTag class to encapsulate state properties, improving data structure clarity.
    • Introduced an AlertMessageType enum to categorize alert messages in subpoenas.
    • Updated DefenderInfo class with optional properties canEdit and courtContactInfo for enhanced user interaction.
    • Modified SubpoenaData to include an alerts array for better tracking of subpoena statuses.
    • Added an optional address property to the Institution interface for improved data representation.
  • Bug Fixes

    • Improved logic for determining acknowledgment status of subpoenas.
  • Documentation

    • Enhanced API documentation with clearer property definitions and usage examples.

@unakb unakb requested a review from a team as a code owner September 24, 2024 11:05
Copy link
Contributor

coderabbitai bot commented Sep 24, 2024

Walkthrough

The changes introduced in this pull request enhance the CasesResponse, SubpoenaResponse, and Institution interface within the judicial system's backend. Key modifications include the addition of a new TagVariant enum and StateTag class in cases.response.ts, improving the organization of state properties. In subpoena.response.ts, a new AlertMessage class is added, and the DefenderInfo class is updated with optional properties. The SubpoenaData class is restructured to replace the acknowledged property with an alerts array. Additionally, an optional address property is added to the Institution interface.

Changes

File Change Summary
apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/cases.response.ts Introduced TagVariant enum and StateTag class; updated CasesResponse to use StateTag.
apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/subpoena.response.ts Added AlertMessage class, updated DefenderInfo with canEdit and courtContactInfo, and modified SubpoenaData to replace acknowledged with alerts.
libs/judicial-system/types/src/lib/institution.ts Added optional address property to the Institution interface.

Possibly related PRs

Suggested reviewers

  • gudjong

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    -- I pushed a fix in commit <commit_id>, please review it.
    -- Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    -- @coderabbitai generate unit testing code for this file.
    -- @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    -- @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    -- @coderabbitai read src/utils.ts and generate unit testing code.
    -- @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    -- @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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

Outside diff range and nitpick comments (9)
apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/cases.response.ts (2)

8-14: LGTM! Consider adding JSDoc comments for better documentation.

The new StateTag class is well-structured and follows TypeScript and NestJS best practices. The use of @ApiProperty decorators is appropriate for API documentation.

Consider adding JSDoc comments to the class and its properties for improved code documentation:

/**
 * Represents the state of a case with color and label.
 */
class StateTag {
  /**
   * The color associated with the state.
   */
  @ApiProperty({ type: String })
  color!: string

  /**
   * The label describing the state.
   */
  @ApiProperty({ type: String })
  label!: string
}

26-27: LGTM! Consider updating the static method for consistency.

The update to use the StateTag type for the state property improves type safety and aligns with TypeScript best practices.

For consistency, consider updating the fromInternalCasesResponse static method to use the StateTag class explicitly:

static fromInternalCasesResponse(
  response: InternalCasesResponse[],
  lang?: string,
): CasesResponse[] {
  return response.map((item: InternalCasesResponse) => {
    const t = getTranslations(lang)

    return {
      id: item.id,
      state: new StateTag({
        color: isCompletedCase(item.state) ? 'purple' : 'blue',
        label: isCompletedCase(item.state) ? t.completed : t.active,
      }),
      caseNumber: `${t.caseNumber} ${item.courtCaseNumber}`,
      type: t.indictment,
    }
  })
}

This change would require adding a constructor to the StateTag class:

class StateTag {
  // ... existing properties ...

  constructor(data: { color: string; label: string }) {
    this.color = data.color;
    this.label = data.label;
  }
}
apps/judicial-system/backend/src/app/modules/defendant/defendant.module.ts (2)

8-8: LGTM! Consider grouping related imports.

The changes look good and align with the PR objectives. The Subpoena model is correctly imported and added to the SequelizeModule.forFeature call, which will make it available for dependency injection within this module.

Consider grouping related imports together for better readability. You could move the Subpoena import next to other model imports:

import { CivilClaimant } from './models/civilClaimant.model'
import { Defendant } from './models/defendant.model'
import { Subpoena } from '../subpoena/models/subpoena.model'

Also applies to: 22-22


Line range hint 1-33: Summary: Subpoena model integration enhances case management capabilities

These changes successfully integrate the Subpoena model into the DefendantModule, aligning with the PR's objective to enhance functionality for law and order cases and subpoenas. By including the Subpoena model in the SequelizeModule.forFeature call, you've made it available for dependency injection within this module, which will allow for better tracking and management of subpoenas in relation to defendants.

As the system grows, consider creating a separate SubpoenaModule if subpoena-related functionality becomes more complex. This would improve modularity and separation of concerns.

apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/case.response.ts (1)

33-38: LGTM: Improved subpoena handling logic

The introduction of new variables and the updated logic for hasBeenServed significantly improve the integration of subpoena acknowledgement information. This aligns well with the PR objectives and enhances the overall functionality.

Consider adding a comment explaining the fallback logic for subpoenaCreatedDate. For example:

// Fallback to empty string if subpoenaDateLog or its created property is undefined
const subpoenaCreatedDate = subpoenaDateLog?.created?.toString() ?? '';

This would clarify the intention behind the fallback logic and improve code maintainability.

apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/utils/translations.strings.ts (1)

50-51: LGTM: English translations added correctly

The new English translations for courtContactInfo and subpoenaServed have been added correctly. The messages are clear, relevant, and grammatically correct.

Consider adding a period at the end of the courtContactInfo message for consistency with other multi-line messages:

 courtContactInfo:
-      'Please contact the court if you wish to change your choice of defender',
+      'Please contact the court if you wish to change your choice of defender.',

Also applies to: 70-71

apps/judicial-system/backend/src/app/modules/defendant/models/defendant.model.ts (2)

138-139: LGTM: Subpoenas property correctly added with a minor suggestion

The 'subpoenas' property is correctly added and typed as an optional array of Subpoena. The @ApiPropertyOptional decorator is used appropriately for Swagger documentation.

For improved type safety, consider using a more specific type annotation:

subpoenas?: Subpoena[] | null;

This explicitly allows for null values, which might be returned by some ORM queries when no related records are found.


7-7: Summary: Successful integration of Subpoena relationship

The changes in this file successfully integrate the Subpoena model with the Defendant model, aligning with the PR objectives. The new HasMany relationship and corresponding property are correctly implemented, following TypeScript and Sequelize ORM best practices. These modifications enhance the data structure by allowing a defendant to have multiple associated subpoenas, which will improve the tracking and management of subpoenas in the judicial system backend.

As the application grows, consider the potential impact of this relationship on query performance. If you frequently need to load defendants with their subpoenas, you might want to implement eager loading strategies or create composite queries to optimize database access.

Also applies to: 24-24, 137-139

apps/judicial-system/backend/src/app/modules/police/police.service.ts (1)

524-526: Approve changes with suggestions for improvement

The introduction of normalizedNationalId using the normalizeAndFormatNationalId function is a good practice for ensuring data consistency. However, there are a few points to consider:

  1. Error handling: Consider adding error handling for cases where the normalization might fail.
  2. Array destructuring: The use of [0] suggests that normalizeAndFormatNationalId returns an array. It might be worth documenting why we're only using the first element.

Consider refactoring the code to include error handling:

let normalizedNationalId: string;
try {
  const [normalized] = normalizeAndFormatNationalId(defendantNationalId);
  if (!normalized) {
    throw new Error('Failed to normalize national ID');
  }
  normalizedNationalId = normalized;
} catch (error) {
  this.logger.error(`Failed to normalize national ID for case ${workingCase.id}`, {
    error,
    defendantNationalId,
  });
  throw error;
}

This approach ensures that any issues with normalization are caught and logged, improving the robustness of the application.

Also applies to: 548-548

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 9c26661 and 80e2b0e.

Files selected for processing (9)
  • apps/judicial-system/backend/src/app/modules/case/internalCase.service.ts (3 hunks)
  • apps/judicial-system/backend/src/app/modules/defendant/defendant.module.ts (2 hunks)
  • apps/judicial-system/backend/src/app/modules/defendant/models/defendant.model.ts (3 hunks)
  • apps/judicial-system/backend/src/app/modules/police/police.service.ts (3 hunks)
  • apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/case.response.ts (3 hunks)
  • apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/cases.response.ts (2 hunks)
  • apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/internal/internalCase.response.ts (2 hunks)
  • apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/subpoena.response.ts (3 hunks)
  • apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/utils/translations.strings.ts (6 hunks)
Additional context used
Path-based instructions (9)
apps/judicial-system/backend/src/app/modules/case/internalCase.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."
apps/judicial-system/backend/src/app/modules/defendant/defendant.module.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/src/app/modules/defendant/models/defendant.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/backend/src/app/modules/police/police.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."
apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/case.response.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/digital-mailbox-api/src/app/modules/cases/models/cases.response.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/digital-mailbox-api/src/app/modules/cases/models/internal/internalCase.response.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/digital-mailbox-api/src/app/modules/cases/models/subpoena.response.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/digital-mailbox-api/src/app/modules/cases/models/utils/translations.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."
Additional comments not posted (21)
apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/internal/internalCase.response.ts (3)

31-31: LGTM: Addition of subpoenas property to Defendant interface

The addition of the optional subpoenas property to the Defendant interface is well-implemented. It's correctly typed as an array of Subpoena objects and made optional, which maintains backwards compatibility. This change aligns with the PR objectives of integrating subpoena acknowledgement information and enhances the data structure for defendants.


31-31: Overall impact and follow-up suggestions

The additions of the subpoenas property to the Defendant interface and the new Subpoena interface are well-integrated and align with the PR objectives. They enhance the data model to include subpoena information while maintaining type safety.

To ensure full integration:

  1. Update any components or services that interact with the Defendant interface to handle the new subpoenas property.
  2. Consider adding unit tests for these new data structures.
  3. Update relevant documentation to reflect these changes in the data model.

Let's check for potential areas that might need updates:

Also applies to: 42-46


42-46: Approve Subpoena interface with a request for clarification

The new Subpoena interface is well-structured and includes the necessary properties for tracking subpoena acknowledgement, which aligns with the PR objectives. However, could you please clarify the difference between id and subpoenaId? It seems potentially redundant to have both fields, and understanding their distinct purposes would be helpful.

To ensure these fields are used consistently across the codebase, let's run the following check:

apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/case.response.ts (5)

15-15: LGTM: Property renamed for clarity

The renaming of acknowledged to hasBeenServed improves the clarity of the code and better reflects the domain language. This change is consistent with the PR objectives and enhances the readability of the IndictmentCaseData class.


29-29: LGTM: Method parameter renamed for clarity

The renaming of the parameter from res to internalCase in the fromInternalCaseResponse method improves code readability and aligns with TypeScript best practices. This change enhances the overall clarity of the method signature.


41-44: LGTM: Consistent use of internalCase and improved subpoena handling

The changes in the return statement correctly utilize the internalCase object and implement the new subpoena acknowledgement logic. This ensures consistency with the parameter renaming and aligns with the PR objectives for integrating subpoena information.


79-95: LGTM: Consistent use of internalCase in information group

The changes in the information group of the return statement consistently use the internalCase object instead of the previous res. This refactoring improves code consistency and readability without altering the underlying logic.


Line range hint 1-103: Overall assessment: High-quality changes that meet PR objectives

The changes in this file successfully integrate subpoena acknowledgement information and improve the overall code quality. Key improvements include:

  1. Renaming properties and parameters for better clarity
  2. Implementing subpoena handling logic
  3. Consistently using the internalCase object throughout the code

These changes adhere to TypeScript and NextJS best practices, improving code readability and maintainability. The modifications align well with the PR objectives and enhance the functionality related to law and order cases and subpoenas.

apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/utils/translations.strings.ts (2)

14-14: LGTM: New translation properties added correctly

The new properties courtContactInfo and subpoenaServed have been added to the Translations type correctly. They follow the existing naming convention and are appropriately typed as string.

Also applies to: 33-33


85-86: Icelandic translations added, please verify

The new Icelandic translations for courtContactInfo and subpoenaServed have been added with consistent formatting.

As a non-Icelandic speaker, I cannot verify the accuracy of these translations. Please ensure that a native Icelandic speaker or a qualified translator reviews these new entries for correctness and clarity.

Also applies to: 105-105

apps/judicial-system/backend/src/app/modules/defendant/models/defendant.model.ts (2)

7-7: LGTM: Import statements are correctly added

The new import statements for HasMany decorator and Subpoena model are correctly placed and necessary for the new relationship being added to the Defendant model. This follows TypeScript best practices for importing only the required elements.

Also applies to: 24-24


137-137: LGTM: HasMany relationship correctly defined

The new HasMany relationship between Defendant and Subpoena models is correctly implemented. The explicit foreign key definition enhances clarity. This change aligns well with the PR objectives of integrating subpoena information with the backend.

apps/judicial-system/backend/src/app/modules/police/police.service.ts (1)

24-24: LGTM: Import statement follows best practices

The import of normalizeAndFormatNationalId is well-structured and follows TypeScript best practices. It's a named import, which is good for tree-shaking and indicates a well-organized project structure.

apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/subpoena.response.ts (4)

23-28: Addition of 'canEdit' and 'courtContactInfo' properties to 'DefenderInfo'

The inclusion of the optional properties canEdit and courtContactInfo in the DefenderInfo class enhances the model by providing additional information about the defender's capabilities and court contact details.


42-43: Integration of 'alerts' property into 'SubpoenaData' enhances user communication

Adding the alerts property as an array of AlertMessage objects to the SubpoenaData class allows the system to communicate important messages to the user effectively.


94-104: Conditional inclusion of alert messages based on acknowledgment status

The code correctly includes a success alert when the subpoena is acknowledged:

alerts: [
  ...(subpoenaAcknowledged
    ? [
        {
          type: 'success',
          message: t.subpoenaServed,
        },
      ]
    : []),
],

Ensure that the translation t.subpoenaServed provides the appropriate localized message and that the type property aligns with the suggested AlertType enum for consistency.


137-140: Validation of 'canEdit' and 'courtContactInfo' logic in 'defenderInfo'

The assignment of canEdit and courtContactInfo based on canChangeDefenseChoice accurately reflects the business logic:

canEdit: canChangeDefenseChoice,
courtContactInfo: canChangeDefenseChoice
  ? t.courtContactInfo
  : undefined,

This ensures that users receive the correct information regarding their ability to change their defense choice and whom to contact at the court.

apps/judicial-system/backend/src/app/modules/case/internalCase.service.ts (4)

61-61: Import Subpoena Model Successfully

The Subpoena model is correctly imported from '../subpoena/models/subpoena.model' for use within the service.


1208-1211: Include 'defendants' Association in Query

Including the defendants association ensures that defendant information is retrieved along with the case data. This inclusion is appropriate and necessary for comprehensive case details.


1235-1245: Eager Loading 'subpoenas' within 'defendants' Association

The nested inclusion of Subpoena within the defendants association allows for eager loading of subpoenas related to each defendant, ordered by the created date in descending order. This ensures that all relevant subpoena information is fetched efficiently.


1249-1253: Include 'institution' Association within 'prosecutor'

Including the institution model within the prosecutor association ensures that the prosecutor's institution data is eagerly loaded. This provides a complete set of information for the prosecutor associated with the case.

Copy link

codecov bot commented Sep 24, 2024

Codecov Report

Attention: Patch coverage is 50.00000% with 4 lines in your changes missing coverage. Please review.

Project coverage is 36.71%. Comparing base (f55aa92) to head (2838a15).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...rc/app/modules/defendant/models/defendant.model.ts 50.00% 2 Missing ⚠️
...kend/src/app/modules/defendant/defendant.module.ts 0.00% 1 Missing ⚠️
...m/backend/src/app/modules/police/police.service.ts 50.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #16132      +/-   ##
==========================================
+ Coverage   36.69%   36.71%   +0.01%     
==========================================
  Files        6761     6761              
  Lines      139068   139076       +8     
  Branches    39501    39501              
==========================================
+ Hits        51035    51055      +20     
+ Misses      88033    88021      -12     
Flag Coverage Δ
judicial-system-api 18.61% <ø> (ø)
judicial-system-backend 54.78% <50.00%> (+0.08%) ⬆️
judicial-system-formatters 79.76% <ø> (ø)
judicial-system-message 66.86% <ø> (ø)
judicial-system-message-handler 47.71% <ø> (ø)
judicial-system-scheduler 69.06% <ø> (ø)
judicial-system-types 48.35% <ø> (ø)
judicial-system-web 28.56% <ø> (ø)

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

Files with missing lines Coverage Δ
...ckend/src/app/modules/case/internalCase.service.ts 85.12% <100.00%> (+0.03%) ⬆️
libs/judicial-system/types/src/lib/institution.ts 100.00% <ø> (ø)
...kend/src/app/modules/defendant/defendant.module.ts 0.00% <0.00%> (ø)
...m/backend/src/app/modules/police/police.service.ts 74.86% <50.00%> (-0.28%) ⬇️
...rc/app/modules/defendant/models/defendant.model.ts 84.37% <50.00%> (-4.92%) ⬇️

... 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 2bd9353...2838a15. Read the comment docs.

@datadog-island-is
Copy link

datadog-island-is bot commented Sep 24, 2024

Datadog Report

All test runs f1fc0fc 🔗

9 Total Test Services: 0 Failed, 9 Passed
⬆️ Test Sessions change in coverage: 1 increased (+0.1%), 13 no change

Test Services
Service Name Failed Known Flaky New Flaky Passed Skipped Total Time Code Coverage Change Test Service View
judicial-system-api 0 0 0 57 0 5.8s 1 no change Link
judicial-system-backend 0 0 0 21269 0 18m 44.13s 1 increased (+0.1%) Link
judicial-system-formatters 0 0 0 38 0 5.06s 1 no change Link
judicial-system-message 0 0 0 32 0 10.49s 1 no change Link
judicial-system-message-handler 0 0 0 4 0 3.4s 1 no change Link
judicial-system-scheduler 0 0 0 4 0 3.94s 1 no change Link
judicial-system-types 0 0 0 23 0 7.14s 1 no change Link
judicial-system-web 0 0 0 338 0 1m 5.49s 1 no change Link
judicial-system-xrd-api 0 0 0 6 0 4.93s 1 no change Link

@oddsson oddsson added automerge Merge this PR as soon as all checks pass and removed automerge Merge this PR as soon as all checks pass labels Sep 24, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Outside diff range and nitpick comments (3)
apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/cases.response.ts (1)

25-32: LGTM: StateTag class is well-structured. Consider initializing properties.

The StateTag class is well-structured and uses decorators appropriately for validation and API documentation. It follows TypeScript best practices.

Consider initializing the properties instead of using non-null assertions:

class StateTag {
  @IsEnum(TagVariant)
  @ApiProperty({ enum: TagVariant })
  color: TagVariant = TagVariant.BLUE;

  @ApiProperty({ type: String })
  label: string = '';
}

This approach provides default values and eliminates the need for non-null assertions, potentially improving type safety.

apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/subpoena.response.ts (2)

38-44: LGTM with suggestion: Consider making AlertMessage properties required

The new AlertMessage class is well-structured and uses the AlertMessageType enum for improved type safety. However, consider making the type and message properties required if they are always needed for a valid alert message. This would ensure that all alert messages have both a type and a message.

If you decide to make them required, you can remove the question marks from the property declarations:

class AlertMessage {
  @IsEnum(AlertMessageType)
  @ApiProperty({ enum: AlertMessageType })
  type!: AlertMessageType

  @ApiProperty({ type: () => String })
  message!: string
}

88-90: Approved with suggestion: Consider a more robust way to determine hasBeenServed

The changes to the fromInternalCaseResponse method are generally good, especially the improved formatting of the arraignment location. However, the hasBeenServed variable is determined based only on the first subpoena's acknowledgment status. This might not be accurate if there are multiple subpoenas.

Consider using a more robust method to determine the hasBeenServed status, such as checking if any subpoena has been acknowledged:

const hasBeenServed = subpoena.some(s => s.acknowledged) ?? false

This approach ensures that the status is accurate even when there are multiple subpoenas.

Also applies to: 97-99

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 61b7461 and cc840d0.

Files selected for processing (2)
  • apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/cases.response.ts (3 hunks)
  • apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/subpoena.response.ts (3 hunks)
Additional context used
Path-based instructions (2)
apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/cases.response.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/digital-mailbox-api/src/app/modules/cases/models/subpoena.response.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."
Additional comments not posted (8)
apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/cases.response.ts (3)

1-1: LGTM: Import statement addition is appropriate.

The addition of IsEnum from 'class-validator' is necessary for the new StateTag class and follows TypeScript best practices for ensuring type safety.


10-23: LGTM: TagVariant enum is well-structured and follows best practices.

The TagVariant enum provides a type-safe way to represent color variants, following TypeScript best practices for creating constants. The naming convention is consistent and clear, enhancing code readability and maintainability.


43-44: LGTM: CasesResponse class updates improve type safety and consistency.

The changes to the CasesResponse class, including updating the state property type to StateTag and using TagVariant enum values in the fromInternalCasesResponse method, improve type safety and maintain consistency with the new StateTag class. The logic for setting the color based on the case state remains intact and clear.

Also applies to: 56-58

apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/subpoena.response.ts (5)

15-21: LGTM: Well-defined enum for alert message types

The addition of the AlertMessageType enum is a good practice. It provides a clear set of allowed values for alert message types, improving type safety and preventing the use of invalid values. The naming convention follows the standard uppercase snake case for TypeScript enums.


31-35: LGTM: Appropriate additions to DefenderInfo class

The new optional properties canEdit and courtContactInfo are well-defined and properly decorated. They maintain consistency with the existing code style and improve the flexibility of the DefenderInfo class by allowing for additional information when available.


51-52: LGTM: Flexible addition of alerts to SubpoenaData

The new alerts property in the SubpoenaData class is well-defined. Using an array of AlertMessage objects allows for multiple alerts, providing flexibility in the response structure. Making it optional is appropriate, as there might not always be alerts to display.


105-115: LGTM: Good use of new properties and conditional logic

The changes to the data object in the fromInternalCaseResponse method are well-implemented. The addition of the hasBeenServed property and the conditional alerts array make good use of the new structures defined earlier in the file. The logic ensures that a success message is only added when the subpoena has been served, which is appropriate.


148-151: LGTM: Well-implemented additions to defenderInfo

The new properties canEdit and courtContactInfo in the defenderInfo object are well-implemented. The logic for setting these properties based on the canChangeDefenseChoice variable is appropriate. The use of the translation function for courtContactInfo is good for internationalization support.

@unakb unakb added the automerge Merge this PR as soon as all checks pass label Sep 24, 2024
@kodiakhq kodiakhq bot merged commit e8e70b8 into main Sep 24, 2024
39 checks passed
@kodiakhq kodiakhq bot deleted the j-s/digital-mailbox-info branch September 24, 2024 16:11
thoreyjona pushed a commit that referenced this pull request Oct 2, 2024
)

* feat(j-s): Return acknowledged info for case in digital mailbox API

* feat(j-s): New info and cleanup for law and order

* Update subpoena.response.ts

* Update subpoena.response.ts

* Change tags and messages to enums

* Update case.response.ts

* fix(j-s): Added subtitle for subpoena response

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
@coderabbitai coderabbitai bot mentioned this pull request Oct 4, 2024
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Merge this PR as soon as all checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants