Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

fix(j-s): Indictment Appeal #15906

Merged
merged 6 commits into from
Sep 9, 2024
Merged

fix(j-s): Indictment Appeal #15906

merged 6 commits into from
Sep 9, 2024

Conversation

gudjong
Copy link
Member

@gudjong gudjong commented Sep 5, 2024

Indictment Appeal

Ríksak - áfríunarfrestur ákærða fyrir viðurlagaákvörðun
Þegar ekki er þörf á að birta dóm þá er birtingastaða á málalista "óbirt". Ætti að vera fullunnið
Laga aðgang FMST að ákærum með marga varnaraðila

What

  • Only show indictment verdict view info and button on public prosecutors office case overview if the case ended in a verdict.
  • Fixes the indictment verdict review status on public prosecutors office case lists when the defendant does not need to see the verdict and therefore does not have a review deadline.
  • Fixes FMST case access. It should only see cases that end with a verdict and it does not have to wait for an appeal deadline to expire for defendants that don't need to see the verdict.
  • Some simplifications and cleanup.

Why

  • Verified bugs.

Screenshots / Gifs

Public Prosecutors Office Case Overview

image

Public Prosecutors Office Case List

image

FMST Case List

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

    • Enhanced case processing with additional properties for specific case types.
    • Introduced new logic for determining appeal deadlines using boolean flags.
    • Improved conditional rendering in UI components based on case status.
  • Bug Fixes

    • Resolved inconsistencies in handling appeal deadline statuses across various modules.
  • Documentation

    • Updated GraphQL queries to reflect changes in field names and meanings.
  • Refactor

    • Streamlined code structure for better readability and maintainability in case transformation logic.

Copy link
Contributor

coderabbitai bot commented Sep 5, 2024

Walkthrough

The changes involve modifications to the judicial system's API and frontend components, primarily focusing on the handling and representation of case attributes related to appeal deadlines. Key updates include renaming fields and functions to reflect their new semantics, introducing conditional logic for case processing, and enhancing the structure of test cases. Overall, the updates aim to improve clarity and maintainability in both the backend and frontend systems.

Changes

Files Change Summary
apps/judicial-system/api/src/app/modules/case-list/interceptors/caseList.interceptor.ts Introduced logic to handle specific case types with additional properties for appeal deadlines.
apps/judicial-system/api/src/app/modules/case-list/models/caseList.model.ts Changed indictmentVerdictAppealDeadline from a nullable string to a nullable boolean named indictmentVerdictAppealDeadlineExpired.
apps/judicial-system/api/src/app/modules/case/interceptors/case.transformer.spec.ts Enhanced test cases by adding type property to theCase objects and modifying parameters for getIndictmentInfo. Introduced getDefendantsInfo function for handling appeal deadlines.
apps/judicial-system/api/src/app/modules/case/interceptors/case.transformer.ts Renamed types and functions, updated IndictmentInfo interface, and introduced transformRequestCase function for handling request cases. Refactored transformCase for better modularity.
apps/judicial-system/api/src/app/modules/case/models/case.model.ts Changed indictmentVerdictAppealDeadline to indictmentVerdictAppealDeadlineExpired, updating its type to nullable boolean.
apps/judicial-system/backend/src/app/modules/case/filters/case.filter.ts Updated method for determining appeal deadline status to use getIndictmentVerdictAppealDeadlineStatus, altering data processing structure.
apps/judicial-system/web/src/components/FormProvider/case.graphql Renamed field indictmentVerdictAppealDeadline to indictmentVerdictAppealDeadlineExpired.
apps/judicial-system/web/src/routes/PublicProsecutor/Indictments/Overview/Overview.tsx Enhanced conditional logic for action buttons and appeal expiration info based on workingCase.indictmentRulingDecision.
apps/judicial-system/web/src/routes/PublicProsecutor/Tables/CasesReviewed.tsx Updated logic to check row.indictmentVerdictAppealDeadlineExpired instead of using the current date for appeal deadline status.
apps/judicial-system/web/src/routes/Shared/Cases/cases.graphql Renamed field indictmentVerdictAppealDeadline to indictmentVerdictAppealDeadlineExpired.
libs/judicial-system/types/src/index.ts Renamed exported function from getIndictmentVerdictAppealDeadline to getIndictmentVerdictAppealDeadlineStatus.
libs/judicial-system/types/src/lib/indictmentCase.ts Renamed function to getIndictmentVerdictAppealDeadlineStatus, changing its input and output types to provide a tuple of booleans regarding appeal status.
libs/judicial-system/types/src/lib/indictmentCase.spec.ts Updated tests for getIndictmentVerdictAppealDeadlineStatus to reflect changes in expected output format, ensuring accurate testing of the new boolean status representation.
apps/judicial-system/backend/src/app/modules/case/filters/cases.filter.ts Streamlined user role checks and case query filters, renaming isArchived to is_archived for consistency and introducing a new function for prison admin users.
apps/judicial-system/backend/src/app/modules/case/filters/test/cases.filter.spec.ts Updated tests to reflect the renaming of isArchived to is_archived and simplified query conditions for case types.
apps/judicial-system/backend/src/app/modules/case/filters/test/prisonAdminUserFilter.spec.ts Added unit tests for access control for prison admin users, validating permissions based on case types and states.
apps/judicial-system/backend/src/app/modules/case/filters/test/prisonStaffUserFilter.spec.ts Introduced unit tests for prison staff user access control, ensuring appropriate permissions for various case attributes.
apps/judicial-system/backend/src/app/modules/file/guards/viewCaseFile.guard.ts Removed checks for isPrisonSystemUser, simplifying access control logic to focus on prosecution and public prosecutor users.

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

