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): Sort cases by IndictmentAppealDeadline #15336

Merged
merged 24 commits into from
Jun 26, 2024
Merged

Conversation

oddsson
Copy link
Member

@oddsson oddsson commented Jun 25, 2024

Sort cases by IndictmentAppealDeadline

Asana

What

Add a a sort button to CasesForReview and CasesAwaitingReview tables. The sort button sorts the cases by IndictmentAppealDeadline.

Why

The people at the Public prosecutors office want to be able to sort cases by deadline.

Note

There is a slight issue with the tests in this RP. When running the tests in Table.spec.tsx there is a warning logged to the console, Warning: The current testing environment is not configured to support act(...). I've created a ticket in Asana for this and we'll fix this in a later cooldown week.

Screenshots / Gifs

Screen.Recording.2024-06-25.at.09.29.38.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

  • Bug Fixes

    • Corrected sorting keys for table columns to improve sorting by defendant names and creation dates.
  • New Features

    • Added a sortable column for 'deadline' in the "Cases Awaiting Review" table.
  • Tests

    • Introduced tests for sorting functionality in tables.
  • Refactor

    • Improved sorting logic and updated component syntax for better readability and performance.
  • Chores

    • Updated utility wrappers with functional component syntax for better code consistency.

Copy link
Contributor

coderabbitai bot commented Jun 25, 2024

Walkthrough

The updates focus on enhancing the sorting functionality within various tables in the judicial system web application. Noteworthy changes include altering sorting keys from 'defendant' to 'defendants' and from 'createdAt' to 'created', updating table components to use these new keys, and adjusting type definitions to reflect these updates. Additionally, several utility wrappers have been refactored to use functional component syntax with TypeScript props for better code consistency and readability.

Changes

File/Group Change Summary
AppealCasesTable.tsx Changed sorting key from 'defendant' to 'defendants'
SortButton.tsx Added <p> element with "visually-hidden" class
Table.spec.tsx Added test scenario for sorting table by the indictmentAppealDeadline field
Table.tsx Updated type definitions, component declarations, and sorting logic
CasesAwaitingAssignmentTable.tsx, CasesInProgressTable.tsx, CasesAwaitingConfirmationTable.tsx, CasesAwaitingReview.tsx, CasesForReview.tsx, CasesReviewed.tsx Changed sorting keys from 'defendant' to 'defendants' and from 'createdAt' to 'created'
ActiveCases.tsx, DefenderCasesTable.tsx Updated sorting logic to use new keys 'defendants' and 'created'
PastCasesTable.tsx, PrisonCases.tsx Adjusted sorting logic and functions to reflect changes in key names
utils/testHelpers.tsx Refactored utility wrappers to use functional component syntax with TypeScript props
types/index.ts Changed sortableTableColumn type to use CaseListEntry keys
useSortCases.ts Updated useSortCases hook to use sortableTableColumn type and corrected typos in sorting logic

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.

@oddsson oddsson changed the title J s/deadline sort feat(j-s): Sort cases by IndictmentAppealDeadline Jun 25, 2024
Copy link

codecov bot commented Jun 25, 2024

Codecov Report

Attention: Patch coverage is 62.96296% with 10 lines in your changes missing coverage. Please review.

Project coverage is 37.05%. Comparing base (b715e12) to head (8c0493d).
Report is 2 commits behind head on main.

Current head 8c0493d differs from pull request most recent head 7c534d5

Please upload reports for the commit 7c534d5 to get more accurate results.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #15336      +/-   ##
==========================================
+ Coverage   37.04%   37.05%   +0.01%     
==========================================
  Files        6538     6538              
  Lines      133126   133114      -12     
  Branches    38130    38123       -7     
