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): Complete Cancellation #15154

Merged
merged 64 commits into from
Jun 11, 2024
Merged

feat(j-s): Complete Cancellation #15154

merged 64 commits into from
Jun 11, 2024

Conversation

gudjong
Copy link
Member

@gudjong gudjong commented Jun 9, 2024

Complete Cancellation

Afturköllun ákæru - dómstóll

What

  • Allows the district court to complete a case after a prosecutor asks for its cancellation.

Why

  • Part of the indictment flow.

Screenshots / Gifs

Screen.Recording.2024-06-09.at.17.52.42.mov

Checklist:

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

Summary by CodeRabbit

  • New Features

    • Added new message definition for postponed cases.
    • Introduced CourtDate component for rendering court date information.
    • Introduced CasesInProgressTable for displaying ongoing court cases.
    • Introduced CourtCaseNumberInput for handling court case number input and validation.
  • Bug Fixes

    • Updated text for the COMPLETE action from "Lokað" to "Lokið".
  • Refactor

    • Enhanced case state transitions to include WAITING_FOR_CANCELLATION.
    • Refactored FormProvider component for improved case handling.
    • Refactored CourtCaseNumber component to use FormContext.
    • Streamlined ActiveCases component for better state and event management.
    • Simplified error handling logic in useCase hook.
  • Style

    • Updated Table component to handle click events conditionally.

oddsson and others added 30 commits May 28, 2024 15:18
Copy link
Member

@oddsson oddsson left a comment

Choose a reason for hiding this comment

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

Just a couple of considerations and questions :)

coderabbitai[bot]
coderabbitai bot previously requested changes Jun 11, 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: 4

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 42664ca and 6cc32e2.

Files selected for processing (1)
  • apps/judicial-system/web/src/routes/Court/components/CasesInProgressTable/CasesInProgressTable.tsx (1 hunks)
Additional context used
Path-based instructions (1)
apps/judicial-system/web/src/routes/Court/components/CasesInProgressTable/CasesInProgressTable.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."

@gudjong gudjong dismissed coderabbitai[bot]’s stale review June 11, 2024 12:15

All requests handled

@gudjong gudjong requested a review from oddsson June 11, 2024 12:16
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

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 6cc32e2 and ab3f1fc.