codecov bot commented Sep 5, 2024

Codecov Report

Attention: Patch coverage is 82.56881% with 19 lines in your changes missing coverage. Please review.

Project coverage is 36.83%. Comparing base (d1fbbda) to head (c668f00).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...les/case-list/interceptors/caseList.interceptor.ts 0.00% 5 Missing ⚠️
...PublicProsecutor/Indictments/Overview/Overview.tsx 0.00% 5 Missing ⚠️
...ackend/src/app/modules/case/filters/case.filter.ts 91.17% 3 Missing ⚠️
...src/app/modules/case-list/models/caseList.model.ts 0.00% 2 Missing ⚠️
...stem/api/src/app/modules/case/models/case.model.ts 0.00% 2 Missing ⚠️
...c/routes/PublicProsecutor/Tables/CasesReviewed.tsx 0.00% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #15906      +/-   ##
==========================================
+ Coverage   36.81%   36.83%   +0.02%     
==========================================
  Files        6693     6693              
  Lines      137122   137128       +6     
  Branches    38975    38975              
==========================================
+ Hits        50476    50506      +30     
+ Misses      86646    86622      -24     
Flag Coverage Δ
air-discount-scheme-backend 54.03% <ø> (ø)
air-discount-scheme-web 0.00% <ø> (ø)
api 3.39% <ø> (ø)
api-domains-air-discount-scheme 36.75% <ø> (ø)
api-domains-assets 26.71% <ø> (ø)
api-domains-auth-admin 53.90% <ø> (ø)
api-domains-communications 40.51% <ø> (ø)
api-domains-criminal-record 47.77% <ø> (ø)
api-domains-driving-license 44.31% <ø> (ø)
api-domains-education 31.22% <ø> (ø)
api-domains-health-insurance 34.58% <ø> (ø)
api-domains-mortgage-certificate 35.73% <ø> (ø)
api-domains-payment-schedule 41.05% <ø> (ø)
application-api-files 57.49% <ø> (ø)
application-core 72.20% <ø> (-0.09%) ⬇️
application-system-api 41.66% <ø> (ø)
application-template-api-modules 23.49% <ø> (-0.02%) ⬇️
application-templates-accident-notification 19.83% <ø> (ø)
application-templates-car-recycling 3.12% <ø> (ø)
application-templates-criminal-record 22.12% <ø> (ø)
application-templates-driving-license 15.96% <ø> (ø)
application-templates-estate 11.86% <ø> (ø)
application-templates-example-payment 20.79% <ø> (ø)
application-templates-financial-aid 12.09% <ø> (ø)
application-templates-general-petition 18.86% <ø> (ø)
application-templates-health-insurance 23.27% <ø> (ø)
application-templates-inheritance-report 4.63% <ø> (ø)
application-templates-marriage-conditions 10.47% <ø> (ø)
application-templates-mortgage-certificate 44.03% <ø> (ø)
application-templates-parental-leave 28.40% <ø> (ø)
application-types 6.74% <ø> (ø)
application-ui-components 1.52% <ø> (ø)
application-ui-shell 21.08% <ø> (ø)
auth-react 22.82% <ø> (ø)
clients-charge-fjs-v2 24.11% <ø> (ø)
clients-driving-license 40.62% <ø> (ø)
clients-driving-license-book 43.85% <ø> (ø)
clients-financial-statements-inao 49.10% <ø> (ø)
clients-license-client 1.83% <ø> (ø)
clients-middlewares 72.36% <ø> (-0.35%) ⬇️
clients-regulations 42.54% <ø> (ø)
clients-rsk-company-registry 29.76% <ø> (ø)
clients-syslumenn 49.75% <ø> (ø)
cms 0.42% <ø> (ø)
cms-translations 39.66% <ø> (ø)
contentful-apps 6.05% <ø> (ø)
download-service 44.51% <ø> (ø)
financial-aid-backend 56.48% <ø> (ø)
financial-aid-shared 19.03% <ø> (ø)
island-ui-core 28.59% <ø> (ø)
judicial-system-api 19.35% <84.21%> (+1.03%) ⬆️
judicial-system-backend 55.97% <81.03%> (+0.02%) ⬆️
judicial-system-formatters 79.83% <15.38%> (-0.29%) ⬇️
judicial-system-message 66.79% <ø> (ø)
judicial-system-message-handler 47.61% <ø> (ø)
judicial-system-scheduler 68.98% <15.38%> (-0.19%) ⬇️
judicial-system-types 48.34% <92.30%> (+0.27%) ⬆️
judicial-system-web 28.71% <5.26%> (-0.01%) ⬇️
license-api 42.82% <ø> (+0.01%) ⬆️
portals-admin-regulations-admin 1.96% <ø> (ø)
portals-core 16.14% <ø> (ø)
services-auth-admin-api 51.01% <ø> (ø)
services-auth-delegation-api 61.50% <ø> (-0.08%) ⬇️
services-auth-ids-api 53.80% <ø> (ø)
services-auth-personal-representative 48.00% <ø> (-0.04%) ⬇️
services-auth-personal-representative-public 43.93% <ø> (ø)
services-auth-public-api 51.89% <ø> (ø)
services-endorsements-api 54.94% <ø> (ø)
services-university-gateway 48.42% <ø> (+0.02%) ⬆️
services-user-notification 47.69% <ø> (+<0.01%) ⬆️
services-user-profile 62.22% <ø> (ø)
shared-components 27.65% <ø> (ø)
shared-form-fields 31.58% <ø> (ø)
shared-utils 29.26% <ø> (ø)
web 1.85% <ø> (ø)

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