==========================================
+ Hits        49310    49319       +9     
+ Misses      83816    83795      -21     
Flag Coverage Δ
air-discount-scheme-backend 53.99% <ø> (ø)
air-discount-scheme-web 0.00% <ø> (ø)
api 3.44% <ø> (ø)
api-catalogue-services 77.85% <ø> (ø)
api-domains-air-discount-scheme 36.79% <ø> (ø)
api-domains-assets 26.71% <ø> (ø)
api-domains-communications 40.76% <ø> (ø)
api-domains-criminal-record 47.89% <ø> (ø)
api-domains-driving-license 44.69% <ø> (ø)
api-domains-education 33.71% <ø> (ø)
api-domains-health-insurance 34.88% <ø> (ø)
api-domains-mortgage-certificate 35.32% <ø> (ø)
api-domains-payment-schedule 41.09% <ø> (ø)
application-api-files 56.93% <ø> (+0.08%) ⬆️
application-core 71.91% <ø> (-0.09%) ⬇️
application-system-api 42.07% <ø> (ø)
application-templates-car-recycling 4.23% <ø> (ø)
application-templates-criminal-record 22.35% <ø> (ø)
application-templates-driving-license 15.89% <ø> (ø)
application-templates-estate 11.94% <ø> (ø)
application-templates-example-payment 21.01% <ø> (ø)
application-templates-financial-aid 12.14% <ø> (ø)
application-templates-general-petition 19.05% <ø> (ø)
application-templates-health-insurance 23.46% <ø> (ø)
application-templates-inheritance-report 4.65% <ø> (ø)
application-templates-marriage-conditions 10.56% <ø> (ø)
application-templates-mortgage-certificate 45.14% <ø> (ø)
application-templates-parental-leave 28.46% <ø> (+0.11%) ⬆️
application-types 7.28% <ø> (ø)
application-ui-components 1.43% <ø> (ø)
application-ui-shell 21.62% <ø> (ø)
clients-charge-fjs-v2 27.54% <ø> (ø)
clients-driving-license 41.04% <ø> (ø)
clients-driving-license-book 44.05% <ø> (ø)
clients-financial-statements-inao 49.25% <ø> (ø)
clients-license-client 1.84% <ø> (ø)
clients-middlewares 72.99% <ø> (ø)
clients-regulations 42.82% <ø> (ø)
clients-rsk-company-registry 30.50% <ø> (ø)
clients-rsk-personal-tax-return 38.00% <ø> (ø)
clients-smartsolutions 12.77% <ø> (ø)
clients-syslumenn 49.63% <ø> (ø)
clients-zendesk 55.26% <ø> (ø)
cms 0.44% <ø> (ø)
cms-translations 39.88% <ø> (ø)
content-search-index-manager 95.65% <ø> (ø)
content-search-toolkit 8.57% <ø> (ø)
contentful-apps 6.05% <ø> (ø)
dokobit-signing 62.22% <ø> (ø)
download-service 44.77% <ø> (ø)
email-service 61.42% <ø> (ø)
feature-flags 90.16% <ø> (ø)
file-storage 52.17% <ø> (ø)
financial-aid-backend 56.52% <ø> (ø)
icelandic-names-registry-backend 54.18% <ø> (ø)
infra-nest-server 48.33% <ø> (ø)
infra-tracing 43.24% <ø> (ø)
island-ui-core 28.92% <ø> (ø)
judicial-system-api 18.18% <ø> (ø)
judicial-system-audit-trail 67.84% <ø> (ø)
judicial-system-backend 56.19% <ø> (ø)
judicial-system-formatters 81.63% <ø> (ø)
license-api 43.33% <ø> (+0.05%) ⬆️
localization 10.15% <ø> (ø)
logging 48.43% <ø> (ø)
message-queue 68.39% <ø> (ø)
nest-audit 68.20% <ø> (ø)
nest-config 77.61% <ø> (ø)
nest-feature-flags 51.46% <ø> (ø)
nest-problem 46.08% <ø> (ø)
nest-sequelize 94.44% <ø> (ø)
nest-swagger 51.71% <ø> (ø)
nova-sms 63.41% <ø> (ø)
reference-backend 50.31% <ø> (ø)
regulations 16.78% <ø> (ø)
residence-history 85.00% <ø> (ø)
services-auth-admin-api 51.45% <ø> (ø)
services-auth-delegation-api 61.69% <ø> (ø)
services-auth-ids-api 54.91% <ø> (+0.01%) ⬆️
services-auth-personal-representative 48.59% <ø> (+0.01%) ⬆️
services-auth-personal-representative-public 44.55% <ø> (+0.04%) ⬆️
services-auth-public-api 50.58% <ø> (ø)
services-documents 60.96% <ø> (ø)
services-endorsements-api 55.45% <ø> (ø)
services-sessions 65.42% <ø> (+0.04%) ⬆️
services-university-gateway 48.59% <ø> (+0.08%) ⬆️
services-user-notification 48.23% <ø> (ø)
services-user-profile 62.40% <ø> (ø)
shared-problem 87.50% <ø> (ø)
shared-utils 29.87% <ø> (ø)
skilavottord-ws 23.78% <ø> (ø)
web 1.89% <ø> (ø)

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

