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): Indictment View Tag #14922

Merged
merged 17 commits into from
May 27, 2024
Merged

feat(j-s): Indictment View Tag #14922

merged 17 commits into from
May 27, 2024

Conversation

unakb
Copy link
Member

@unakb unakb commented May 24, 2024

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:

  • 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 the ability to display appeal expiration information for defendants in the judicial system web application.
  • Enhancements

    • Updated InfoCard and DefendantInfo components to conditionally render appeal expiration details based on new optional properties.
  • User Interface

    • Enhanced defendant information display with new appeal expiration details, improving clarity and user experience.

@unakb unakb requested a review from a team as a code owner May 24, 2024 11:27
@unakb unakb changed the title J s/indictment view tag feat(j-s): Indictment View Tag May 24, 2024

This comment was marked as off-topic.

@datadog-island-is
Copy link

datadog-island-is bot commented May 24, 2024

Datadog Report

All test runs c5179a0 🔗

2 Total Test Services: 0 Failed, 2 Passed
🔻 Test Sessions change in coverage: 2 decreased

Test Services
Service Name Failed Known Flaky New Flaky Passed Skipped Total Time Code Coverage Change Test Service View
judicial-system-api 0 0 0 54 0 12.01s 1 decreased (-0.05%) Link
judicial-system-web 0 0 0 312 0 1m 11.58s 1 decreased (-0.05%) Link

🔻 Code Coverage Decreases vs Default Branch (2)

  • judicial-system-api - jest 18.94% (-0.05%) - Details
  • judicial-system-web - jest 32.36% (-0.05%) - Details

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

Outside diff range and nitpick comments (5)
apps/judicial-system/web/src/components/FormProvider/case.graphql (1)

27-27: Ensure the new field verdictAppealDeadline 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: Refactor getIndictmentInfo 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 prop displayAppealExpirationInfo is properly documented.

apps/judicial-system/api/src/app/modules/case/interceptors/case.transformer.spec.ts (2)

Line range hint 9-10: Consider using import 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 using for...of instead of forEach 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

Commits Files that changed from the base of the PR and between 38a0b33 and 0cf7abe.
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 for getIndictmentInfo 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, including case.graphql, limitedAccessCase.graphql, and various backend files.
  • indictmentVerdictViewedByAll is defined in case.graphql, case.model.ts, and other backend files.
  • indictmentVerdictAppealDeadline is also found in case.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 the verdictAppealDeadline 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 fields indictmentVerdictViewedByAll and indictmentVerdictAppealDeadline 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 and indictmentVerdictAppealDeadline 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 the displayAppealExpirationInfo prop is properly passed and used in the component.

Verification successful

The displayAppealExpirationInfo prop is properly passed and used in the DefendantInfo component and its parent components.

  • The prop is defined and used in DefendantInfo.tsx.

  • It is passed from InfoCard.tsx and InfoCardClosedIndictment.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.tsx

Length 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: Ensure getVerdictViewTag 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 that displayAppealExpirationInfo 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 of indictmentAppealDeadline aligns with business requirements.

Copy link

codecov bot commented May 24, 2024

Codecov Report

Attention: Patch coverage is 20.96774% with 49 lines in your changes are missing coverage. Please review.

Project coverage is 37.06%. Comparing base (aab28bd) to head (8f5a414).

Additional details and impacted files

Impacted file tree graph

@@            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     
Flag Coverage Δ
api 3.48% <ø> (ø)
application-system-api 41.90% <ø> (ø)
application-template-api-modules 24.33% <ø> (+0.01%) ⬆️
application-ui-shell 21.73% <ø> (ø)
judicial-system-api 17.63% <25.00%> (+0.01%) ⬆️
judicial-system-audit-trail 67.31% <ø> (ø)

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

Files Coverage Δ
apps/judicial-system/web/messages/Core/tables.ts 100.00% <ø> (ø)
...al-system/web/src/components/InfoCard/InfoCard.tsx 76.08% <100.00%> (ø)
...c/components/InfoCard/InfoCardClosedIndictment.tsx 7.69% <ø> (ø)
...s/PublicProsecutor/Tables/CasesReviewed.strings.ts 0.00% <ø> (ø)
...les/case-list/interceptors/caseList.interceptor.ts 0.00% <0.00%> (ø)
...rc/app/modules/defendant/models/defendant.model.ts 0.00% <0.00%> (ø)
...omponents/InfoCard/DefendantInfo/DefendantInfo.tsx 45.16% <40.00%> (-10.02%) ⬇️
...src/app/modules/case-list/models/caseList.model.ts 0.00% <0.00%> (ø)
...stem/api/src/app/modules/case/models/case.model.ts 0.00% <0.00%> (ø)
...c/routes/PublicProsecutor/Tables/CasesReviewed.tsx 0.00% <0.00%> (ø)
... and 1 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 aab28bd...8f5a414. Read the comment docs.

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 0cf7abe and d58efca.
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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Outside diff range and nitpick comments (1)
apps/judicial-system/api/src/app/modules/case/interceptors/case.transformer.ts (1)

Line range hint 99-137: Consider optimizing the mapping of verdictViewDates 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

Commits Files that changed from the base of the PR and between d58efca and b3696e2.
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 in transformCase function is well-implemented.

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

Review Details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits Files that changed from the base of the PR and between b3696e2 and 54cbff8.
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 the transformCase function integrates the new changes effectively.


Line range hint 99-137: Review the logic in getIndictmentInfo for handling defendants.

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 (1)
apps/judicial-system/api/src/app/modules/case/interceptors/case.transformer.ts (1)

Line range hint 99-137: Review the logic in getIndictmentInfo for potential optimizations.

Consider refactoring the logic to reduce complexity and improve readability. For example, the handling of verdictViewDates and the calculation of expiryDate could be simplified or broken down into smaller helper functions.

Review Details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits Files that changed from the base of the PR and between 54cbff8 and cf6b6bf.
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 on displayAppealExpirationInfo is intentional.

Verification successful

The conditional rendering based on displayAppealExpirationInfo appears to be unique to the DefendantInfo 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 for displayAppealExpirationInfo.

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

43-60: Refactor getVerdictViewTag 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>
+ }

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

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

Commits Files that changed from the base of the PR and between cf6b6bf and 8f5a414.
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 optional displayAppealExpirationInfo property to DefendantInfoProps.

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 on displayAppealExpirationInfo.

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 optional displayAppealExpirationInfo property to the defendants object in Props.

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 of displayAppealExpirationInfo to DefendantInfo component.

This ensures that the displayAppealExpirationInfo property is correctly passed down from InfoCard to DefendantInfo, maintaining consistency in the component hierarchy.

@kodiakhq kodiakhq bot merged commit 2ac562a into main May 27, 2024
44 checks passed
@kodiakhq kodiakhq bot deleted the j-s/indictment-view-tag branch May 27, 2024 13:13
@coderabbitai coderabbitai bot mentioned this pull request Oct 4, 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.

3 participants