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): Display connected indictment case files #15526

Merged
merged 10 commits into from
Jul 18, 2024
Merged

Conversation

unakb
Copy link
Member

@unakb unakb commented Jul 16, 2024

Birta skjöl úr sameinuðum málum á aðalmáli

What

Display case files from connected indictment cases on the court overview screen

Screenshots / Gifs

image image

Checklist:

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

Summary by CodeRabbit

  • New Features

    • Introduced a "Connected Case Files" accordion item for displaying related case files in the judicial system web application.
    • Enhanced case querying to include additional conditions and associations for merged cases, filtering by completed state and including related entities.
  • Enhancements

    • Updated the IndictmentCaseFilesList component to support optional heading display.
    • Added new data sections in the InfoCardActiveIndictment component for merged cases, including detailed case information.
  • Internationalization

    • Added new internationalized strings for components and messages related to connected case files and merged cases.
  • GraphQL

    • Extended the mergedCases query to include more detailed fields like case type, court, judge, prosecutor, prosecutor's office, and case files.
  • UI/UX

    • Updated the IndictmentOverview component to display the new "Connected Case Files" accordion item for merged cases.

@unakb unakb requested a review from a team as a code owner July 16, 2024 22:10
Copy link
Contributor

coderabbitai bot commented Jul 16, 2024

Walkthrough

The recent changes enhance the judicial system's backend and frontend by adding more detailed querying and presentation of merged cases. The backend now filters and includes conditions for completed cases, while the frontend introduces new components and internationalized strings to display connected case files and merged case details. Additionally, GraphQL queries have been extended to retrieve more comprehensive information about cases.

Changes

File Path Change Summary
.../case.service.ts Updated CaseService to include extra conditions and associations for querying merged cases, focusing on completed cases and related entities.
.../ConnectedCaseFilesAccordionItem.strings.ts Introduced internationalized strings for the connected case files accordion item.
.../ConnectedCaseFilesAccordionItem.tsx Added ConnectedCaseFilesAccordionItem component to render an accordion item for connected case files with internationalization support.
.../case.graphql Added new fields to the mergedCases query in the Case GraphQL query for expanded details.
.../IndictmentCaseFilesList.tsx Updated IndictmentCaseFilesList component to conditionally render its heading based on a new displayHeading prop.
.../InfoCardActiveIndictment.tsx Enhanced InfoCardActiveIndictment component to display additional sections for merged cases.
.../InfoCardIndictment.strings.ts Added a new string entry for "Sameinað úr" in the InfoCardIndictment strings.
.../index.ts Added export for ConnectedCaseFilesAccordionItem and modified exports for RenderFiles and CheckboxList.
.../Overview.tsx Incorporated ConnectedCaseFilesAccordionItem component into the IndictmentOverview to display merged cases if available.

Sequence Diagrams

Displaying Connected Case Files in Indictments

sequenceDiagram
    participant User
    participant WebApp
    participant Backend
    participant Database

    User->>WebApp: Access Indictments Overview
    WebApp->>Backend: Fetch Case Details
    Backend->>Database: Query for Case and Merged Cases
    Database-->>Backend: Return Case and Merged Cases Data
    Backend-->>WebApp: Send Case and Merged Cases Data

    WebApp->>WebApp: Render IndictmentOverview
    WebApp->>WebApp: Check for Merged Cases
    WebApp-->>User: Display Indictment Overview with Connected Case Files
Loading

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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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

Outside diff range, codebase verification and nitpick comments (1)
apps/judicial-system/web/src/components/index.ts (1)

57-57: Syntax Adjustment in Export

The addition of an extra comma in the export of RenderFiles is a minor change and does not affect the functionality. However, ensure this change is intentional and consistent with coding standards.

- export { RenderFiles,  }
+ export { RenderFiles }
Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 143c0e0 and 5960365.

