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): Subpoena type decision on court overview screen #15432

Merged
merged 7 commits into from
Jul 4, 2024

Conversation

unakb
Copy link
Member

@unakb unakb commented Jul 3, 2024

Dómari geti tekið ákvörðun um tegund fyrirkalls á yfirliti máls

What

Allow judge to make subpoena type decision on Overview screen
Extracted subpoena type radio button in to separate component

Why

So that the judge can decide early on

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 SubpoenaType component to manage the rendering and interaction logic for selecting subpoena types for defendants.
  • Refactor

    • Simplified Subpoena.tsx by moving subpoena type handling to the new SubpoenaType component.
  • Enhancements

    • Enhanced defendant data handling by updating defendant state before navigation in Overview.tsx.
  • Improvements

    • Improved code organization and readability by restructuring the subpoena types logic into a dedicated component.

@unakb unakb requested a review from a team as a code owner July 3, 2024 13:47
Copy link
Contributor

coderabbitai bot commented Jul 3, 2024

Walkthrough

The changes primarily involve refactoring and restructuring components related to handling subpoena types for defendants within the judicial system web application. A new component SubpoenaType is introduced for better code organization and readability. Additionally, the logic for updating defendant data has been revamped to ensure a more streamlined and maintainable codebase.

Changes

Files Change Summary
apps/judicial-system/web/src/routes/Court/Indictments/Overview/Overview.tsx Addition of useDefendants import, added updateDefendantState and updateDefendant functions, modified handleNavigationTo.
apps/judicial-system/web/src/routes/Court/Indictments/Subpoena/Subpoena.tsx Refactored rendering of subpoena types using a separate SubpoenaType component. Removed unnecessary imports and styles.
apps/judicial-system/web/src/routes/Court/components/SubpoenaType/SubpoenaType.strings.ts Defined internationalized messages for different types of subpoenas used in prosecutor's flow.
apps/judicial-system/web/src/routes/Court/components/SubpoenaType/SubpoenaType.tsx Introduced SubpoenaType functional component to handle rendering and interaction logic for selecting subpoena types.
apps/judicial-system/web/src/routes/Court/components/index.ts Added export for the SubpoenaType component.

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

Outside diff range and nitpick comments (2)
apps/judicial-system/web/src/routes/Court/components/SubpoenaType/SubpoenaType.tsx (1)

40-44: Improve readability of SectionHeading component.

Consider using self-closing tags for components without children to improve readability.

- <SectionHeading
-   title={formatMessage(strings.title)}
-   required={required}
- />
+ <SectionHeading title={formatMessage(strings.title)} required={required} />
apps/judicial-system/web/src/routes/Court/Indictments/Subpoena/Subpoena.tsx (1)

Line range hint 35-57: Add error handling for updateDefendant promises.

The handleNavigationTo function should include error handling for the updateDefendant promises to ensure that any errors are properly handled.

- const allDataSentToServer = await Promise.all(promises)
+ try {
+   const allDataSentToServer = await Promise.all(promises)
+   if (!allDataSentToServer.every(Boolean)) {
+     return
+   }
+   router.push(`${destination}/${workingCase.id}`)
+ } catch (error) {
+   // Handle error (e.g., show a notification)
+   console.error('Error updating defendants:', error)
+ }
Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between ee2100d and a9955e9.

Files selected for processing (5)
  • apps/judicial-system/web/src/routes/Court/Indictments/Overview/Overview.tsx (3 hunks)
  • apps/judicial-system/web/src/routes/Court/Indictments/Subpoena/Subpoena.tsx (4 hunks)
  • apps/judicial-system/web/src/routes/Court/components/SubpoenaType/SubpoenaType.strings.ts (1 hunks)
  • apps/judicial-system/web/src/routes/Court/components/SubpoenaType/SubpoenaType.tsx (1 hunks)
  • apps/judicial-system/web/src/routes/Court/components/index.ts (1 hunks)
Files skipped from review due to trivial changes (2)
  • apps/judicial-system/web/src/routes/Court/components/SubpoenaType/SubpoenaType.strings.ts
  • apps/judicial-system/web/src/routes/Court/components/index.ts
Additional context used
Path-based instructions (3)
apps/judicial-system/web/src/routes/Court/components/SubpoenaType/SubpoenaType.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/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/routes/Court/Indictments/Subpoena/Subpoena.tsx (1)

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

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
Learnings (1)
apps/judicial-system/web/src/routes/Court/Indictments/Overview/Overview.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: unakb
PR: island-is/island.is#14712
File: apps/judicial-system/web/src/routes/PublicProsecutor/Indictments/Overview/IndictmentOverview.tsx:0-0
Timestamp: 2024-05-06T18:09:27.876Z
Learning: The judicial system application uses a toaster notification system to handle errors globally.
Additional comments not posted (11)
apps/judicial-system/web/src/routes/Court/components/SubpoenaType/SubpoenaType.tsx (3)

19-28: Props interface is well-defined.

The SubpoenaTypeProps interface covers all necessary props for the component.


30-38: Component definition looks good.

The SubpoenaType component is correctly defined as a functional component and uses the useIntl hook for internationalization.


101-101: Export statement looks good.

The SubpoenaType component is correctly exported as the default export.

apps/judicial-system/web/src/routes/Court/Indictments/Overview/Overview.tsx (4)

26-28: Imports look good.