Files Coverage Δ
...onents/Table/AppealCasesTable/AppealCasesTable.tsx 2.38% <ø> (ø)
...web/src/components/Table/SortButton/SortButton.tsx 100.00% <ø> (ø)
...ngAssignmentTable/CasesAwaitingAssignmentTable.tsx 38.88% <ø> (ø)
...ents/CasesInProgressTable/CasesInProgressTable.tsx 56.86% <ø> (ø)
...nfirmationTable/CasesAwaitingConfirmationTable.tsx 33.33% <ø> (ø)
...es/PublicProsecutor/Tables/CasesAwaitingReview.tsx 5.88% <ø> (ø)
...c/routes/PublicProsecutor/Tables/CasesReviewed.tsx 0.00% <ø> (ø)
...system/web/src/routes/Shared/Cases/ActiveCases.tsx 62.50% <100.00%> (ø)
...system/web/src/routes/Shared/Cases/PrisonCases.tsx 0.00% <ø> (ø)
...system/web/src/utils/hooks/useSort/useSortCases.ts 65.62% <100.00%> (ø)
... and 5 more

... and 3 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 11e9ede...7c534d5. Read the comment docs.

@datadog-island-is
Copy link

datadog-island-is bot commented Jun 25, 2024

Datadog Report

All test runs 8b4b93d 🔗

6 Total Test Services: 0 Failed, 6 Passed
⬆️ Test Sessions change in coverage: 1 increased (+0.08%), 10 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 3.18s 1 no change Link
application-system-api 0 0 0 111 2 3m 17.02s 1 no change Link
application-template-api-modules 0 0 0 109 0 2m 18.26s 1 no change Link
application-ui-shell 0 0 0 74 0 1m 5.25s 1 no change Link
judicial-system-web 0 0 0 317 0 1m 6.37s 1 increased (+0.08%) Link
portals-admin-regulations-admin 0 0 0 24 0 14.24s 1 no change Link

@oddsson oddsson marked this pull request as ready for review June 25, 2024 10:02
@oddsson oddsson requested a review from a team as a code owner June 25, 2024 10:02
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 and nitpick comments (1)
apps/judicial-system/web/src/components/Table/Table.tsx (1)

Line range hint 194-206: Add keyboard accessibility for row click actions

The table rows are clickable but lack corresponding keyboard event handlers, which is necessary for accessibility compliance.

- onClick={() => { if (!onClick?.(row)) { handleOpenCase(row.id) } }}
+ onClick={() => { if (!onClick?.(row)) { handleOpenCase(row.id) } }}
+ onKeyUp={(event) => { if (event.key === 'Enter') handleOpenCase(row.id) }}
Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 0f98314 and aa6b30a.