Files with missing lines Coverage Δ
.../app/modules/case/interceptors/case.transformer.ts 100.00% <100.00%> (+23.17%) ⬆️
...ckend/src/app/modules/case/filters/cases.filter.ts 97.91% <100.00%> (-0.13%) ⬇️
.../src/app/modules/file/guards/viewCaseFile.guard.ts 100.00% <ø> (+9.37%) ⬆️
libs/judicial-system/types/src/index.ts 100.00% <100.00%> (ø)
...bs/judicial-system/types/src/lib/indictmentCase.ts 100.00% <100.00%> (ø)
...src/app/modules/case-list/models/caseList.model.ts 0.00% <0.00%> (ø)
...stem/api/src/app/modules/case/models/case.model.ts 0.00% <0.00%> (ø)
...c/routes/PublicProsecutor/Tables/CasesReviewed.tsx 0.00% <0.00%> (ø)
...ackend/src/app/modules/case/filters/case.filter.ts 91.03% <91.17%> (+2.79%) ⬆️
...les/case-list/interceptors/caseList.interceptor.ts 0.00% <0.00%> (ø)
... and 1 more

... and 1 file with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d1fbbda...c668f00. Read the comment docs.

@datadog-island-is
Copy link

datadog-island-is bot commented Sep 5, 2024

Datadog Report

All test runs eb1fe0e 🔗

73 Total Test Services: 0 Failed, 71 Passed
🔻 Test Sessions change in coverage: 7 decreased, 4 increased, 189 no change

