-
Notifications
You must be signed in to change notification settings - Fork 61
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): Indictment Deletion #15028
Conversation
WalkthroughThe recent updates primarily focus on refining the state transition logic within the judicial system's backend and frontend components. Notably, transitions from Changes
Sequence Diagram(s) (Beta)sequenceDiagram
participant User
participant Frontend
participant Backend
participant StateMachine
User->>Frontend: Access Active Cases
Frontend->>Backend: Fetch Cases
Backend->>StateMachine: Get Case States
StateMachine-->>Backend: Return Case States
Backend-->>Frontend: Return Cases with States
Frontend-->>User: Display Cases with Options
User->>Frontend: Attempt to Delete Case
Frontend->>Backend: Request Case Deletion
Backend->>StateMachine: Validate Transition (SUBMITTED/RECEIVED to DELETED)
StateMachine-->>Backend: Transition Not Allowed
Backend-->>Frontend: Transition Error
Frontend-->>User: Display Error Message
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? TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this 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
Outside diff range and nitpick comments (4)
apps/judicial-system/backend/src/app/modules/case/state/case.state.ts (2)
Line range hint
327-344
: Consider converting this function expression to an arrow function for consistency and conciseness.- export const transitionCase = function ( + export const transitionCase = ( transition: CaseTransition, caseType: CaseType, currentState: CaseState, currentAppealState?: CaseAppealState, ): CaseStates { if (isIndictmentCase(caseType)) { return transitionIndictmentCase(transition, currentState) } if (isRequestCase(caseType)) { return transitionRequestCase(transition, currentState, currentAppealState) } throw new ForbiddenException( `The transition ${transition} cannot be applied to a ${caseType} case`, ) }
Line range hint
2-18
: Some imports are only used as types and should be imported usingimport type
.- import { + import type { CaseAppealState, CaseState, CaseTransition, CaseType, IndictmentCaseState, IndictmentCaseTransition, isIndictmentCase, isIndictmentCaseState, isIndictmentCaseTransition, isRequestCase, isRequestCaseState, isRequestCaseTransition, RequestCaseState, RequestCaseTransition, } from '@island.is/judicial-system/types'apps/judicial-system/web/src/routes/Shared/Cases/ActiveCases.tsx (2)
Line range hint
223-223
: JSX elements without children should be self-closing for better readability and consistency.- <Box display="flex" flexDirection="column"> + <Box display="flex" flexDirection="column" />
Line range hint
1-1
: Imports that are only used as types should be imported usingimport type
to avoid unnecessary runtime imports and to clarify their usage.- import React, { useContext, useEffect, useMemo, useState } from 'react' + import type { FC, PropsWithChildren } from 'react' + import React, { useContext, useEffect, useMemo, useState } from 'react' - import { Box, IconMapIcon, Text } from '@island.is/island-ui/core' + import type { IconMapIcon } from '@island.is/island-ui/core' + import { Box, Text } from '@island.is/island-ui/core' - import { + import type { CaseListEntry, CaseState, } from '@island.is/judicial-system-web/src/graphql/schema' - import { + import type { directionType, sortableTableColumn, SortConfig, } from '@island.is/judicial-system-web/src/types'Also applies to: 8-9, 35-39, 39-44
Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Files selected for processing (3)
- apps/judicial-system/backend/src/app/modules/case/state/case.state.spec.ts (1 hunks)
- apps/judicial-system/backend/src/app/modules/case/state/case.state.ts (1 hunks)
- apps/judicial-system/web/src/routes/Shared/Cases/ActiveCases.tsx (2 hunks)
Additional context used
Path-based instructions (3)
apps/judicial-system/backend/src/app/modules/case/state/case.state.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."
apps/judicial-system/backend/src/app/modules/case/state/case.state.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 (1)
apps/judicial-system/web/src/routes/Shared/Cases/ActiveCases.tsx (1)
User: 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.
Biome
apps/judicial-system/backend/src/app/modules/case/state/case.state.ts
[error] 327-344: This function expression can be turned into an arrow function.
[error] 2-18: Some named imports are only used as types.
apps/judicial-system/web/src/routes/Shared/Cases/ActiveCases.tsx
[error] 223-223: JSX elements without children should be marked as self-closing. In JSX, it is valid for any element to be self-closing.
[error] 1-1: The default import is only used as a type.
[error] 8-9: Some named imports are only used as types.
[error] 35-39: Some named imports are only used as types.
[error] 39-44: All these imports are only used as types.
Additional comments not posted (1)
apps/judicial-system/backend/src/app/modules/case/state/case.state.spec.ts (1)
Line range hint
1-1
: This file does not contain any specific changes to review based on the provided context. The tests seem to be well-structured and cover various scenarios for state transitions.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #15028 +/- ##
==========================================
- Coverage 37.12% 37.12% -0.01%
==========================================
Files 6393 6391 -2
Lines 130123 130049 -74
Branches 37132 37107 -25
==========================================
- Hits 48310 48279 -31
+ Misses 81813 81770 -43
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 21 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
Datadog ReportAll test runs ✅ 2 Total Test Services: 0 Failed, 2 Passed Test Services
|
There was a problem hiding this 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
Outside diff range and nitpick comments (2)
apps/judicial-system/backend/src/app/modules/case/test/caseController/transition.spec.ts (2)
Line range hint
1-2
: Optimize imports by using TypeScript's type-only import syntax.- import each from 'jest-each' - import { Transaction } from 'sequelize' - import { uuid } from 'uuidv4' + import type each from 'jest-each' + import type { Transaction } from 'sequelize' + import type { uuid } from 'uuidv4'This change ensures that these imports are only used for type checking and not included in the JavaScript runtime, aligning with TypeScript best practices.
Also applies to: 4-5, 6-7, 7-24, 29-30, 31-32, 32-33
Line range hint
161-166
: Remove duplicate setup and teardown hooks to streamline test setup.It appears that setup and teardown hooks are duplicated across different test suites. Consolidating these can help reduce redundancy and potential confusion during test maintenance.
Also applies to: 345-350, 645-652
Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Files selected for processing (1)
- apps/judicial-system/backend/src/app/modules/case/test/caseController/transition.spec.ts (1 hunks)
Additional context used
Path-based instructions (1)
apps/judicial-system/backend/src/app/modules/case/test/caseController/transition.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."
Biome
apps/judicial-system/backend/src/app/modules/case/test/caseController/transition.spec.ts
[error] 161-166: Disallow duplicate setup and teardown hooks.
[error] 345-350: Disallow duplicate setup and teardown hooks.
[error] 645-652: Disallow duplicate setup and teardown hooks.
[error] 1-2: All these imports are only used as types.
[error] 4-5: All these imports are only used as types.
[error] 6-7: Some named imports are only used as types.
[error] 7-24: Some named imports are only used as types.
[error] 29-30: All these imports are only used as types.
[error] 31-32: All these imports are only used as types.
[error] 32-33: All these imports are only used as types.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm!
Indictment Deletion
Afturköllun ákæru áður en mál er sent á dómstól
What
Why
Screenshots / Gifs
Checklist:
Summary by CodeRabbit
Bug Fixes
SUBMITTED
andRECEIVED
toDELETED
in the case management system.Enhancements