Files selected for processing (9)
  • apps/judicial-system/backend/src/app/modules/case/case.service.ts (1 hunks)
  • apps/judicial-system/web/src/components/AccordionItems/ConnectedCaseFilesAccordionItem/ConnectedCaseFilesAccordionItem.strings.ts (1 hunks)
  • apps/judicial-system/web/src/components/AccordionItems/ConnectedCaseFilesAccordionItem/ConnectedCaseFilesAccordionItem.tsx (1 hunks)
  • apps/judicial-system/web/src/components/FormProvider/case.graphql (1 hunks)
  • apps/judicial-system/web/src/components/IndictmentCaseFilesList/IndictmentCaseFilesList.tsx (3 hunks)
  • apps/judicial-system/web/src/components/InfoCard/InfoCardActiveIndictment.tsx (1 hunks)
  • apps/judicial-system/web/src/components/InfoCard/InfoCardIndictment.strings.ts (1 hunks)
  • apps/judicial-system/web/src/components/index.ts (2 hunks)
  • apps/judicial-system/web/src/routes/Court/Indictments/Overview/Overview.tsx (2 hunks)
Additional context used
Path-based instructions (9)
apps/judicial-system/web/src/components/AccordionItems/ConnectedCaseFilesAccordionItem/ConnectedCaseFilesAccordionItem.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/AccordionItems/ConnectedCaseFilesAccordionItem/ConnectedCaseFilesAccordionItem.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/judicial-system/web/src/components/InfoCard/InfoCardIndictment.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/InfoCard/InfoCardActiveIndictment.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/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."
apps/judicial-system/web/src/routes/Court/Indictments/Overview/Overview.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/judicial-system/web/src/components/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/components/IndictmentCaseFilesList/IndictmentCaseFilesList.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/judicial-system/backend/src/app/modules/case/case.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."
Learnings (1)
apps/judicial-system/web/src/routes/Court/Indictments/Overview/Overview.tsx (1)
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-06-27T14:37:07.823Z
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.
Biome
apps/judicial-system/web/src/routes/Court/Indictments/Overview/Overview.tsx

[error] 110-110: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)

Additional comments not posted (9)
apps/judicial-system/web/src/components/AccordionItems/ConnectedCaseFilesAccordionItem/ConnectedCaseFilesAccordionItem.strings.ts (1)

3-10: Internationalization strings defined correctly.

The strings for the accordion heading are well-defined with appropriate IDs and descriptions.

apps/judicial-system/web/src/components/AccordionItems/ConnectedCaseFilesAccordionItem/ConnectedCaseFilesAccordionItem.tsx (1)

1-39: Component structure and logic are correctly implemented.

The ConnectedCaseFilesAccordionItem component is well-structured and follows best practices for React and TypeScript. The handling of empty data cases and the use of internationalization are appropriate.

Verification successful

Component structure and logic are correctly implemented.

The ConnectedCaseFilesAccordionItem component is well-structured and follows best practices for React and TypeScript. The handling of empty data cases and the use of internationalization are appropriate. The import paths and usage of external components are correctly implemented.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correct import paths and usage of external components.

# Test: Search for import paths in the project to ensure they are correct.
rg --type typescript --files-with-matches 'ConnectedCaseFilesAccordionItem' | xargs rg 'from .*ConnectedCaseFilesAccordionItem'

Length of output: 544

apps/judicial-system/web/src/components/InfoCard/InfoCardIndictment.strings.ts (1)

61-65: New internationalization string correctly added.

The mergedFromTitle string is well-defined and consistent with the existing internationalization practices in the project.

apps/judicial-system/web/src/components/InfoCard/InfoCardActiveIndictment.tsx (1)

Line range hint 1-102: Enhancements to display merged case details are correctly implemented.

The additional sections for merged cases in the InfoCardActiveIndictment component are well-integrated and enhance the component's functionality by providing more detailed information.

Verification successful

Line range hint 1-102: Enhancements to display merged case details are correctly implemented.

The additional sections for merged cases in the InfoCardActiveIndictment component are well-integrated and enhance the component's functionality by providing more detailed information. The handling of potentially undefined values for mergedCases is properly managed throughout the codebase.

  • apps/judicial-system/web/src/routes/Court/Indictments/Overview/Overview.tsx: mergedCases is checked before access.
  • apps/judicial-system/web/src/components/InfoCard/InfoCardActiveIndictment.tsx: mergedCases is checked before access.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the handling of potentially undefined values in the data structure.