Files selected for processing (3)
  • apps/judicial-system/web/src/components/Table/CourtDate/CourtDate.tsx (1 hunks)
  • apps/judicial-system/web/src/components/Table/Table.tsx (5 hunks)
  • apps/judicial-system/web/src/routes/Court/components/CasesInProgressTable/CasesInProgressTable.tsx (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • apps/judicial-system/web/src/routes/Court/components/CasesInProgressTable/CasesInProgressTable.tsx
Additional context used
Path-based instructions (2)
apps/judicial-system/web/src/components/Table/CourtDate/CourtDate.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/Table/Table.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."
Biome
apps/judicial-system/web/src/components/Table/Table.tsx

[error] 186-197: Enforce to have the onClick mouse event with the onKeyUp, the onKeyDown, or the onKeyPress keyboard event. (lint/a11y/useKeyWithClickEvents)

Actions triggered using mouse events should have corresponding keyboard events to account for keyboard-only navigation.

Copy link
Member

@oddsson oddsson left a comment

Choose a reason for hiding this comment

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

Two more import considerations

@gudjong gudjong requested a review from oddsson June 11, 2024 13:02
@oddsson oddsson added the automerge Merge this PR as soon as all checks pass label Jun 11, 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: 2

Outside diff range and nitpick comments (3)
apps/judicial-system/web/src/utils/hooks/useCase/index.ts (2)

Line range hint 370-370: Avoid using the delete operator for performance reasons.

+     updatesToCase.force = undefined

Line range hint 123-123: Optimize the use of spread syntax in accumulators.

+     Object.assign(currentUpdates, nextUpdates)
+     return currentUpdates
apps/judicial-system/web/src/routes/Shared/Cases/ActiveCases.tsx (1)

Line range hint 219-219: Mark JSX elements without children as self-closing for cleaner code.

+               <motion.tr />
Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between ab3f1fc and 2e49084.

Files selected for processing (4)
  • apps/judicial-system/web/src/routes/Court/components/CasesInProgressTable/CasesInProgressTable.tsx (1 hunks)
  • apps/judicial-system/web/src/routes/Court/components/CourtCaseNumber/CourtCaseNumberInput.tsx (1 hunks)
  • apps/judicial-system/web/src/routes/Shared/Cases/ActiveCases.tsx (9 hunks)
  • apps/judicial-system/web/src/utils/hooks/useCase/index.ts (5 hunks)
Files skipped from review as they are similar to previous changes (1)
  • apps/judicial-system/web/src/routes/Court/components/CasesInProgressTable/CasesInProgressTable.tsx
Additional context used
Path-based instructions (3)
apps/judicial-system/web/src/routes/Court/components/CourtCaseNumber/CourtCaseNumberInput.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/utils/hooks/useCase/index.ts (1)

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

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/judicial-system/web/src/routes/Shared/Cases/ActiveCases.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."
Biome
apps/judicial-system/web/src/utils/hooks/useCase/index.ts

[error] 370-370: Avoid the delete operator which can impact performance. (lint/performance/noDelete)

Unsafe fix: Use an undefined assignment instead.


[error] 123-123: Avoid the use of spread (...) syntax on accumulators. (lint/performance/noAccumulatingSpread)

Spread syntax should be avoided on accumulators (like those in .reduce) because it causes a time complexity of O(n^2).
Consider methods such as .splice or .push instead.

apps/judicial-system/web/src/routes/Shared/Cases/ActiveCases.tsx

[error] 219-219: JSX elements without children should be marked as self-closing. In JSX, it is valid for any element to be self-closing. (lint/style/useSelfClosingElements)

Unsafe fix: Use a SelfClosingElement instead

Additional comments not posted (1)
apps/judicial-system/web/src/utils/hooks/useCase/index.ts (1)

254-254: Use optional chaining to safely access properties on potentially undefined objects.

Likely invalid or redundant comment.

@kodiakhq kodiakhq bot merged commit 6b940d9 into main Jun 11, 2024
36 checks passed
@kodiakhq kodiakhq bot deleted the j-s/complete-cancellation branch June 11, 2024 14:19
sigruntg pushed a commit that referenced this pull request Jun 12, 2024
* Add POSTPONED_TO_VERDICT radio button

* Change Radio to Checkbox

* Add column to Case table -- IndictmentDecision

* Update IndictmentDecision

* Postponed until verdict tag in cases

* Disable subpoena screen if a case is postponed until verdict

* Add a postpone until verdict tag for defenders

* Checkpoint

* Checkpoint

* Merge

* Determining when step is valid when postponing until verdict

* Checkpoint

* Change all instances of Array<something> to something[]

* Only show InfoCard on summary page if indictment decison is POSTPONING_UNTIL_VERDICT

* Wipe courtDate out when postponing until verdict

* Move scheduled info card to overview page

* Save court date when postponing until verdict

* Checkpoint

* Fixing update functionality

* Fix case state on cases page

* Fix migration

* Add location to verdict date

* Cleanup

* Allow judges to remove set court date

* Added test

* Allows prosecutors to cancel submitted indictments

* Hides buttons when prosecutor has asked for cancellation

* Adds unit tests

* Updates unit tests

* Fixes unit tests

* Rewrite open case

* Adds modal for cancelling case

* Fixes back navigation

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

Co-authored-by: Ívar Oddsson <ivaroddsson@gmail.com>

* Refactors code

* Rewrites condition

* Completes cancellation

* Removes obsolete unit tests

* Fixes test helpers

* Simplifies code

* Simplifies code

* Improves imports

* Improves imports

* Improves imports

* Simplifies type

* Simplifies expressions

* Correct function declaration

---------

Co-authored-by: Ívar Oddsson <ivaroddsson@gmail.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
lodmfjord pushed a commit that referenced this pull request Jun 14, 2024
* Add POSTPONED_TO_VERDICT radio button

* Change Radio to Checkbox

* Add column to Case table -- IndictmentDecision

* Update IndictmentDecision

* Postponed until verdict tag in cases

* Disable subpoena screen if a case is postponed until verdict

* Add a postpone until verdict tag for defenders

* Checkpoint

* Checkpoint

* Merge

* Determining when step is valid when postponing until verdict

* Checkpoint

* Change all instances of Array<something> to something[]

* Only show InfoCard on summary page if indictment decison is POSTPONING_UNTIL_VERDICT

* Wipe courtDate out when postponing until verdict

* Move scheduled info card to overview page

* Save court date when postponing until verdict

* Checkpoint

* Fixing update functionality

* Fix case state on cases page

* Fix migration

* Add location to verdict date

* Cleanup

* Allow judges to remove set court date

* Added test

* Allows prosecutors to cancel submitted indictments

* Hides buttons when prosecutor has asked for cancellation

* Adds unit tests

* Updates unit tests

* Fixes unit tests

* Rewrite open case

* Adds modal for cancelling case

* Fixes back navigation

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

Co-authored-by: Ívar Oddsson <ivaroddsson@gmail.com>

* Refactors code

* Rewrites condition

* Completes cancellation

* Removes obsolete unit tests

* Fixes test helpers

* Simplifies code

* Simplifies code

* Improves imports

* Improves imports

* Improves imports

* Simplifies type

* Simplifies expressions

* Correct function declaration

---------

Co-authored-by: Ívar Oddsson <ivaroddsson@gmail.com>
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