The imports for useDefendants and SubpoenaType are correctly added.


36-36: useDefendants hook usage looks good.

The useDefendants hook is correctly used to get the updateDefendantState and updateDefendant functions.


111-123: SubpoenaType component usage looks good.

The SubpoenaType component is correctly used to render the subpoena type selection for each defendant.


124-124: Export statement looks good.

The IndictmentOverview component is correctly exported as the default export.

apps/judicial-system/web/src/routes/Court/Indictments/Subpoena/Subpoena.tsx (4)

31-31: Imports look good.

The import for the SubpoenaType component is correctly added.


113-123: SubpoenaType component usage looks good.

The SubpoenaType component is correctly used to render the subpoena type selection for each defendant.


125-125: Export statement looks good.

The Subpoena component is correctly exported as the default export.


Line range hint 1-124: Component logic looks good.

The remaining component logic, including hooks and UI components, is correctly implemented and follows best practices.

Copy link

codecov bot commented Jul 3, 2024

Codecov Report

Attention: Patch coverage is 0% with 26 lines in your changes missing coverage. Please review.

Project coverage is 37.01%. Comparing base (bd185f2) to head (4e361ec).
Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #15432      +/-   ##
==========================================
- Coverage   37.01%   37.01%   -0.01%     
==========================================
  Files        6540     6542       +2     
  Lines      133713   133739      +26     
  Branches    38253    38262       +9     
==========================================
+ Hits        49499    49503       +4     
- Misses      84214    84236      +22     
Flag Coverage Δ
air-discount-scheme-backend 54.04% <ø> (ø)
api 3.44% <ø> (ø)
application-system-api 41.85% <ø> (-0.02%) ⬇️
application-template-api-modules 23.89% <ø> (-0.16%) ⬇️
dokobit-signing 62.22% <ø> (ø)
judicial-system-backend 56.03% <ø> (ø)
judicial-system-message 66.26% <ø> (ø)
judicial-system-message-handler 66.04% <ø> (ø)
judicial-system-scheduler 58.04% <ø> (ø)
judicial-system-types 50.35% <ø> (ø)
judicial-system-web 28.24% <0.00%> (-0.04%) ⬇️
nest-swagger 51.71% <ø> (ø)
nova-sms 64.00% <ø> (ø)
services-auth-admin-api 51.11% <ø> (ø)
services-auth-delegation-api 61.61% <ø> (ø)
services-auth-ids-api 54.68% <ø> (+0.01%) ⬆️
services-auth-personal-representative 48.28% <ø> (ø)
services-auth-personal-representative-public 44.09% <ø> (-0.05%) ⬇️
services-auth-public-api 51.08% <ø> (ø)
services-documents 60.96% <ø> (ø)
services-endorsements-api 55.48% <ø> (ø)
services-sessions 65.42% <ø> (ø)
shared-form-fields 31.93% <ø> (ø)
shared-mocking 64.62% <ø> (ø)
shared-pii 92.85% <ø> (ø)
shared-problem 87.50% <ø> (ø)
shared-utils 29.87% <ø> (ø)

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

Files Coverage Δ
...rt/components/SubpoenaType/SubpoenaType.strings.ts 0.00% <0.00%> (ø)
...src/routes/Court/Indictments/Subpoena/Subpoena.tsx 0.00% <0.00%> (ø)
...src/routes/Court/Indictments/Overview/Overview.tsx 0.00% <0.00%> (ø)
...tes/Court/components/SubpoenaType/SubpoenaType.tsx 0.00% <0.00%> (ø)

... and 6 files 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 2ca7aa6...4e361ec. Read the comment docs.

@datadog-island-is
Copy link

datadog-island-is bot commented Jul 3, 2024

Datadog Report

All test runs 7119ccd 🔗

3 Total Test Services: 0 Failed, 3 Passed
🔻 Test Sessions change in coverage: 1 decreased (-0.05%), 3 no change

Test Services
Service Name Failed Known Flaky New Flaky Passed Skipped Total Time Code Coverage Change Test Service View
api 0 0 0 4 0 2.93s 1 no change Link
application-system-api 0 0 0 111 2 3m 3.21s 1 no change Link
judicial-system-web 0 0 0 317 0 1m 8.17s 1 decreased (-0.05%) Link

🔻 Code Coverage Decreases vs Default Branch (1)

  • judicial-system-web - jest 32.47% (-0.05%) - Details

Copy link
Member

@gudjong gudjong left a comment

Choose a reason for hiding this comment

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

Neat

@unakb unakb added the automerge Merge this PR as soon as all checks pass label Jul 4, 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

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between a9955e9 and 1222366.

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

@unakb unakb added automerge Merge this PR as soon as all checks pass and removed automerge Merge this PR as soon as all checks pass labels Jul 4, 2024
@lodmfjord lodmfjord added automerge Merge this PR as soon as all checks pass and removed automerge Merge this PR as soon as all checks pass labels Jul 4, 2024
@kodiakhq kodiakhq bot merged commit 545de44 into main Jul 4, 2024
29 checks passed
@kodiakhq kodiakhq bot deleted the j-s/subpoena-type-selection branch July 4, 2024 17:20
oskarjs pushed a commit that referenced this pull request Aug 20, 2024
* feat(j-s): Subpoena type decision on court overview screen

* Update Subpoena.tsx

---------

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

3 participants