Test Services
This report shows up to 10 services
Service Name Failed Known Flaky New Flaky Passed Skipped Total Time Code Coverage Change Test Service View
air-discount-scheme-backend 0 0 0 81 0 31.11s N/A Link
air-discount-scheme-web 0 0 0 2 0 7.99s N/A Link
api 0 0 0 4 0 2.97s N/A Link
api-domains-air-discount-scheme 0 0 0 6 0 19.89s N/A Link
api-domains-assets 0 0 0 3 0 13.11s 1 no change Link
api-domains-auth-admin 0 0 0 18 0 13.73s N/A Link
api-domains-communications 0 0 0 5 0 32.88s 1 no change Link
api-domains-criminal-record 0 0 0 5 0 10s 1 no change Link
api-domains-driving-license 0 0 0 23 0 30.1s N/A Link
api-domains-education 0 0 0 8 0 20.01s 1 no change Link

🔻 Code Coverage Decreases vs Default Branch (7)

This report shows up to 5 code coverage decreases.

  • judicial-system-formatters - jest 88.12% (-0.36%) - Details
  • services-auth-delegation-api - jest 60.11% (-0.26%) - Details
  • judicial-system-scheduler - jest 74.95% (-0.22%) - Details
  • clients-middlewares - jest 75.05% (-0.2%) - Details
  • judicial-system-xrd-api - jest 75.81% (-0.19%) - Details

@gudjong gudjong marked this pull request as ready for review September 5, 2024 16:21
@gudjong gudjong requested a review from a team as a code owner September 5, 2024 16:21
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: 4

Outside diff range, codebase verification and nitpick comments (5)
libs/judicial-system/types/src/lib/indictmentCase.ts (1)

3-10: Review the function documentation for clarity and completeness.

The documentation clearly explains the input and output of the function. However, it could be enhanced by specifying what constitutes an "appeal deadline" and under what conditions it is considered "expired".

Consider adding more details to the documentation to improve clarity for future maintainers or developers unfamiliar with the context.

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

83-83: Update Test Files to Reflect Function Renaming

The function getIndictmentVerdictAppealDeadline has been renamed to getIndictmentVerdictAppealDeadlineStatus, but the test file libs/judicial-system/types/src/lib/indictmentCase.spec.ts still uses the old function name. Please update the test file to ensure consistency and correct test coverage.

  • Update libs/judicial-system/types/src/lib/indictmentCase.spec.ts to use getIndictmentVerdictAppealDeadlineStatus.
Analysis chain

Approved: Function renaming for clarity.

The renaming of getIndictmentVerdictAppealDeadline to getIndictmentVerdictAppealDeadlineStatus enhances clarity and aligns with the PR objectives. However, it's crucial to verify that this change does not impact other parts of the application where the old function name was used.

Run the following script to verify the function usage:

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `getIndictmentVerdictAppealDeadline` match the new name.

# Test: Search for the old function usage. Expect: No occurrences of the old name.
rg --type ts -A 5 $'getIndictmentVerdictAppealDeadline'

Length of output: 6460

apps/judicial-system/api/src/app/modules/case/interceptors/case.transformer.ts (2)

104-129: Function Review: transformRequestCase

The introduction of transformRequestCase is a positive change, enhancing the modularity and clarity of handling request cases. The function effectively consolidates appeal-related fields and uses conditional logic to determine the state of various deadlines.

Consider refactoring the TODO comment at line 116 to a more actionable item or an issue tracker to ensure it is addressed.


132-166: Function Update: getIndictmentInfo

The updates to getIndictmentInfo, including the addition of the rulingDecision parameter and enhanced logic for handling verdict deadlines, significantly improve the function's ability to provide accurate and relevant information.

Consider adding more detailed comments to explain the logic behind the calculations and conditions, especially around lines 148-162, to improve maintainability and readability for future developers.

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

189-205: Refined access control logic for prison system users.

The updated logic in canPrisonSystemUserAccessCase now more accurately reflects the requirements for prison system users to access case information based on the indictment verdict and appeal deadlines. The use of a tuple to store verdict-related data is a smart approach to encapsulate necessary details.

However, consider adding comments to explain the tuple structure and the conditions checked, which could improve code readability and maintainability.

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between bd2eb08 and 6ae26de.

