-
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 View Tag #14922
Conversation
This comment was marked as off-topic.
This comment was marked as off-topic.
Datadog ReportAll test runs ✅ 2 Total Test Services: 0 Failed, 2 Passed Test Services
🔻 Code Coverage Decreases vs Default Branch (2) |
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: 4
Outside diff range and nitpick comments (5)
apps/judicial-system/web/src/components/FormProvider/case.graphql (1)
27-27
: Ensure the new fieldverdictAppealDeadline
is properly indexed in the database for performance.apps/judicial-system/api/src/app/modules/case/interceptors/case.transformer.ts (1)
Line range hint
99-137
: RefactorgetIndictmentInfo
to improve readability and efficiency.- export const getIndictmentInfo = ( - rulingDate?: string, - caseType?: CaseType, - defendants?: Defendant[], - ): IndictmentInfo => { - const indictmentInfo: IndictmentInfo = {} - if ((caseType && !isIndictmentCase(caseType)) || !rulingDate) { - return indictmentInfo - } - const theRulingDate = new Date(rulingDate) - indictmentInfo.indictmentAppealDeadline = new Date( - theRulingDate.setDate(theRulingDate.getDate() + 28), - ).toISOString() - if (defendants) { - const verdictViewDates = defendants?.map( - (defendant) => defendant.verdictViewDate, - ) - if (!verdictViewDates || verdictViewDates?.some((date) => !date)) { - indictmentInfo.indictmentVerdictViewedByAll = false - } else { - indictmentInfo.indictmentVerdictViewedByAll = true - const newestViewDate = verdictViewDates - ?.filter((date): date is string => date !== undefined) - .map((date) => new Date(date)) - .reduce( - (newest, current) => (current > newest ? current : newest), - new Date(0), - ) - const expiryDate = new Date(newestViewDate.getTime()) - expiryDate.setDate(newestViewDate.getDate() + 28) - indictmentInfo.indictmentVerdictAppealDeadline = expiryDate.toISOString() - } - } - return indictmentInfo - } + Simplified and optimized version of the function here...apps/judicial-system/web/src/components/InfoCard/InfoCard.tsx (1)
41-41
: Ensure the new propdisplayAppealExpirationInfo
is properly documented.apps/judicial-system/api/src/app/modules/case/interceptors/case.transformer.spec.ts (2)
Line range hint
9-10
: Consider usingimport type
for imports that are only used for type annotations.- import { + import type { CaseAppealDecision, CaseAppealState, CaseState, UserRole, } from '@island.is/judicial-system/types'
Line range hint
522-537
: Consider usingfor...of
instead offorEach
for better control and readability in loops.- Object.values(CaseAppealDecision).forEach((decision) => { + for (const decision of Object.values(CaseAppealDecision)) { const expected = decision === CaseAppealDecision.POSTPONE || decision === CaseAppealDecision.NOT_APPLICABLE test(`canProsecutorAppeal for appeal decision ${decision} should return ${expected}`, () => { const theCase = { rulingDate, prosecutorAppealDecision: decision, } as Case const appealInfo = getAppealInfo(theCase) expect(appealInfo).toHaveProperty('canProsecutorAppeal', expected) }) + }Also applies to: 539-554
Review Details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Files selected for processing (14)
- 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 (1 hunks)
- apps/judicial-system/api/src/app/modules/case/interceptors/case.transformer.ts (5 hunks)
- apps/judicial-system/api/src/app/modules/case/models/case.model.ts (1 hunks)
- apps/judicial-system/api/src/app/modules/defendant/models/defendant.model.ts (1 hunks)
- apps/judicial-system/web/messages/Core/tables.ts (1 hunks)
- apps/judicial-system/web/src/components/FormProvider/case.graphql (2 hunks)
- apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.tsx (2 hunks)
- apps/judicial-system/web/src/components/InfoCard/InfoCard.tsx (3 hunks)
- apps/judicial-system/web/src/components/InfoCard/InfoCardClosedIndictment.tsx (1 hunks)
- apps/judicial-system/web/src/routes/PublicProsecutor/Tables/CasesReviewed.strings.ts (1 hunks)
- apps/judicial-system/web/src/routes/PublicProsecutor/Tables/CasesReviewed.tsx (4 hunks)
- apps/judicial-system/web/src/routes/Shared/Cases/cases.graphql (2 hunks)
Files skipped from review due to trivial changes (2)
- apps/judicial-system/web/messages/Core/tables.ts
- apps/judicial-system/web/src/routes/PublicProsecutor/Tables/CasesReviewed.strings.ts
Additional Context Used
Biome (27)
apps/judicial-system/api/src/app/modules/case-list/interceptors/caseList.interceptor.ts (3)
1-1: All these imports are only used as types.
3-9: Some named imports are only used as types.
11-12: All these imports are only used as types.
apps/judicial-system/api/src/app/modules/case/interceptors/case.transformer.spec.ts (3)
522-537: Prefer for...of instead of forEach.
539-554: Prefer for...of instead of forEach.
9-10: All these imports are only used as types.
apps/judicial-system/api/src/app/modules/case/interceptors/case.transformer.ts (3)
1-7: Some named imports are only used as types.
8-9: All these imports are only used as types.
9-10: All these imports are only used as types.
apps/judicial-system/api/src/app/modules/case/models/case.model.ts (1)
8-25: Some named imports are only used as types.
apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.tsx (4)
98-98: Do not use template literals if interpolation and special-character handling are not needed.
1-1: Some named imports are only used as types.
3-10: Some named imports are only used as types.
11-12: All these imports are only used as types.
apps/judicial-system/web/src/components/InfoCard/InfoCard.tsx (8)
84-84: Do not use template literals if interpolation and special-character handling are not needed.
1-1: All these imports are only used as types.
3-4: Some named imports are only used as types.
4-8: Some named imports are only used as types.
9-13: Some named imports are only used as types.
91-91: Avoid using the index of an array as key property in an element.
126-135: Missing key property for this element in iterable.
180-180: Avoid using the index of an array as key property in an element.
apps/judicial-system/web/src/components/InfoCard/InfoCardClosedIndictment.tsx (2)
1-1: The default import is only used as a type.
11-12: All these imports are only used as types.
apps/judicial-system/web/src/routes/PublicProsecutor/Tables/CasesReviewed.tsx (3)
1-1: Some named imports are only used as types.
4-5: Some named imports are only used as types.
17-21: Some named imports are only used as types.
Path-based Instructions (12)
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."
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/defendant/models/defendant.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/components/InfoCard/InfoCardClosedIndictment.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/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/components/InfoCard/DefendantInfo/DefendantInfo.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/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/components/InfoCard/InfoCard.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/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 (1)
apps/judicial-system/web/src/routes/PublicProsecutor/Tables/CasesReviewed.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.
Additional comments not posted (11)
apps/judicial-system/api/src/app/modules/case-list/interceptors/caseList.interceptor.ts (1)
Line range hint
30-44
: Ensure proper error handling forgetIndictmentInfo
function calls.apps/judicial-system/web/src/routes/Shared/Cases/cases.graphql (1)
29-29
: Confirm that the backend schema supports the new fields added to the GraphQL query.Also applies to: 93-94
Verification successful
The backend schema supports the new fields added to the GraphQL query.
verdictViewDate
is present in multiple files, includingcase.graphql
,limitedAccessCase.graphql
, and various backend files.indictmentVerdictViewedByAll
is defined incase.graphql
,case.model.ts
, and other backend files.indictmentVerdictAppealDeadline
is also found incase.graphql
,case.model.ts
, and other backend files.These fields are correctly integrated into the backend schema.
Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify that the backend schema supports the new fields. # Test: Search for the new fields in the backend schema definitions. rg --type graphql $'type Case {.*verdictViewDate.*indictmentVerdictViewedByAll.*indictmentVerdictAppealDeadline.*}'Length of output: 304
Script:
#!/bin/bash # Description: Verify that the backend schema supports the new fields. # Test: Search for the new fields in the backend schema definitions. rg --type graphql 'type Case {[^}]*verdictViewDate[^}]*indictmentVerdictViewedByAll[^}]*indictmentVerdictAppealDeadline[^}]*}'Length of output: 328
Script:
#!/bin/bash # Description: Verify that the backend schema supports the new fields. # Test: Search for the new fields in the backend schema definitions. rg --type graphql 'type Case {[^}]*verdictViewDate[^}]*' | rg 'indictmentVerdictViewedByAll' | rg 'indictmentVerdictAppealDeadline'Length of output: 259
Script:
#!/bin/bash # Description: Verify that the backend schema supports the new fields. # Test: Search for the new fields in the backend schema definitions. rg --type graphql 'verdictViewDate' | rg 'indictmentVerdictViewedByAll' | rg 'indictmentVerdictAppealDeadline'Length of output: 138
Script:
#!/bin/bash # Description: Verify that the backend schema supports the new fields. # Test: Search for the new fields in the backend schema definitions. rg 'verdictViewDate' | rg 'indictmentVerdictViewedByAll' | rg 'indictmentVerdictAppealDeadline'Length of output: 91
Script:
#!/bin/bash # Description: Verify that the backend schema supports the new fields. # Test: Search for each new field in the backend schema definitions individually. rg 'verdictViewDate' rg 'indictmentVerdictViewedByAll' rg 'indictmentVerdictAppealDeadline'Length of output: 3745
apps/judicial-system/api/src/app/modules/defendant/models/defendant.model.ts (1)
69-70
: Confirm that theverdictAppealDeadline
field is supported in all relevant queries and mutations.Verification successful
The
verdictAppealDeadline
field is supported in relevant queries and mutations.
apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.tsx
apps/judicial-system/web/src/components/FormProvider/case.graphql
apps/judicial-system/api/src/app/modules/defendant/models/defendant.model.ts
apps/judicial-system/api/src/app/modules/case/interceptors/case.transformer.ts
Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify that the `verdictAppealDeadline` field is supported in all relevant queries and mutations. # Test: Search for the field in GraphQL queries and mutations. rg --type graphql $'verdictAppealDeadline'Length of output: 73
Script:
#!/bin/bash # Description: Verify that the `verdictAppealDeadline` field is supported in all relevant queries and mutations. # Test: Search for the field in GraphQL queries and mutations. rg --type gql $'verdictAppealDeadline'Length of output: 65
Script:
#!/bin/bash # Description: Verify that the `verdictAppealDeadline` field is supported in all relevant queries and mutations. # Test: Search for the field in all files. rg 'verdictAppealDeadline'Length of output: 533
apps/judicial-system/api/src/app/modules/case-list/models/caseList.model.ts (1)
118-122
: Confirm that the new fieldsindictmentVerdictViewedByAll
andindictmentVerdictAppealDeadline
are supported in all relevant queries and mutations.Verification successful
Let's correct the file type for GraphQL and re-run the search to verify if the new fields are supported in all relevant queries and mutations.
The new fields
indictmentVerdictViewedByAll
andindictmentVerdictAppealDeadline
are supported in the relevant GraphQL queries and mutations.
apps/judicial-system/web/src/routes/Shared/Cases/cases.graphql
apps/judicial-system/web/src/components/FormProvider/case.graphql
Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify that the new fields are supported in all relevant queries and mutations. # Test: Search for the fields in GraphQL queries and mutations. rg --type graphql $'indictmentVerdictViewedByAll.*indictmentVerdictAppealDeadline'Length of output: 115
Script:
#!/bin/bash # Description: Verify that the new fields are supported in all relevant queries and mutations. # Test: Search for the fields in GraphQL queries and mutations. rg --type-add 'graphql:*.graphql' --type graphql 'indictmentVerdictViewedByAll|indictmentVerdictAppealDeadline'Length of output: 509
apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.tsx (1)
83-89
: Ensure that thedisplayAppealExpirationInfo
prop is properly passed and used in the component.Verification successful
The
displayAppealExpirationInfo
prop is properly passed and used in theDefendantInfo
component and its parent components.
The prop is defined and used in
DefendantInfo.tsx
.It is passed from
InfoCard.tsx
andInfoCardClosedIndictment.tsx
.Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify that the `displayAppealExpirationInfo` prop is properly passed and used. # Test: Search for the prop usage in the component. rg --type typescript $'displayAppealExpirationInfo' ./apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.tsxLength of output: 168
Script:
#!/bin/bash # Description: Verify that the `displayAppealExpirationInfo` prop is properly passed and used. # Test 1: Search for the prop usage in the DefendantInfo component. rg 'displayAppealExpirationInfo' ./apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.tsx # Test 2: Search for the prop being passed from parent components. rg 'displayAppealExpirationInfo' ./apps/judicial-system/web/src/components/InfoCard/Length of output: 1149
apps/judicial-system/web/src/routes/PublicProsecutor/Tables/CasesReviewed.tsx (3)
5-5
: Ensure proper usage of newly imported components.
114-114
: EnsuregetVerdictViewTag
is called with the correct data.
85-85
: Verify the new column addition aligns with UI design specifications.apps/judicial-system/web/src/components/InfoCard/InfoCard.tsx (1)
129-131
: Verify thatdisplayAppealExpirationInfo
is correctly passed and used within the component.apps/judicial-system/api/src/app/modules/case/models/case.model.ts (1)
432-436
: Confirm that the new fields are integrated into the system's data flow and properly indexed for performance.apps/judicial-system/api/src/app/modules/case/interceptors/case.transformer.spec.ts (1)
578-578
: Ensure the calculation ofindictmentAppealDeadline
aligns with business requirements.
apps/judicial-system/web/src/routes/PublicProsecutor/Tables/CasesReviewed.tsx
Outdated
Show resolved
Hide resolved
apps/judicial-system/api/src/app/modules/case/interceptors/case.transformer.ts
Outdated
Show resolved
Hide resolved
apps/judicial-system/web/src/components/InfoCard/InfoCardClosedIndictment.tsx
Show resolved
Hide resolved
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #14922 +/- ##
==========================================
- Coverage 37.08% 37.06% -0.02%
==========================================
Files 6354 6353 -1
Lines 129445 129485 +40
Branches 36960 36978 +18
==========================================
- Hits 48005 48000 -5
- Misses 81440 81485 +45
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 3 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
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: 1
Review Details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Files selected for processing (1)
- apps/judicial-system/web/src/routes/PublicProsecutor/Tables/CasesReviewed.tsx (4 hunks)
Additional Context Used
Biome (2)
apps/judicial-system/web/src/routes/PublicProsecutor/Tables/CasesReviewed.tsx (2)
1-1: Some named imports are only used as types.
17-21: Some named imports are only used as types.
Path-based Instructions (1)
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."
Learnings (1)
apps/judicial-system/web/src/routes/PublicProsecutor/Tables/CasesReviewed.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.
Additional comments not posted (1)
apps/judicial-system/web/src/routes/PublicProsecutor/Tables/CasesReviewed.tsx (1)
81-81
: New column for verdict view state added appropriately.This addition enhances the display of indictment information as intended.
apps/judicial-system/web/src/routes/PublicProsecutor/Tables/CasesReviewed.tsx
Show resolved
Hide resolved
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: 2
Outside diff range and nitpick comments (1)
apps/judicial-system/api/src/app/modules/case/interceptors/case.transformer.ts (1)
Line range hint
99-137
: Consider optimizing the mapping ofverdictViewDates
to avoid unnecessary operations.- const verdictViewDates = defendants?.map( - (defendant) => defendant.verdictViewDate, - ) + const verdictViewDates = defendants?.map(({ verdictViewDate }) => verdictViewDate)
Review Details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Files selected for processing (1)
- apps/judicial-system/api/src/app/modules/case/interceptors/case.transformer.ts (5 hunks)
Additional Context Used
Biome (3)
apps/judicial-system/api/src/app/modules/case/interceptors/case.transformer.ts (3)
1-7: Some named imports are only used as types.
8-9: All these imports are only used as types.
9-10: All these imports are only used as types.
Path-based Instructions (1)
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."
Additional comments not posted (1)
apps/judicial-system/api/src/app/modules/case/interceptors/case.transformer.ts (1)
Line range hint
160-190
: The integration of case information intransformCase
function is well-implemented.
apps/judicial-system/api/src/app/modules/case/interceptors/case.transformer.ts
Outdated
Show resolved
Hide resolved
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: 3
Review Details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Files selected for processing (1)
- apps/judicial-system/api/src/app/modules/case/interceptors/case.transformer.ts (5 hunks)
Additional Context Used
Biome (3)
apps/judicial-system/api/src/app/modules/case/interceptors/case.transformer.ts (3)
1-7: Some named imports are only used as types.
8-9: All these imports are only used as types.
9-10: All these imports are only used as types.
Path-based Instructions (1)
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."
Additional comments not posted (2)
apps/judicial-system/api/src/app/modules/case/interceptors/case.transformer.ts (2)
Line range hint
160-190
: Ensure thetransformCase
function integrates the new changes effectively.
Line range hint
99-137
: Review the logic ingetIndictmentInfo
for handlingdefendants
.
apps/judicial-system/api/src/app/modules/case/interceptors/case.transformer.ts
Outdated
Show resolved
Hide resolved
apps/judicial-system/api/src/app/modules/case/interceptors/case.transformer.ts
Show resolved
Hide resolved
…s/island.is into j-s/indictment-view-tag
apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.tsx
Outdated
Show resolved
Hide resolved
apps/judicial-system/web/src/routes/PublicProsecutor/Tables/CasesReviewed.tsx
Outdated
Show resolved
Hide resolved
apps/judicial-system/web/src/routes/PublicProsecutor/Tables/CasesReviewed.tsx
Show resolved
Hide resolved
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: 3
Outside diff range and nitpick comments (1)
apps/judicial-system/api/src/app/modules/case/interceptors/case.transformer.ts (1)
Line range hint
99-137
: Review the logic ingetIndictmentInfo
for potential optimizations.Consider refactoring the logic to reduce complexity and improve readability. For example, the handling of
verdictViewDates
and the calculation ofexpiryDate
could be simplified or broken down into smaller helper functions.
Review Details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Files selected for processing (3)
- apps/judicial-system/api/src/app/modules/case/interceptors/case.transformer.ts (5 hunks)
- apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.tsx (2 hunks)
- apps/judicial-system/web/src/routes/PublicProsecutor/Tables/CasesReviewed.tsx (3 hunks)
Additional Context Used
Biome (9)
apps/judicial-system/api/src/app/modules/case/interceptors/case.transformer.ts (3)
1-7: Some named imports are only used as types.
8-9: All these imports are only used as types.
9-10: All these imports are only used as types.
apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.tsx (4)
98-98: Do not use template literals if interpolation and special-character handling are not needed.
1-1: Some named imports are only used as types.
3-10: Some named imports are only used as types.
11-12: All these imports are only used as types.
apps/judicial-system/web/src/routes/PublicProsecutor/Tables/CasesReviewed.tsx (2)
1-1: Some named imports are only used as types.
17-21: Some named imports are only used as types.
Path-based Instructions (3)
apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.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/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/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."
Learnings (1)
apps/judicial-system/web/src/routes/PublicProsecutor/Tables/CasesReviewed.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.
Additional comments not posted (3)
apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.tsx (2)
83-89
: Ensure conditional rendering based ondisplayAppealExpirationInfo
is intentional.Verification successful
The conditional rendering based on
displayAppealExpirationInfo
appears to be unique to theDefendantInfo
component, suggesting that it is intentional.
- Location:
apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.tsx
Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify if the conditional rendering based on `displayAppealExpirationInfo` is consistent across the application. # Test: Search for similar conditional renderings in other components. rg --type javascript 'displayAppealExpirationInfo &&'Length of output: 90
Script:
#!/bin/bash # Description: Verify if the conditional rendering based on `displayAppealExpirationInfo` is consistent across the application. # Test: Search for similar conditional renderings in other components. rg --type ts 'displayAppealExpirationInfo &&'Length of output: 170
28-28
: Consider adding a default value or handling fordisplayAppealExpirationInfo
.apps/judicial-system/web/src/routes/PublicProsecutor/Tables/CasesReviewed.tsx (1)
43-60
: RefactorgetVerdictViewTag
for improved clarity and efficiency.
[REFACTOR_SUGGESTion]- const getVerdictViewTag = (row: CaseListEntry) => { - const today = new Date() - const deadline = new Date(row.indictmentVerdictAppealDeadline ?? '') - const variant = !row.indictmentVerdictViewedByAll ? 'red' : - (today < deadline ? 'mint' : 'blue') - const message = !row.indictmentVerdictViewedByAll ? strings.tagVerdictUnviewed : - (today < deadline ? strings.tagVerdictViewComplete : strings.tagVerdictViewOnDeadline) - return <Tag variant={variant} outlined disabled truncate>{formatMessage(message)}</Tag> - } + const getVerdictViewTag = (row: CaseListEntry) => { + const today = new Date() + const deadline = new Date(row.indictmentVerdictAppealDeadline ?? '') + const variant = !row.indictmentVerdictViewedByAll ? 'red' : + (today > deadline ? 'mint' : 'blue') + const message = !row.indictmentVerdictViewedByAll ? strings.tagVerdictUnviewed : + (today > deadline ? strings.tagVerdictViewComplete : strings.tagVerdictViewOnDeadline) + return <Tag variant={variant} outlined disabled truncate>{formatMessage(message)}</Tag> + }
apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.tsx
Outdated
Show resolved
Hide resolved
apps/judicial-system/api/src/app/modules/case/interceptors/case.transformer.ts
Show resolved
Hide resolved
apps/judicial-system/api/src/app/modules/case/interceptors/case.transformer.ts
Show resolved
Hide resolved
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 (3)
apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.tsx (1)
Line range hint
98-98
: Avoid using template literals if interpolation and special-character handling are not needed.- <Text as="span">{`${formatMessage(strings.defender)}: ${defendant.defenderName}`}</Text> + <Text as="span">{formatMessage(strings.defender) + ': ' + defendant.defenderName}</Text>This change simplifies the string construction by using concatenation instead of template literals, as there's no complex expression involved.
apps/judicial-system/web/src/components/InfoCard/InfoCard.tsx (2)
Line range hint
91-91
: Avoid using the index of an array as a key property in React elements.- <Text key={dataItem.title}> + <Text key={`dataItem-${index}-${dataItem.title}`}>Using array indices as keys in React can lead to issues with component state and re-rendering. It's better to use a unique identifier, such as a combination of the index and the item's title, to ensure stability during updates.
Also applies to: 181-181
Line range hint
84-84
: Avoid using template literals if interpolation and special-character handling are not needed.- <Text>{`${defender.phoneNumber ? ', s. ' + defender.phoneNumber : ''}`}</Text> + <Text>{defender.phoneNumber ? ', s. ' + defender.phoneNumber : ''}</Text>This change simplifies the string construction by using conditional rendering instead of template literals, as there's no complex expression involved.
Review Details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Files selected for processing (2)
- apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.tsx (3 hunks)
- apps/judicial-system/web/src/components/InfoCard/InfoCard.tsx (2 hunks)
Additional Context Used
Biome (11)
apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.tsx (4)
98-98: Do not use template literals if interpolation and special-character handling are not needed.
1-1: Some named imports are only used as types.
3-10: Some named imports are only used as types.
11-12: All these imports are only used as types.
apps/judicial-system/web/src/components/InfoCard/InfoCard.tsx (7)
84-84: Do not use template literals if interpolation and special-character handling are not needed.
1-1: All these imports are only used as types.
3-4: Some named imports are only used as types.
4-8: Some named imports are only used as types.
9-13: Some named imports are only used as types.
91-91: Avoid using the index of an array as key property in an element.
181-181: Avoid using the index of an array as key property in an element.
Path-based Instructions (2)
apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.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/InfoCard/InfoCard.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 (2)
apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.tsx (1)
User: unakb PR: island-is/island.is#14922 File: apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.tsx:43-49 Timestamp: 2024-05-27T10:53:40.687Z Learning: The `getAppealExpirationInfo` function in `DefendantInfo.tsx` correctly uses `today < expiryDate` to determine if the current date is before the appeal expiration date.
apps/judicial-system/web/src/components/InfoCard/InfoCard.tsx (1)
User: unakb PR: island-is/island.is#14922 File: apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.tsx:43-49 Timestamp: 2024-05-27T10:53:40.687Z Learning: The `getAppealExpirationInfo` function in `DefendantInfo.tsx` correctly uses `today < expiryDate` to determine if the current date is before the appeal expiration date.
Additional comments not posted (4)
apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.tsx (2)
28-28
: Added optionaldisplayAppealExpirationInfo
property toDefendantInfoProps
.This change allows conditional rendering of appeal expiration information, aligning with the PR's objectives to enhance the display of indictment and defendant information.
83-89
: Conditional rendering of appeal expiration information based ondisplayAppealExpirationInfo
.This implementation ensures that the appeal expiration information is displayed only when appropriate, which is a good use of React's conditional rendering capabilities.
apps/judicial-system/web/src/components/InfoCard/InfoCard.tsx (2)
41-41
: Added optionaldisplayAppealExpirationInfo
property to thedefendants
object inProps
.This addition supports the conditional display of appeal expiration information in the
InfoCard
component, enhancing the flexibility of the component in different contexts.
127-132
: Proper propagation ofdisplayAppealExpirationInfo
toDefendantInfo
component.This ensures that the
displayAppealExpirationInfo
property is correctly passed down fromInfoCard
toDefendantInfo
, maintaining consistency in the component hierarchy.
Bæta birtingartöggum á listasíðu
What
Added tags to public prosecutor case table of reviewed cases
Fixed infocard that was displaying indictment appealed deadline when it shouldn't
Checklist:
Summary by CodeRabbit
New Features
Enhancements
User Interface