# Test: Search for usage of mergedCases in the project to ensure it's always properly checked before access.
rg --type typescript 'mergedCases' | xargs rg 'if.*mergedCases'

Length of output: 98


Script:

#!/bin/bash
# Description: Verify the handling of potentially undefined values in the data structure.

# Test: Search for usage of mergedCases in the project to ensure it's always properly checked before access.
rg --type ts 'mergedCases' | xargs rg 'if.*mergedCases'

Length of output: 2068


Script:

#!/bin/bash
# Description: Verify the handling of potentially undefined values in the data structure.

# Test: Search for usage of mergedCases in the project to ensure it's always properly checked before access.
rg --type ts 'mergedCases' -A 5

Length of output: 2699

apps/judicial-system/web/src/components/FormProvider/case.graphql (1)

278-308: Review of GraphQL Query Enhancements

The additions to the mergedCases query include various details such as type, court, judge, prosecutor, prosecutorsOffice, caseFiles, policeCaseNumbers, and indictmentSubtypes. These fields are essential for providing comprehensive case details in the court overview screen.

  • Ensure that all new fields are supported by the backend schema and are correctly fetched.
  • The structure and naming conventions used are consistent with the existing GraphQL schema, which is good for maintainability.
  • Consider adding descriptions for these fields in the GraphQL schema if not already present, to improve the readability and understandability of the schema.
apps/judicial-system/web/src/routes/Court/Indictments/Overview/Overview.tsx (1)

21-21: Import of ConnectedCaseFilesAccordionItem

The import statement for ConnectedCaseFilesAccordionItem is correctly placed and follows the project's conventions. This component is crucial for displaying connected case files in the UI.

apps/judicial-system/web/src/components/index.ts (1)

13-13: Export of ConnectedCaseFilesAccordionItem

The new export for ConnectedCaseFilesAccordionItem is added correctly. This allows other parts of the application to import and use this component efficiently.

apps/judicial-system/web/src/components/IndictmentCaseFilesList/IndictmentCaseFilesList.tsx (1)

31-31: Enhancement to IndictmentCaseFilesList Component

The addition of the displayHeading property to the Props interface and its default setting in the component function are implemented correctly. This allows for more flexible UI rendering based on the component's usage context.

  • The use of a default parameter for displayHeading ensures that existing usages of the component will not be affected by this change, which is a good practice for backward compatibility.

Also applies to: 63-64

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

305-323: Review of the updated query for merged cases in CaseService.

The updated query for merged cases now filters by CaseState.COMPLETED and includes multiple related entities with specific conditions. This is a significant enhancement as it allows for more precise and relevant data retrieval, which is crucial for the feature of displaying connected indictment case files.

  • Correctness: The query correctly filters merged cases by their completion state and ensures that deleted case files are excluded. This is crucial for data integrity and user experience.
  • Performance: The use of separate: true in the associations is a good practice in Sequelize when dealing with potentially large datasets, as it prevents the generation of massive single SQL queries that could degrade performance.
  • Security: No sensitive data seems to be exposed directly; however, ensure that all data used in this context is properly authorized at higher levels of the application.
  • Maintainability: The query is structured and readable. Using named associations like 'court', 'judge', 'prosecutor', and 'prosecutorsOffice' helps in understanding the relational context quickly.

Suggestions:

  • Testing: Ensure that there are comprehensive tests covering these new query conditions, particularly focusing on edge cases where data might not fit expected norms.
  • Documentation: Update the documentation to reflect these changes and how they affect the data retrieval process. This is especially important for new developers or external teams who might interact with this service.

Overall, the changes are well-implemented and align with the requirements specified in the PR description.

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

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 5960365 and 3479fe0.