Files selected for processing (12)
  • apps/judicial-system/api/src/app/modules/case-list/interceptors/caseList.interceptor.ts (2 hunks)
  • apps/judicial-system/api/src/app/modules/case-list/models/caseList.model.ts (1 hunks)
  • apps/judicial-system/api/src/app/modules/case/interceptors/case.transformer.spec.ts (34 hunks)
  • apps/judicial-system/api/src/app/modules/case/interceptors/case.transformer.ts (4 hunks)
  • apps/judicial-system/api/src/app/modules/case/models/case.model.ts (1 hunks)
  • apps/judicial-system/backend/src/app/modules/case/filters/case.filter.ts (3 hunks)
  • apps/judicial-system/web/src/components/FormProvider/case.graphql (1 hunks)
  • apps/judicial-system/web/src/routes/PublicProsecutor/Indictments/Overview/Overview.tsx (3 hunks)
  • apps/judicial-system/web/src/routes/PublicProsecutor/Tables/CasesReviewed.tsx (1 hunks)
  • apps/judicial-system/web/src/routes/Shared/Cases/cases.graphql (1 hunks)
  • libs/judicial-system/types/src/index.ts (1 hunks)
  • libs/judicial-system/types/src/lib/indictmentCase.ts (1 hunks)
Additional context used
Path-based instructions (12)
libs/judicial-system/types/src/lib/indictmentCase.ts (1)

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

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
apps/judicial-system/web/src/routes/Shared/Cases/cases.graphql (1)

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

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

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

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

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

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
apps/judicial-system/api/src/app/modules/case-list/models/caseList.model.ts (1)

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

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/judicial-system/web/src/routes/PublicProsecutor/Tables/CasesReviewed.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/api/src/app/modules/case/interceptors/case.transformer.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/PublicProsecutor/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/backend/src/app/modules/case/filters/case.filter.ts (1)

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

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/judicial-system/api/src/app/modules/case/models/case.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/api/src/app/modules/case/interceptors/case.transformer.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."
Learnings (2)
apps/judicial-system/web/src/routes/PublicProsecutor/Tables/CasesReviewed.tsx (2)
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.
Learnt from: oddsson
PR: island-is/island.is#14673
File: apps/judicial-system/web/src/routes/PublicProsecutor/Tables/CasesForReview.tsx:79-79
Timestamp: 2024-05-06T23:16:04.892Z
Learning: The implementation of `mapIndictmentCaseStateToTagVariant` in `TagCaseState.tsx`, which maps only `CaseState.ACCEPTED` to a specific tag and defaults others to an "unknown" status, is intentional as per the application's requirements.
apps/judicial-system/web/src/routes/PublicProsecutor/Indictments/Overview/Overview.tsx (3)
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.
Learnt from: oddsson
PR: island-is/island.is#14673
File: apps/judicial-system/web/src/routes/PublicProsecutor/Tables/CasesForReview.tsx:79-79
Timestamp: 2024-05-06T23:16:04.892Z
Learning: The implementation of `mapIndictmentCaseStateToTagVariant` in `TagCaseState.tsx`, which maps only `CaseState.ACCEPTED` to a specific tag and defaults others to an "unknown" status, is intentional as per the application's requirements.
Learnt from: oddsson
PR: island-is/island.is#15461
File: apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.tsx:36-62
Timestamp: 2024-07-08T13:30:58.001Z
Learning: The user prefers readability over optimization in the `getAppealExpirationInfo` function within `DefendantInfo.tsx`.
Additional comments not posted (20)
libs/judicial-system/types/src/lib/indictmentCase.ts (3)

11-13: Function signature update is appropriate.

The function signature has been updated to accept an array of tuples, which is a suitable choice for the given requirements. The use of optional chaining and tuple types in TypeScript is correctly applied.


15-19: Logic to handle empty or non-appealable cases.

The function correctly returns [true, true] when there are no defendants or none can appeal, indicating that all deadlines have expired and all necessary views have occurred. This is a logical and efficient way to handle these edge cases.


22-28: Check for unviewed verdicts by appealable defendants.

The logic here correctly identifies if any appealable verdicts have not been viewed and returns [false, false]. This ensures that the system accurately reflects the status of the case review process.

apps/judicial-system/web/src/routes/Shared/Cases/cases.graphql (1)

94-94: Field Renaming: indictmentVerdictAppealDeadlineExpired