Files selected for processing (14)
  • apps/judicial-system/web/src/components/Table/AppealCasesTable/AppealCasesTable.tsx (1 hunks)
  • apps/judicial-system/web/src/components/Table/SortButton/SortButton.tsx (1 hunks)
  • apps/judicial-system/web/src/components/Table/Table.spec.tsx (1 hunks)
  • apps/judicial-system/web/src/components/Table/Table.tsx (7 hunks)
  • apps/judicial-system/web/src/routes/Court/components/CasesAwaitingAssignmentTable/CasesAwaitingAssignmentTable.tsx (2 hunks)
  • apps/judicial-system/web/src/routes/Court/components/CasesInProgressTable/CasesInProgressTable.tsx (1 hunks)
  • apps/judicial-system/web/src/routes/Prosecutor/components/CasesAwaitingConfirmationTable/CasesAwaitingConfirmationTable.tsx (1 hunks)
  • apps/judicial-system/web/src/routes/PublicProsecutor/Tables/CasesAwaitingReview.tsx (1 hunks)
  • apps/judicial-system/web/src/routes/PublicProsecutor/Tables/CasesForReview.tsx (4 hunks)
  • apps/judicial-system/web/src/routes/PublicProsecutor/Tables/CasesReviewed.tsx (1 hunks)
  • apps/judicial-system/web/src/routes/Shared/Cases/ActiveCases.tsx (3 hunks)
  • apps/judicial-system/web/src/routes/Shared/Cases/PrisonCases.tsx (1 hunks)
  • apps/judicial-system/web/src/types/index.ts (2 hunks)
  • apps/judicial-system/web/src/utils/testHelpers.tsx (3 hunks)
Files not reviewed due to errors (1)
  • apps/judicial-system/web/src/utils/testHelpers.tsx (no review received)
Files skipped from review due to trivial changes (4)
  • apps/judicial-system/web/src/components/Table/SortButton/SortButton.tsx
  • apps/judicial-system/web/src/routes/PublicProsecutor/Tables/CasesReviewed.tsx
  • apps/judicial-system/web/src/routes/Shared/Cases/PrisonCases.tsx
  • apps/judicial-system/web/src/types/index.ts
Additional context used
Path-based instructions (10)
apps/judicial-system/web/src/utils/testHelpers.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.spec.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/components/CasesAwaitingAssignmentTable/CasesAwaitingAssignmentTable.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/PublicProsecutor/Tables/CasesAwaitingReview.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/PublicProsecutor/Tables/CasesForReview.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/Prosecutor/components/CasesAwaitingConfirmationTable/CasesAwaitingConfirmationTable.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/AppealCasesTable/AppealCasesTable.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/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."
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."
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/components/Table/Table.tsx

[error] 194-206: 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.

Additional comments not posted (9)
apps/judicial-system/web/src/components/Table/Table.spec.tsx (1)

28-90: Ensure correct behavior in sorting test for Table.

This test checks the sorting functionality of the Table component by the indictmentAppealDeadline. Ensure that the test adequately covers both ascending and descending orders and that the test setup correctly mocks or isolates dependencies.

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

52-52: Approval of sorting functionality addition in CasesAwaitingReview.

The addition of a new sortable column for 'indictmentAppealDeadline' aligns with the PR's objectives to improve case management by sorting based on deadlines. Ensure that the backend supports this key and that it correctly interacts with the sorting mechanism.

Also applies to: 56-61

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

49-52: Review the implementation of new sortable columns in CasesForReview.

The changes to add 'defendants' and 'indictmentAppealDeadline' as sortable columns are crucial for enhancing the usability of the table. Confirm that these keys are supported on the backend and that the UI updates correctly reflect the sorted data.

Also applies to: 56-61

apps/judicial-system/web/src/routes/Prosecutor/components/CasesAwaitingConfirmationTable/CasesAwaitingConfirmationTable.tsx (2)

61-61: Updated sorting key for defendants

The sorting key for defendants has been updated from 'defendant' to 'defendants'. Ensure that this change aligns with the backend schema and other frontend components where sorting might be affected.

Verification successful

Updated sorting key for defendants

The verification confirms that the key 'defendants' is used extensively across the frontend and backend components, aligning with the updated sorting key change. This ensures consistency and proper functionality across the system.

  • The key 'defendants' is found in various frontend components, including sorting configurations and data handling.
  • The backend schema also supports 'defendants', as evidenced by its presence in GraphQL queries, TypeScript files, and backend services.
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the backend schema and other frontend components align with the new sorting key 'defendants'.
ast-grep --lang typescript --pattern $'sortable: { isSortable: true, key: "defendants" }'