Files selected for processing (1)
  • apps/judicial-system/web/src/components/index.ts (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • apps/judicial-system/web/src/components/index.ts

Copy link

codecov bot commented Jul 16, 2024

Codecov Report

Attention: Patch coverage is 18.75000% with 13 lines in your changes missing coverage. Please review.

Project coverage is 37.02%. Comparing base (aba1949) to head (0928c80).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #15526      +/-   ##
==========================================
- Coverage   37.02%   37.02%   -0.01%     
==========================================
  Files        6558     6560       +2     
  Lines      134045   134060      +15     
  Branches    38349    38356       +7     
==========================================
+ Hits        49628    49630       +2     
- Misses      84417    84430      +13     
Flag Coverage Δ
judicial-system-backend 55.98% <ø> (ø)
judicial-system-web 28.11% <18.75%> (-0.02%) ⬇️

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

Files Coverage Δ
...ystem/backend/src/app/modules/case/case.service.ts 90.82% <ø> (ø)
...ionItem/ConnectedCaseFilesAccordionItem.strings.ts 100.00% <100.00%> (ø)
...ndictmentCaseFilesList/IndictmentCaseFilesList.tsx 3.57% <20.00%> (-0.28%) ⬇️
...src/routes/Court/Indictments/Overview/Overview.tsx 0.00% <0.00%> (ø)
...sAccordionItem/ConnectedCaseFilesAccordionItem.tsx 16.66% <16.66%> (ø)

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 aba1949...0928c80. Read the comment docs.

@datadog-island-is
Copy link

datadog-island-is bot commented Jul 16, 2024

Datadog Report

All test runs 39ae59d 🔗

2 Total Test Services: 0 Failed, 2 Passed
➡️ Test Sessions change in coverage: 2 no change

Test Services
Service Name Failed Known Flaky New Flaky Passed Skipped Total Time Code Coverage Change Test Service View
judicial-system-backend 0 0 0 20003 0 18m 34.1s 1 no change Link
judicial-system-web 0 0 0 326 0 1m 13.24s 1 no change Link

…/Overview.tsx

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
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

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 3479fe0 and 3853745.

Files selected for processing (1)
  • apps/judicial-system/web/src/routes/Court/Indictments/Overview/Overview.tsx (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • apps/judicial-system/web/src/routes/Court/Indictments/Overview/Overview.tsx

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

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 3853745 and c7404b1.

Files selected for processing (2)
  • apps/judicial-system/web/src/components/AccordionItems/ConnectedCaseFilesAccordionItem/ConnectedCaseFilesAccordionItem.tsx (1 hunks)
  • apps/judicial-system/web/src/routes/Court/Indictments/Overview/Overview.tsx (2 hunks)
Files skipped from review as they are similar to previous changes (2)
  • apps/judicial-system/web/src/components/AccordionItems/ConnectedCaseFilesAccordionItem/ConnectedCaseFilesAccordionItem.tsx
  • apps/judicial-system/web/src/routes/Court/Indictments/Overview/Overview.tsx

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

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between c7404b1 and 0928c80.

Files selected for processing (1)
  • apps/judicial-system/backend/src/app/modules/case/case.service.ts (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • apps/judicial-system/backend/src/app/modules/case/case.service.ts

@unakb unakb added the automerge Merge this PR as soon as all checks pass label Jul 18, 2024
@kodiakhq kodiakhq bot merged commit 7a8d95c into main Jul 18, 2024
36 checks passed
@kodiakhq kodiakhq bot deleted the j-s/merged-case-files branch July 18, 2024 21:22
oskarjs pushed a commit that referenced this pull request Aug 20, 2024
* feat(j-s): Infocard for court for merged cases

* Update InfoCardActiveIndictment.tsx

* Update InfoCardActiveIndictment.tsx

* feat(j-s): CaseFiles for connected cases

* chore: nx format:write update dirty files

* Update apps/judicial-system/web/src/routes/Court/Indictments/Overview/Overview.tsx

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* fix(j-s): Linting

* Update case.service.ts

---------

Co-authored-by: andes-it <builders@andes.is>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: Guðjón Guðjónsson <gudjon@kolibri.is>
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.

3 participants