The renaming of the field from indictmentVerdictAppealDeadline to indictmentVerdictAppealDeadlineExpired is noted. This change suggests a shift in semantics from merely indicating a deadline to specifying whether the deadline has expired, which could significantly affect how this data is used in client applications.

Please ensure that all client-side code that consumes this query is updated to reflect the new field name. This includes checking any logic that depends on this field to ensure it correctly interprets the new semantics.

Consider adding a comment in the GraphQL schema or adjacent documentation to explain the reason for this semantic change, which could help developers understand the context and implications of using this field.

Verification successful

Field Renaming Verified: indictmentVerdictAppealDeadlineExpired

The renaming of the field from indictmentVerdictAppealDeadline to indictmentVerdictAppealDeadlineExpired has been successfully applied across the codebase. There are no remaining references to the old field name in the client-side code, ensuring consistency and preventing potential issues related to outdated references.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all occurrences of the old field name in client-side code.

# Test: Search for the old field name. Expect: No occurrences.
rg --type ts --type tsx 'indictmentVerdictAppealDeadline'

Length of output: 85


Script:

#!/bin/bash
# Description: Verify all occurrences of the old field name in client-side code.

# Corrected Test: Search for the old field name. Expect: No occurrences.
rg --type=ts --type=tsx 'indictmentVerdictAppealDeadline'

Length of output: 85


Script:

#!/bin/bash
# Description: Verify all occurrences of the old field name in client-side code using a different approach.

# Find all .ts and .tsx files and search for the old field name.
fd --extension ts --extension tsx --exec rg 'indictmentVerdictAppealDeadline'

Length of output: 795

apps/judicial-system/api/src/app/modules/case-list/interceptors/caseList.interceptor.ts (2)

11-12: Function getAppealedDate is correctly implemented.

The function uses a straightforward fallback mechanism to determine the appealedDate, which is a common and acceptable pattern.


44-51: Review the fallback logic for cases not requiring special handling.

The fallback logic using getIndictmentInfo is maintained, which ensures that existing functionality is preserved for cases not meeting the new criteria. This is a good practice as it ensures backward compatibility.

apps/judicial-system/api/src/app/modules/case-list/models/caseList.model.ts (1)

125-126: Field type and name change approved.

The change from a nullable string to a nullable boolean for indictmentVerdictAppealDeadlineExpired is appropriate and aligns with the PR objectives. This should simplify the logic for handling appeal deadlines.

Please ensure that the frontend correctly interprets this new boolean field, especially in conditional rendering or logic that previously depended on date string parsing.

apps/judicial-system/web/src/routes/PublicProsecutor/Tables/CasesReviewed.tsx (1)

Line range hint 1-100: Well-structured component with effective TypeScript usage.

The component is well-structured and follows React and NextJS best practices. The use of TypeScript for props typing and the integration of internationalization are effectively implemented. The dynamic generation of table content and context menu items based on the cases array is a good practice, enhancing the component's reusability and maintainability.

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

267-267: Confirm alignment with PR objectives and summary.

The renaming of the field indictmentVerdictAppealDeadline to indictmentVerdictAppealDeadlineExpired aligns with the PR objectives to correct the indictment verdict review status in case lists. This change ensures that the field now accurately reflects its purpose in the context of the application, enhancing clarity and maintainability.


267-267: Verify the usage of the renamed field across the application.

The field indictmentVerdictAppealDeadline has been renamed to indictmentVerdictAppealDeadlineExpired. This change implies a semantic shift from representing a deadline to indicating whether the deadline has expired. It is crucial to verify that all client-side logic that previously interacted with the old field name has been updated accordingly.

Run the following script to verify the usage of the new field name across the application:

apps/judicial-system/api/src/app/modules/case/interceptors/case.transformer.ts (3)

30-33: Interface Update: IndictmentInfo

The updates to the IndictmentInfo interface, including the addition of indictmentCompletedDate and the change to indictmentVerdictAppealDeadlineExpired, align well with the PR objectives to enhance clarity and maintainability.


187-197: Function Review: transformIndictmentCase

The refactoring of transformIndictmentCase to explicitly handle indictment cases and integrate other utility functions enhances the clarity and modularity of the code. This change aligns well with the PR objectives to improve the handling of case attributes.

The function is well-implemented and improves the structure of the codebase.


200-205: Function Review: transformCase