Length of output: 90



Script:

#!/bin/bash
# Description: Check if the sorting key 'defendants' is used elsewhere in the frontend components.
rg 'key: "defendants"'

# Description: Check if the backend schema supports the 'defendants' key.
rg 'defendants' --glob '*.graphql' --glob '*.ts' --glob '*.tsx'

Length of output: 63635


68-68: Updated sorting key for created date

The sorting key for the created date has been updated from 'createdAt' to 'created'. This change should be consistently applied across the backend and other components that might use this sorting key.

Verification successful

Updated sorting key for created date

The sorting key for the created date has been updated from 'createdAt' to 'created'. The search results confirm that the new sorting key 'created' is used consistently across the backend and other frontend components.

  • Backend Components: Multiple files in the backend show usage of 'created' as the sorting key.
  • Frontend Components: The 'created' key is also found in various frontend TypeScript files.

No further action required.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the backend schema and other frontend components align with the new sorting key 'created'.
ast-grep --lang typescript --pattern $'sortable: { isSortable: true, key: "created" }'

Length of output: 87



Script:

#!/bin/bash
# Verify the usage of the new sorting key 'created' in the frontend components
rg 'key: "created"' --glob='*.tsx' --glob='*.ts'

# Verify the usage of the new sorting key 'created' in the backend components
rg 'created' --glob='*.ts' --glob='*.js'

Length of output: 118766

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

80-80: Updated sorting key for defendants in AppealCasesTable

The sorting key for defendants has been updated to 'defendants'. This change should be verified to ensure that it aligns with the data structure expected by the backend and other frontend components.

Verification successful

Updated sorting key for defendants in AppealCasesTable

The sorting key 'defendants' is widely used across both frontend and backend components, ensuring consistency with the new sorting key in the AppealCasesTable. The key 'defendants' appears in various files and contexts, indicating that it aligns with the data structure expected by the backend and other frontend components.

  • Frontend Components: The key 'defendants' is used in multiple components, such as Table.tsx, MobilePastCase.tsx, DefendantInfo.tsx, and others.
  • Backend Schema: The key 'defendants' is also present in backend files, such as notification.service.ts, case.service.ts, and various test files.

Files that need attention:

  • apps/judicial-system/web/src/components/Table/AppealCasesTable/AppealCasesTable.tsx
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the backend schema and other frontend components align with the new sorting key 'defendants' in AppealCasesTable.
ast-grep --lang typescript --pattern $'sortable: { isSortable: true, key: "defendants" }'

Length of output: 90



Script:

#!/bin/bash
# Search for the usage of 'defendants' as a sorting key in backend-related files.
rg 'defendants' --type ts --type tsx --type graphql

# Search for the usage of 'defendants' in other frontend components.
rg 'defendants' --type ts --type tsx

Length of output: 144



Script:

#!/bin/bash
# Search for the usage of 'defendants' as a sorting key in backend-related files.
rg 'defendants' --type typescript --type graphql

# Search for the usage of 'defendants' in other frontend components.
rg 'defendants' --type typescript

Length of output: 152



Script:

#!/bin/bash
# Search for the usage of 'defendants' as a sorting key in backend-related files.
rg 'defendants' --type ts --type graphql

# Search for the usage of 'defendants' in other frontend components.
rg 'defendants' --type ts

Length of output: 62848

apps/judicial-system/web/src/routes/Court/components/CasesInProgressTable/CasesInProgressTable.tsx (1)

115-115: Updated sorting keys for defendants and created date in CasesInProgressTable

The sorting keys for defendants and created date have been updated. Confirm that these changes are consistent across all related components and the backend schema.

Also applies to: 122-122

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

106-113: Ensure consistent sorting logic for defendant names

The sorting logic for defendant names checks for the existence of the first defendant's name. Ensure that this logic correctly handles cases where defendant information might be partially missing or formatted differently.

Verification successful

Consistent sorting logic for defendant names verified

