-
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
chore(j-s): Refactor TagCaseState component #17844
base: main
Are you sure you want to change the base?
Conversation
WalkthroughThis pull request refactors how the Changes
Sequence Diagram(s)sequenceDiagram
participant Parent as Parent Component
participant TCS as TagCaseState Component
participant UC as UserContext
Parent->>TCS: Pass `theCase` prop (case data)
TCS->>UC: Retrieve user details
TCS->>TCS: Map case state to tag variant using `theCase` and user
TCS-->>Parent: Render tag with computed variant
Possibly related PRs
Suggested labels
Suggested reviewers
Tip 🌐 Web search-backed reviews and chat
✨ Finishing Touches
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 using PR comments)
Other keywords and placeholders
Documentation and Community
|
View your CI Pipeline Execution ↗ for commit 04c6b51.
☁️ Nx Cloud last updated this comment at |
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
🧹 Nitpick comments (1)
apps/judicial-system/web/src/components/Tags/TagCaseState/TagCaseState.tsx (1)
61-139
: Consider refactoring complex conditional logic.The
mapCaseStateToTagVariant
function contains complex nested conditions that could be simplified for better maintainability.Consider extracting the subpoena service check and indictment decision handling into separate functions:
+const isAwaitingSubpoenaService = (theCase: CaseListEntry): boolean => { + return ( + isIndictmentCase(theCase.type) && + theCase.defendants && + theCase.courtDate && + !haveAllSubpoenasBeenServiced(theCase.defendants) + ) +} +const getIndictmentDecisionTag = ( + decision: IndictmentDecision, + formatMessage: IntlShape['formatMessage'], +): CaseStateTag | null => { + switch (decision) { + case IndictmentDecision.POSTPONING: + case IndictmentDecision.SCHEDULING: + case IndictmentDecision.COMPLETING: + return { color: 'mint', text: formatMessage(strings.scheduled) } + // ... other cases + } + return null +}
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (14)
apps/judicial-system/web/src/components/PageTitle/PageTitle.tsx
(2 hunks)apps/judicial-system/web/src/components/Table/PastCasesTable/PastCasesTable.tsx
(1 hunks)apps/judicial-system/web/src/components/Table/Table.tsx
(0 hunks)apps/judicial-system/web/src/components/Tags/TagCaseState/TagCaseState.spec.ts
(7 hunks)apps/judicial-system/web/src/components/Tags/TagCaseState/TagCaseState.tsx
(6 hunks)apps/judicial-system/web/src/routes/Court/components/CasesAwaitingAssignmentTable/CasesAwaitingAssignmentTable.tsx
(1 hunks)apps/judicial-system/web/src/routes/Court/components/CasesInProgressTable/CasesInProgressTable.tsx
(1 hunks)apps/judicial-system/web/src/routes/Defender/Cases/components/DefenderCasesTable.tsx
(1 hunks)apps/judicial-system/web/src/routes/Prosecutor/components/CasesAwaitingConfirmationTable/CasesAwaitingConfirmationTable.tsx
(1 hunks)apps/judicial-system/web/src/routes/PublicProsecutor/Tables/CasesAwaitingReview.tsx
(1 hunks)apps/judicial-system/web/src/routes/PublicProsecutor/Tables/CasesForReview.tsx
(1 hunks)apps/judicial-system/web/src/routes/Shared/Cases/ActiveCases.tsx
(1 hunks)apps/judicial-system/web/src/routes/Shared/Cases/MobileCase.tsx
(1 hunks)apps/judicial-system/web/src/routes/Shared/Cases/PrisonCases.tsx
(1 hunks)
💤 Files with no reviewable changes (1)
- apps/judicial-system/web/src/components/Table/Table.tsx
🧰 Additional context used
📓 Path-based instructions (1)
`apps/**/*`: "Confirm that the code adheres to the following...
apps/**/*
: "Confirm that the code adheres to the following:
- NextJS best practices, including file structure, API routes, and static generation methods.
- Efficient state management and server-side rendering techniques.
- Optimal use of TypeScript for component and utility type safety."
apps/judicial-system/web/src/routes/Court/components/CasesInProgressTable/CasesInProgressTable.tsx
apps/judicial-system/web/src/components/PageTitle/PageTitle.tsx
apps/judicial-system/web/src/routes/Court/components/CasesAwaitingAssignmentTable/CasesAwaitingAssignmentTable.tsx
apps/judicial-system/web/src/routes/PublicProsecutor/Tables/CasesForReview.tsx
apps/judicial-system/web/src/routes/Shared/Cases/ActiveCases.tsx
apps/judicial-system/web/src/routes/Prosecutor/components/CasesAwaitingConfirmationTable/CasesAwaitingConfirmationTable.tsx
apps/judicial-system/web/src/routes/PublicProsecutor/Tables/CasesAwaitingReview.tsx
apps/judicial-system/web/src/routes/Shared/Cases/PrisonCases.tsx
apps/judicial-system/web/src/routes/Shared/Cases/MobileCase.tsx
apps/judicial-system/web/src/components/Tags/TagCaseState/TagCaseState.spec.ts
apps/judicial-system/web/src/components/Table/PastCasesTable/PastCasesTable.tsx
apps/judicial-system/web/src/routes/Defender/Cases/components/DefenderCasesTable.tsx
apps/judicial-system/web/src/components/Tags/TagCaseState/TagCaseState.tsx
📓 Learnings (11)
apps/judicial-system/web/src/routes/Court/components/CasesInProgressTable/CasesInProgressTable.tsx (2)
Learnt from: gudjong
PR: island-is/island.is#16760
File: apps/judicial-system/web/src/routes/Shared/Cases/PrisonCases.tsx:112-118
Timestamp: 2024-11-12T15:15:11.835Z
Learning: In `apps/judicial-system/web/src/routes/Prosecutor/components/CasesAwaitingConfirmationTable/CasesAwaitingConfirmationTable.tsx`, `apps/judicial-system/web/src/routes/Court/components/CasesAwaitingAssignmentTable/CasesAwaitingAssignmentTable.tsx`, and one instance in `apps/judicial-system/web/src/routes/Shared/Cases/PrisonCases.tsx`, it's correct to pass only the `type` prop to `ColumnCaseType` without the `decision` and `parentCaseId` props.
Learnt from: oddsson
PR: island-is/island.is#14673
File: apps/judicial-system/web/src/routes/PublicProsecutor/Tables/CasesForReview.tsx:79-79
Timestamp: 2024-11-12T15:15:11.835Z
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.
apps/judicial-system/web/src/routes/Court/components/CasesAwaitingAssignmentTable/CasesAwaitingAssignmentTable.tsx (2)
Learnt from: gudjong
PR: island-is/island.is#16760
File: apps/judicial-system/web/src/routes/Shared/Cases/PrisonCases.tsx:112-118
Timestamp: 2024-11-12T15:15:11.835Z
Learning: In `apps/judicial-system/web/src/routes/Prosecutor/components/CasesAwaitingConfirmationTable/CasesAwaitingConfirmationTable.tsx`, `apps/judicial-system/web/src/routes/Court/components/CasesAwaitingAssignmentTable/CasesAwaitingAssignmentTable.tsx`, and one instance in `apps/judicial-system/web/src/routes/Shared/Cases/PrisonCases.tsx`, it's correct to pass only the `type` prop to `ColumnCaseType` without the `decision` and `parentCaseId` props.
Learnt from: oddsson
PR: island-is/island.is#14673
File: apps/judicial-system/web/src/routes/PublicProsecutor/Tables/CasesForReview.tsx:79-79
Timestamp: 2024-11-12T15:15:11.835Z
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.
apps/judicial-system/web/src/routes/PublicProsecutor/Tables/CasesForReview.tsx (3)
Learnt from: oddsson
PR: island-is/island.is#14673
File: apps/judicial-system/web/src/routes/PublicProsecutor/Tables/CasesForReview.tsx:79-79
Timestamp: 2024-11-12T15:15:11.835Z
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.
Learnt from: gudjong
PR: island-is/island.is#16760
File: apps/judicial-system/web/src/routes/Shared/Cases/PrisonCases.tsx:112-118
Timestamp: 2024-11-12T15:15:11.835Z
Learning: In `apps/judicial-system/web/src/routes/Prosecutor/components/CasesAwaitingConfirmationTable/CasesAwaitingConfirmationTable.tsx`, `apps/judicial-system/web/src/routes/Court/components/CasesAwaitingAssignmentTable/CasesAwaitingAssignmentTable.tsx`, and one instance in `apps/judicial-system/web/src/routes/Shared/Cases/PrisonCases.tsx`, it's correct to pass only the `type` prop to `ColumnCaseType` without the `decision` and `parentCaseId` props.
Learnt from: unakb
PR: island-is/island.is#15378
File: apps/judicial-system/web/src/routes/Court/Indictments/Summary/Summary.tsx:86-100
Timestamp: 2024-11-12T15:15:11.835Z
Learning: User unakb prefers explicit case handling in switch statements for key functionalities like `getRulingDecisionTagColor` to ensure clarity and avoid assumptions that a case was overlooked.
apps/judicial-system/web/src/routes/Shared/Cases/ActiveCases.tsx (5)
Learnt from: gudjong
PR: island-is/island.is#16760
File: apps/judicial-system/web/src/routes/Shared/Cases/PrisonCases.tsx:112-118
Timestamp: 2024-11-12T15:15:11.835Z
Learning: In `apps/judicial-system/web/src/routes/Prosecutor/components/CasesAwaitingConfirmationTable/CasesAwaitingConfirmationTable.tsx`, `apps/judicial-system/web/src/routes/Court/components/CasesAwaitingAssignmentTable/CasesAwaitingAssignmentTable.tsx`, and one instance in `apps/judicial-system/web/src/routes/Shared/Cases/PrisonCases.tsx`, it's correct to pass only the `type` prop to `ColumnCaseType` without the `decision` and `parentCaseId` props.
Learnt from: oddsson
PR: island-is/island.is#14673
File: apps/judicial-system/web/src/routes/PublicProsecutor/Tables/CasesForReview.tsx:79-79
Timestamp: 2024-11-12T15:15:11.835Z
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.
Learnt from: oddsson
PR: island-is/island.is#16939
File: apps/judicial-system/web/src/components/Table/PastCasesTable/PastCasesTable.tsx:136-139
Timestamp: 2024-11-20T10:15:04.980Z
Learning: The properties `isValidToDateInThePast`, `indictmentRulingDecision`, and `indictmentDecision` are defined in the `CaseListEntry` interface used in the `PastCasesTable` component.
Learnt from: oddsson
PR: island-is/island.is#16939
File: apps/judicial-system/web/src/components/Table/PastCasesTable/PastCasesTable.tsx:126-131
Timestamp: 2024-11-19T21:47:09.093Z
Learning: The `CaseListEntry` interface in `@island.is/judicial-system-web/src/graphql/schema` includes the properties `isValidToDateInThePast`, `indictmentRulingDecision`, and `indictmentDecision`.
Learnt from: oddsson
PR: island-is/island.is#17611
File: apps/judicial-system/web/src/components/Table/Table.spec.tsx:101-101
Timestamp: 2025-01-24T06:55:16.117Z
Learning: The case entity retains the `created` field even after introducing `caseSentToCourtDate`.
apps/judicial-system/web/src/routes/Prosecutor/components/CasesAwaitingConfirmationTable/CasesAwaitingConfirmationTable.tsx (2)
Learnt from: oddsson
PR: island-is/island.is#14673
File: apps/judicial-system/web/src/routes/PublicProsecutor/Tables/CasesForReview.tsx:79-79
Timestamp: 2024-11-12T15:15:11.835Z
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.
Learnt from: gudjong
PR: island-is/island.is#16760
File: apps/judicial-system/web/src/routes/Shared/Cases/PrisonCases.tsx:112-118
Timestamp: 2024-11-12T15:15:11.835Z
Learning: In `apps/judicial-system/web/src/routes/Prosecutor/components/CasesAwaitingConfirmationTable/CasesAwaitingConfirmationTable.tsx`, `apps/judicial-system/web/src/routes/Court/components/CasesAwaitingAssignmentTable/CasesAwaitingAssignmentTable.tsx`, and one instance in `apps/judicial-system/web/src/routes/Shared/Cases/PrisonCases.tsx`, it's correct to pass only the `type` prop to `ColumnCaseType` without the `decision` and `parentCaseId` props.
apps/judicial-system/web/src/routes/PublicProsecutor/Tables/CasesAwaitingReview.tsx (2)
Learnt from: oddsson
PR: island-is/island.is#14673
File: apps/judicial-system/web/src/routes/PublicProsecutor/Tables/CasesForReview.tsx:79-79
Timestamp: 2024-11-12T15:15:11.835Z
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.
Learnt from: gudjong
PR: island-is/island.is#16760
File: apps/judicial-system/web/src/routes/Shared/Cases/PrisonCases.tsx:112-118
Timestamp: 2024-11-12T15:15:11.835Z
Learning: In `apps/judicial-system/web/src/routes/Prosecutor/components/CasesAwaitingConfirmationTable/CasesAwaitingConfirmationTable.tsx`, `apps/judicial-system/web/src/routes/Court/components/CasesAwaitingAssignmentTable/CasesAwaitingAssignmentTable.tsx`, and one instance in `apps/judicial-system/web/src/routes/Shared/Cases/PrisonCases.tsx`, it's correct to pass only the `type` prop to `ColumnCaseType` without the `decision` and `parentCaseId` props.
apps/judicial-system/web/src/routes/Shared/Cases/PrisonCases.tsx (3)
Learnt from: gudjong
PR: island-is/island.is#16760
File: apps/judicial-system/web/src/routes/Shared/Cases/PrisonCases.tsx:112-118
Timestamp: 2024-11-12T15:15:11.835Z
Learning: In `apps/judicial-system/web/src/routes/Prosecutor/components/CasesAwaitingConfirmationTable/CasesAwaitingConfirmationTable.tsx`, `apps/judicial-system/web/src/routes/Court/components/CasesAwaitingAssignmentTable/CasesAwaitingAssignmentTable.tsx`, and one instance in `apps/judicial-system/web/src/routes/Shared/Cases/PrisonCases.tsx`, it's correct to pass only the `type` prop to `ColumnCaseType` without the `decision` and `parentCaseId` props.
Learnt from: thorhildurt
PR: island-is/island.is#17285
File: apps/judicial-system/web/src/routes/Shared/Cases/PrisonCases.tsx:223-225
Timestamp: 2024-12-18T17:15:59.181Z
Learning: The system currently only allows adding one defendant, so the punishment type logic in the table can default to the first defendant, with a plan to support multiple defendants in the future.
Learnt from: oddsson
PR: island-is/island.is#14673
File: apps/judicial-system/web/src/routes/PublicProsecutor/Tables/CasesForReview.tsx:79-79
Timestamp: 2024-11-12T15:15:11.835Z
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.
apps/judicial-system/web/src/routes/Shared/Cases/MobileCase.tsx (1)
Learnt from: gudjong
PR: island-is/island.is#16760
File: apps/judicial-system/web/src/routes/Shared/Cases/PrisonCases.tsx:112-118
Timestamp: 2024-11-12T15:15:11.835Z
Learning: In `apps/judicial-system/web/src/routes/Prosecutor/components/CasesAwaitingConfirmationTable/CasesAwaitingConfirmationTable.tsx`, `apps/judicial-system/web/src/routes/Court/components/CasesAwaitingAssignmentTable/CasesAwaitingAssignmentTable.tsx`, and one instance in `apps/judicial-system/web/src/routes/Shared/Cases/PrisonCases.tsx`, it's correct to pass only the `type` prop to `ColumnCaseType` without the `decision` and `parentCaseId` props.
apps/judicial-system/web/src/components/Tags/TagCaseState/TagCaseState.spec.ts (1)
Learnt from: oddsson
PR: island-is/island.is#16939
File: apps/judicial-system/web/src/components/Table/PastCasesTable/PastCasesTable.tsx:126-131
Timestamp: 2024-11-19T21:47:09.093Z
Learning: The `CaseListEntry` interface in `@island.is/judicial-system-web/src/graphql/schema` includes the properties `isValidToDateInThePast`, `indictmentRulingDecision`, and `indictmentDecision`.
apps/judicial-system/web/src/components/Table/PastCasesTable/PastCasesTable.tsx (3)
Learnt from: oddsson
PR: island-is/island.is#16939
File: apps/judicial-system/web/src/components/Table/PastCasesTable/PastCasesTable.tsx:136-139
Timestamp: 2024-11-20T10:15:04.980Z
Learning: The properties `isValidToDateInThePast`, `indictmentRulingDecision`, and `indictmentDecision` are defined in the `CaseListEntry` interface used in the `PastCasesTable` component.
Learnt from: oddsson
PR: island-is/island.is#16939
File: apps/judicial-system/web/src/components/Table/PastCasesTable/PastCasesTable.tsx:126-131
Timestamp: 2024-11-19T21:47:09.093Z
Learning: The `CaseListEntry` interface in `@island.is/judicial-system-web/src/graphql/schema` includes the properties `isValidToDateInThePast`, `indictmentRulingDecision`, and `indictmentDecision`.
Learnt from: gudjong
PR: island-is/island.is#16760
File: apps/judicial-system/web/src/routes/Shared/Cases/PrisonCases.tsx:112-118
Timestamp: 2024-11-12T15:15:11.835Z
Learning: In `apps/judicial-system/web/src/routes/Prosecutor/components/CasesAwaitingConfirmationTable/CasesAwaitingConfirmationTable.tsx`, `apps/judicial-system/web/src/routes/Court/components/CasesAwaitingAssignmentTable/CasesAwaitingAssignmentTable.tsx`, and one instance in `apps/judicial-system/web/src/routes/Shared/Cases/PrisonCases.tsx`, it's correct to pass only the `type` prop to `ColumnCaseType` without the `decision` and `parentCaseId` props.
apps/judicial-system/web/src/routes/Defender/Cases/components/DefenderCasesTable.tsx (2)
Learnt from: gudjong
PR: island-is/island.is#16760
File: apps/judicial-system/web/src/routes/Shared/Cases/PrisonCases.tsx:112-118
Timestamp: 2024-11-12T15:15:11.835Z
Learning: In `apps/judicial-system/web/src/routes/Prosecutor/components/CasesAwaitingConfirmationTable/CasesAwaitingConfirmationTable.tsx`, `apps/judicial-system/web/src/routes/Court/components/CasesAwaitingAssignmentTable/CasesAwaitingAssignmentTable.tsx`, and one instance in `apps/judicial-system/web/src/routes/Shared/Cases/PrisonCases.tsx`, it's correct to pass only the `type` prop to `ColumnCaseType` without the `decision` and `parentCaseId` props.
Learnt from: oddsson
PR: island-is/island.is#14673
File: apps/judicial-system/web/src/routes/PublicProsecutor/Tables/CasesForReview.tsx:79-79
Timestamp: 2024-11-12T15:15:11.835Z
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.
🪛 ESLint
apps/judicial-system/web/src/components/PageTitle/PageTitle.tsx
[error] 1-20: Run autofix to sort these imports!
(simple-import-sort/imports)
🪛 Biome (1.9.4)
apps/judicial-system/web/src/components/Tags/TagCaseState/TagCaseState.tsx
[error] 22-22: Shouldn't redeclare 'Tag'. Consider to delete it or rename it.
'Tag' is defined here:
(lint/suspicious/noRedeclare)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: tests (judicial-system-web)
- GitHub Check: build (judicial-system-web)
🔇 Additional comments (15)
apps/judicial-system/web/src/routes/Prosecutor/components/CasesAwaitingConfirmationTable/CasesAwaitingConfirmationTable.tsx (1)
124-124
: LGTM! The prop consolidation aligns with the refactoring objectives.The change to use a single
theCase
prop improves the component's interface by reducing prop drilling and enhancing maintainability.Let's verify that this change is consistent across all usages of
TagCaseState
:✅ Verification successful
🏁 Script executed:
#!/bin/bash # Description: Check for any remaining instances of old prop usage in TagCaseState # Expect: All instances should use the new `theCase` prop format # Search for TagCaseState usage patterns rg -A 2 '<TagCaseState' apps/Length of output: 3997
LGTM! The usage of the consolidated
theCase
prop is consistent.The shell script output confirms that all instances of
<TagCaseState>
across the repository now use the singletheCase
prop, aligning with the refactoring objectives.apps/judicial-system/web/src/components/PageTitle/PageTitle.tsx (2)
20-20
: LGTM! Import added for CaseListEntry type.The import is correctly placed and aligns with the refactoring objectives.
🧰 Tools
🪛 ESLint
[error] 1-20: Run autofix to sort these imports!
(simple-import-sort/imports)
58-58
: LGTM! TagCaseState prop structure updated.The component now correctly uses the consolidated
theCase
prop with appropriate type casting.apps/judicial-system/web/src/routes/Shared/Cases/MobileCase.tsx (1)
77-77
: LGTM! TagCaseState implementation updated.The component correctly uses the new prop structure and includes a key prop for the array element.
apps/judicial-system/web/src/routes/Court/components/CasesAwaitingAssignmentTable/CasesAwaitingAssignmentTable.tsx (1)
91-91
: LGTM! TagCaseState cell implementation updated.The table cell correctly uses the new prop structure, maintaining consistency with other components.
apps/judicial-system/web/src/routes/PublicProsecutor/Tables/CasesAwaitingReview.tsx (1)
92-95
: LGTM! TagCaseState implementation updated while preserving custom behavior.The component correctly uses the new prop structure while maintaining the custom state mapping functionality.
apps/judicial-system/web/src/components/Tags/TagCaseState/TagCaseState.tsx (2)
27-33
: LGTM! Props interface refactoring improves maintainability.The consolidation of multiple props into a single
theCase
prop of typeCaseListEntry
reduces prop drilling and improves type safety.
141-157
: LGTM! Clean component implementation.The component implementation is well-structured with proper context usage and prop handling.
apps/judicial-system/web/src/routes/Defender/Cases/components/DefenderCasesTable.tsx (1)
108-108
: LGTM! Consistent with TagCaseState refactoring.The update to use the consolidated
theCase
prop is clean and follows the new component API.apps/judicial-system/web/src/routes/PublicProsecutor/Tables/CasesForReview.tsx (1)
105-110
: LGTM! Proper integration of custom mapping function.The implementation correctly uses both the new
theCase
prop and thecustomMapCaseStateToTag
function.apps/judicial-system/web/src/components/Table/PastCasesTable/PastCasesTable.tsx (1)
126-126
: LGTM! Clean conditional rendering with new API.The conditional rendering of
TagCaseState
with the newtheCase
prop is well-implemented.apps/judicial-system/web/src/routes/Court/components/CasesInProgressTable/CasesInProgressTable.tsx (1)
157-157
: LGTM! Clean refactor of TagCaseState props.The change correctly implements the new prop structure by passing the entire case object to TagCaseState.
apps/judicial-system/web/src/components/Tags/TagCaseState/TagCaseState.spec.ts (1)
22-316
: LGTM! Comprehensive test coverage for the refactored TagCaseState.The test suite has been successfully updated to use the new function signature while maintaining thorough coverage of all case states and scenarios.
apps/judicial-system/web/src/routes/Shared/Cases/PrisonCases.tsx (1)
140-140
: LGTM! Clean refactor of TagCaseState props.The change correctly implements the new prop structure by passing the entire case object to TagCaseState.
apps/judicial-system/web/src/routes/Shared/Cases/ActiveCases.tsx (1)
97-97
: LGTM! Clean refactor of TagCaseState props.The change aligns with the PR objectives by simplifying the TagCaseState component's interface to accept a single CaseListEntry parameter. This improves code maintainability and type safety.
Let's verify the TypeScript types are properly enforced:
✅ Verification successful
🏁 Script executed:
#!/bin/bash # Description: Verify TypeScript types for TagCaseState component usage # Test: Check if TagCaseState component properly types the theCase prop ast-grep --pattern 'interface TagCaseStateProps { $$$ theCase: CaseListEntry $$$ }' # Test: Check if there are any remaining instances of old prop usage rg "TagCaseState.*caseState|TagCaseState.*caseType|TagCaseState.*isValidToDateInThePast|TagCaseState.*courtDate|TagCaseState.*indictmentDecision|TagCaseState.*indictmentRulingDecision|TagCaseState.*defendants"Length of output: 303
Let's run another script to further verify that the updated interface for
TagCaseState
is in place and that no legacy props remain. This script will:
- Search for the declaration of the
TagCaseStateProps
interface within files that mentionTagCaseState
- Show the snippet around the usage in
ActiveCases.tsx
to confirm that only the updatedtheCase
prop is passedPlease execute the following shell script:
Once we have these additional details, we can more confidently verify that TypeScript type safety is enforced and the refactor is complete.
🏁 Script executed:
#!/bin/bash # 1. Search for the interface declaration of TagCaseStateProps in files related to TagCaseState fd -t f -e ts -e tsx -g "TagCaseState" . | xargs rg -n "interface TagCaseStateProps" # 2. Display the relevant snippet from ActiveCases.tsx to verify usage of theCase prop sed -n '90,105p' apps/judicial-system/web/src/routes/Shared/Cases/ActiveCases.tsxLength of output: 722
LGTM! The updated usage of
<TagCaseState>
is correctly passing the singletheCase
prop, and no legacy props appear to be in use.The snippet from
ActiveCases.tsx
confirms that the refactor is applied, and our searches did not reveal any lingering references to the old props.
interface Tag { | ||
color: TagVariant | ||
text: string | ||
} |
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.
Rename the Tag interface to avoid naming conflicts.
The Tag
interface conflicts with the imported Tag
from '@island.is/island-ui/core'. Consider renaming it to something more specific like CaseStateTag
or TagDefinition
.
-interface Tag {
+interface CaseStateTag {
color: TagVariant
text: string
}
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
interface Tag { | |
color: TagVariant | |
text: string | |
} | |
interface CaseStateTag { | |
color: TagVariant | |
text: string | |
} |
🧰 Tools
🪛 Biome (1.9.4)
[error] 22-22: Shouldn't redeclare 'Tag'. Consider to delete it or rename it.
'Tag' is defined here:
(lint/suspicious/noRedeclare)
Refactor TagCaseState component
Asana
What
This PR implements a significant refactor to the TagCaseState component. The CaseState component is responsible for rendering the state of a case in a tag component. The refactoring done in this component is
CaseListEntry
parameter instead of deconstructed properties ofCaseListEntry
. This means that the component accepts a prop,theCase: CaseListEntry
instead ofTag
for cleaner code.Why
This makes calling the function and all code related to it much cleaner.
Checklist:
Summary by CodeRabbit
Refactor
Tests
Chores