The refactoring of transformCase to delegate processing based on the case type is a significant improvement. This change enhances the clarity and maintainability of the code by clearly separating the logic for different case types.

This approach is in line with best practices for modularity and code clarity.

apps/judicial-system/web/src/routes/PublicProsecutor/Indictments/Overview/Overview.tsx (3)

28-28: Confirm the correct usage of new import CaseIndictmentRulingDecision.

The import of CaseIndictmentRulingDecision from the GraphQL schema is correctly used in the conditional logic within the InfoCardClosedIndictment component. This aligns with the PR's objective to improve the handling of indictment verdict information based on the case's ruling decision.


28-28: Review the main functional component Overview.

The Overview component is well-structured and follows best practices for React and NextJS applications. It effectively uses context for state management and conditional rendering based on the case's status. The component's interactions, such as handling verdict views and assigning reviewers, are appropriately managed.


141-158: Confirm the correct implementation of conditional logic in InfoCardClosedIndictment.

The conditional rendering of defendantInfoActionButton and displayAppealExpirationInfo based on workingCase.indictmentRulingDecision is correctly implemented. This change ensures that the UI components react appropriately to the case's ruling decision, aligning with the PR's objectives to enhance user experience and maintain system integrity.

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

6-9: Approved import changes.

The addition of CaseIndictmentRulingDecision and getIndictmentVerdictAppealDeadlineStatus aligns with the new logic requirements for handling indictment verdicts and appeal deadlines. These changes are necessary for the updated functionality.

Also applies to: 22-22

apps/judicial-system/api/src/app/modules/case/models/case.model.ts (1)

439-440: Review of the property change from string to boolean for appeal deadline

The change from a nullable string to a nullable boolean for the indictmentVerdictAppealDeadlineExpired property is a significant shift in how the appeal deadline is represented. This change simplifies the logic by directly indicating whether the deadline has expired, rather than requiring parsing and comparison of date strings.

Considerations:

  • Ensure that all parts of the application that interact with this property are updated to handle a boolean value instead of a date string.
  • Verify that the frontend and any serialization/deserialization logic are adjusted to accommodate this change.
  • Check if there are any database migrations needed as a result of this change, especially if the data type in the database is also being altered.

TypeScript and GraphQL Best Practices:

  • The use of nullable: true is appropriate here, considering that not all cases may have an appeal deadline.
  • Ensure that TypeScript interfaces or types that correspond to this model are updated to reflect the new boolean type.
apps/judicial-system/api/src/app/modules/case/interceptors/case.transformer.spec.ts (2)

6-9: Review of new imports and their usage.

The new imports CaseIndictmentRulingDecision, CaseType, and ServiceRequirement are correctly added and used in the test cases. This ensures that the tests are aligned with the new functionalities being tested.


17-17: Review of new function declarations in imports.

The addition of getDefendantsInfo and the modification of getIndictmentInfo are correctly declared. It's important to ensure that these functions are used appropriately in the test cases that follow.

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 6ae26de and de6a968.

Files selected for processing (1)
  • libs/judicial-system/types/src/lib/indictmentCase.spec.ts (1 hunks)
Additional context used
Path-based instructions (1)
libs/judicial-system/types/src/lib/indictmentCase.spec.ts (1)

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

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
Additional comments not posted (5)
libs/judicial-system/types/src/lib/indictmentCase.spec.ts (5)

1-1: Verify the import path.

Ensure that the import path for getIndictmentVerdictAppealDeadlineStatus correctly points to the updated function location. This is crucial for maintaining the integrity of the test suite.


3-6: Test case approved: Handling of no dates.

This test case correctly checks the function's behavior when no dates are provided, expecting [true, true]. It is well-implemented and aligns with the new functionality.


9-19: Test case approved: Handling of undefined dates.

This test case effectively checks the function's behavior when any dates are undefined, using multiple configurations to ensure robustness. The expectations are clearly defined and align with the new functionality.


22-28: Test case approved: Handling of mixed deadline statuses.

This test case correctly evaluates the function's behavior when some deadlines have not passed, expecting [true, false]. The setup and expectations are appropriate for the functionality being tested.


31-37: Test case approved: Handling of all passed deadlines.

This test case effectively tests the function's behavior when all deadlines have passed, expecting [true, true]. The test setup is well-chosen and aligns with the intended functionality.

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 de6a968 and 158914a.

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

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 158914a and 07fcda2.