The sorting logic for defendant names in the identified files (useSortCases.ts and useSortAppealCases.ts) ensures robustness by providing a default empty string when the name is missing. This confirms that the logic handles cases where defendant information might be partially missing.

  • apps/judicial-system/web/src/utils/hooks/useSort/useSortCases.ts:50
  • apps/judicial-system/web/src/utils/hooks/useSort/useSortAppealCases.ts:49
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the consistency and robustness of sorting logic for defendant names in various components.
ast-grep --lang typescript --pattern $'entry.defendants[0].name'

Length of output: 311

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

181-184: Updated sorting keys for defendants and created date in ActiveCases

The sorting keys for defendants and created date have been updated to 'defendants' and 'created', respectively. Confirm that these keys are consistently used across all relevant components and back-end schemas.

Also applies to: 198-201

Verification successful

Consistent Usage of Sorting Keys 'defendants' and 'created' Verified

The sorting keys 'defendants' and 'created' are consistently used across the frontend components and backend schemas.

  • Frontend:

    • apps/judicial-system/web/src/routes/Shared/Cases/ActiveCases.tsx
    • apps/judicial-system/web/src/routes/Shared/Cases/PrisonCases.tsx
    • apps/judicial-system/web/src/routes/PublicProsecutor/Tables/CasesForReview.tsx
    • apps/judicial-system/web/src/routes/Court/components/CasesInProgressTable/CasesInProgressTable.tsx
    • apps/judicial-system/web/src/routes/Court/components/CasesAwaitingAssignmentTable/CasesAwaitingAssignmentTable.tsx
  • Backend:

    • apps/judicial-system/backend/src/app/modules/case/models/case.model.ts
    • apps/judicial-system/backend/src/app/modules/case/internalCase.service.ts
    • apps/judicial-system/backend/src/app/modules/notification/notification.service.ts

These results confirm that the sorting keys 'defendants' and 'created' are correctly implemented and used consistently across the codebase.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the backend schema and other frontend components align with the new sorting keys 'defendants' and 'created' in ActiveCases.
ast-grep --lang typescript --pattern $'sortable: { isSortable: true, key: "defendants" }'
ast-grep --lang typescript --pattern $'sortable: { isSortable: true, key: "created" }'

Length of output: 178



Script:

#!/bin/bash
# Description: Verify that the sorting keys 'defendants' and 'created' are used in the frontend components.
# Searching for 'defendants' and 'created' in the frontend code.
rg 'defendants' --type js --type ts --type tsx
rg 'created' --type js --type ts --type tsx

Length of output: 146


Script:

#!/bin/bash
# Description: Verify that the sorting keys 'defendants' and 'created' are used in the backend schemas.
# Searching for 'defendants' and 'created' in the backend code.
rg 'defendants' --type js --type ts
rg 'created' --type js --type ts

Length of output: 208240

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.

Please fix broken build

@oddsson oddsson requested a review from gudjong June 25, 2024 13:24
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 aa6b30a and dfc8aab.

Files selected for processing (3)
  • apps/judicial-system/web/src/components/Table/PastCasesTable/PastCasesTable.tsx (3 hunks)
  • apps/judicial-system/web/src/routes/Defender/Cases/components/DefenderCasesTable.tsx (3 hunks)
  • apps/judicial-system/web/src/utils/hooks/useSort/useSortCases.ts (4 hunks)
Files not reviewed due to errors (1)
  • apps/judicial-system/web/src/utils/hooks/useSort/useSortCases.ts (no review received)
Additional context used
Path-based instructions (3)
apps/judicial-system/web/src/utils/hooks/useSort/useSortCases.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/Table/PastCasesTable/PastCasesTable.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/Defender/Cases/components/DefenderCasesTable.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/PastCasesTable/PastCasesTable.tsx

[error] 137-141: 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.

apps/judicial-system/web/src/routes/Defender/Cases/components/DefenderCasesTable.tsx

[error] 126-130: 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.

Additional comments not posted (4)
apps/judicial-system/web/src/components/Table/PastCasesTable/PastCasesTable.tsx (3)

56-56: Good use of useSortCases hook.