Files selected for processing (6)
  • apps/judicial-system/backend/src/app/modules/case/filters/case.filter.ts (5 hunks)
  • apps/judicial-system/backend/src/app/modules/case/filters/cases.filter.ts (7 hunks)
  • apps/judicial-system/backend/src/app/modules/case/filters/test/cases.filter.spec.ts (12 hunks)
  • apps/judicial-system/backend/src/app/modules/case/filters/test/prisonAdminUserFilter.spec.ts (1 hunks)
  • apps/judicial-system/backend/src/app/modules/case/filters/test/prisonStaffUserFilter.spec.ts (1 hunks)
  • apps/judicial-system/backend/src/app/modules/file/guards/viewCaseFile.guard.ts (3 hunks)
Files skipped from review as they are similar to previous changes (1)
  • apps/judicial-system/backend/src/app/modules/case/filters/case.filter.ts
Additional context used
Path-based instructions (5)
apps/judicial-system/backend/src/app/modules/file/guards/viewCaseFile.guard.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/case/filters/test/prisonStaffUserFilter.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/backend/src/app/modules/case/filters/test/prisonAdminUserFilter.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/backend/src/app/modules/case/filters/cases.filter.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/case/filters/test/cases.filter.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."
Additional comments not posted (10)
apps/judicial-system/backend/src/app/modules/case/filters/cases.filter.ts (6)

30-34: Refactor and renaming approved.

The consolidation of the type variable and renaming of isArchived to is_archived enhance readability and maintain consistency across the codebase.

Also applies to: 36-37


76-80: Static filter implementation approved.

The function correctly implements the static filter for public prosecution user cases, including the consistent use of is_archived.


150-150: Static filter for appeals court approved.

The function correctly implements the static filter for appeals court user cases, handling complex conditions effectively.


Line range hint 170-185: Static filter for prison staff approved.

The function correctly implements the static filter for prison staff user cases, including the consistent use of is_archived.


187-214: Static filter for prison admin approved.

The function correctly implements the static filter for prison admin user cases, handling complex conditions effectively.


298-303: Role-based delegation approved.

The function correctly delegates to specific query filters based on the user's role, ensuring appropriate access control.

apps/judicial-system/backend/src/app/modules/case/filters/test/cases.filter.spec.ts (4)

7-7: Review of new import: CaseIndictmentRulingDecision

The import of CaseIndictmentRulingDecision from @island.is/judicial-system/types is aligned with the changes described in the PR summary, which involve handling specific case attributes more explicitly. This import is necessary for the new properties used in the test cases.


45-45: Consistent application of is_archived property

The renaming of isArchived to is_archived across various test cases enhances consistency with typical database naming conventions, which often use snake_case. This change is correctly applied in all instances where the property is used, ensuring uniformity in property access across the test suite.

Also applies to: 104-104, 156-156, 222-222, 260-260, 308-308, 337-337, 369-369, 413-413


46-52: Refactoring of type property conditions

The simplification of the type property conditions by directly incorporating it alongside other conditions, as seen in the changes, streamlines the query logic. This refactoring makes the test cases easier to read and maintain, particularly with the inclusion of indictmentCases and other case types in a more structured format.

Also applies to: 105-105, 156-156, 222-222, 260-260, 308-308, 337-337, 369-369, 413-413


384-393: Addition of indictment_ruling_decision and complex SQL query

The introduction of indictment_ruling_decision with a reference to CaseIndictmentRulingDecision.RULING in the test cases is a significant enhancement, aligning with the PR's objective to handle indictment cases more explicitly. The complex SQL query used to exclude certain cases based on verdict_view_date and service_requirement is well-crafted, ensuring that the test reflects the intended application logic accurately.

@gudjong gudjong added the automerge Merge this PR as soon as all checks pass label Sep 9, 2024
@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 9, 2024
@kodiakhq kodiakhq bot merged commit 3aa0c69 into main Sep 9, 2024
209 checks passed
@kodiakhq kodiakhq bot deleted the j-s/review-status-fix branch September 9, 2024 14:13
jonnigs pushed a commit that referenced this pull request Sep 12, 2024
* Fixes review status on case lists for the public prosecutors office

* Only shows indictment view info for indictments that end with a verdict

* Updates unit tests

* Fixes cases query for fmst

---------

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