The useSortCases hook is used effectively to manage sorting state and operations. This encapsulation of sorting logic in a custom hook is a good practice, promoting reusability and separation of concerns.


123-126: Keyboard accessibility needs attention.

Similarly, ensure that sorting by 'created' is accessible via keyboard by adding corresponding keyboard event handlers.
[ISSue]

+ onKeyUp={(event) => event.key === 'Enter' && requestSort('created')}

111-114: Ensure consistent interaction for all users.

The SortButton component interaction is currently only handled through mouse events. Consider adding keyboard event handlers to ensure accessibility for users who rely on keyboard navigation.

+ onKeyUp={(event) => event.key === 'Enter' && requestSort('defendants')}
apps/judicial-system/web/src/routes/Defender/Cases/components/DefenderCasesTable.tsx (1)

51-51: Effective use of useSortCases in DefenderCasesTable.

The hook useSortCases is utilized well here, similar to its use in PastCasesTable. This consistency in handling sorting across different tables is good for maintainability.

@oddsson oddsson added the automerge Merge this PR as soon as all checks pass label Jun 25, 2024
coderabbitai[bot]
coderabbitai bot previously requested changes Jun 25, 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: 1

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between dfc8aab and 76f2042.

Files selected for processing (3)
  • apps/judicial-system/web/src/routes/Court/components/CasesInProgressTable/CasesInProgressTable.tsx (1 hunks)
  • apps/judicial-system/web/src/routes/Defender/Cases/components/DefenderCasesTable.tsx (3 hunks)
  • apps/judicial-system/web/src/routes/Shared/Cases/ActiveCases.tsx (3 hunks)
Files not reviewed due to errors (1)
  • apps/judicial-system/web/src/routes/Court/components/CasesInProgressTable/CasesInProgressTable.tsx (no review received)
Additional context used
Path-based instructions (3)
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."
apps/judicial-system/web/src/routes/Defender/Cases/components/DefenderCasesTable.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/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/routes/Defender/Cases/components/DefenderCasesTable.tsx

[error] 123-127: 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.

Additional comments not posted (3)
apps/judicial-system/web/src/routes/Defender/Cases/components/DefenderCasesTable.tsx (2)

77-80: Accessibility improvements implemented.

The addition of keyboard accessibility features for sorting buttons, as suggested in previous comments, has been correctly implemented. This ensures that the sorting functionality is accessible to users who rely on keyboard navigation.

Also applies to: 94-97


48-48: Sorting functionality initialized correctly.

The initialization of the sorting functionality using the 'created' column in descending order as a default setting is a good practice. It ensures that the users see the most recent cases first, which is likely the most common use case.

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

86-86: Enhanced sorting logic for 'defendants'.

The sorting logic now checks for the presence of defendants and sorts based on the first defendant's name if available. This is a thoughtful addition for cases where multiple defendants might be involved, ensuring the table is sorted meaningfully.

@oddsson oddsson removed the request for review from coderabbitai[bot] June 26, 2024 14:02
@kodiakhq kodiakhq bot merged commit ab2522d into main Jun 26, 2024
42 checks passed
@kodiakhq kodiakhq bot deleted the j-s/deadline-sort branch June 26, 2024 14:22
sigruntg pushed a commit that referenced this pull request Jun 27, 2024
* Checkpoint

* Checkpoint

* Sort now works

* Testing sort now works with existing sorting mechanims

* Cleanup

* sortableTableColumn now has better types

* Fix build errors

* Checkpoint

* Tests correct

* Refactor

* Fix lint

* Revert RTL update

* Revert RTL update

* Revert RTL update

* Use better types

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
snaerseljan pushed a commit that referenced this pull request Jul 2, 2024
* Checkpoint

* Checkpoint

* Sort now works

* Testing sort now works with existing sorting mechanims

* Cleanup

* sortableTableColumn now has better types

* Fix build errors

* Checkpoint

* Tests correct

* Refactor

* Fix lint

* Revert RTL update

* Revert RTL update

* Revert RTL update

* Use better types

---------

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

Successfully merging this pull request may close these issues.

2 participants