-
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
fix(j-s): Fix flashing ui #16952
fix(j-s): Fix flashing ui #16952
Conversation
WalkthroughThe changes in this pull request focus on the Changes
Possibly related PRs
Suggested labels
Suggested reviewers
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
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #16952 +/- ##
==========================================
+ Coverage 35.68% 35.83% +0.15%
==========================================
Files 6937 6931 -6
Lines 147043 147225 +182
Branches 41819 42159 +340
==========================================
+ Hits 52477 52764 +287
+ Misses 94566 94461 -105 Flags with carried forward coverage won't be shown. Click here to find out more.
... and 61 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
Datadog ReportAll test runs ✅ 35 Total Test Services: 0 Failed, 32 Passed Test ServicesThis report shows up to 10 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: 0
🧹 Outside diff range and nitpick comments (2)
apps/judicial-system/web/src/routes/Court/Indictments/Conclusion/Conclusion.tsx (2)
Line range hint
234-280
: Consider refactoring validation logic for better maintainability.The nested switch statements make the validation logic complex and harder to maintain. Consider extracting the validation logic for each decision type into separate functions.
+ const isCompletingDecisionValid = (decision: CaseIndictmentRulingDecision): boolean => { + switch (decision) { + case CaseIndictmentRulingDecision.RULING: + case CaseIndictmentRulingDecision.DISMISSAL: + return hasRequiredFiles([CaseFileCategory.COURT_RECORD, CaseFileCategory.RULING]) + case CaseIndictmentRulingDecision.CANCELLATION: + case CaseIndictmentRulingDecision.FINE: + return hasRequiredFiles([CaseFileCategory.COURT_RECORD]) + case CaseIndictmentRulingDecision.MERGE: + return hasRequiredFiles([CaseFileCategory.COURT_RECORD]) && Boolean(workingCase.mergeCase?.id) + default: + return false + } + } + + const hasRequiredFiles = (categories: CaseFileCategory[]): boolean => { + return categories.every(category => + uploadFiles.some(file => file.category === category && file.status === 'done') + ) + } const stepIsValid = () => { if (!allFilesDoneOrError) { return false } switch (selectedAction) { case IndictmentDecision.POSTPONING: return Boolean(postponementReason) case IndictmentDecision.SCHEDULING: return Boolean(selectedCourtSessionType && courtDate?.date) case IndictmentDecision.COMPLETING: - switch (selectedDecision) { - case CaseIndictmentRulingDecision.RULING: - // ... existing switch cases - } + return selectedDecision ? isCompletingDecisionValid(selectedDecision) : false case IndictmentDecision.POSTPONING_UNTIL_VERDICT: case IndictmentDecision.REDISTRIBUTING: return true default: return false } }
Line range hint
142-186
: Enhance type safety in navigation handling.Consider adding explicit return type and exhaustive type checking to improve type safety and maintainability.
- const handleNavigationTo = useCallback( + const handleNavigationTo = useCallback( + async (destination: keyof stepValidationsType): Promise<void> => { // ... existing implementation + const assertNever = (x: never): never => { + throw new Error(`Unexpected decision type: ${x}`) + } + switch (selectedAction) { // ... existing cases + default: + assertNever(selectedAction) } }, // ... dependencies )
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (1)
apps/judicial-system/web/src/routes/Court/Indictments/Conclusion/Conclusion.tsx
(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
apps/judicial-system/web/src/routes/Court/Indictments/Conclusion/Conclusion.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/Court/Indictments/Conclusion/Conclusion.tsx (1)
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.
🔇 Additional comments (2)
apps/judicial-system/web/src/routes/Court/Indictments/Conclusion/Conclusion.tsx (2)
188-189
: LGTM! This fixes the UI flashing issue.
The early return when postponedIndefinitelyExplanation
exists prevents unnecessary state resets to SCHEDULING
, effectively fixing the UI flashing issue when users select the postponed indefinitely option.
Line range hint 516-530
: Improve error handling for file uploads.
Consider adding user feedback for upload failures and handling edge cases more explicitly.
+ const handleUploadError = (error: Error) => {
+ // Add appropriate error notification/feedback
+ }
onChange={(files) => {
handleUpload(
addUploadFiles(files, {
category: CaseFileCategory.COURT_RECORD,
}),
updateUploadFile,
- )
+ ).catch(handleUploadError)
}}
Also applies to: 557-571
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.
One comment
Fix flashing ui
Asana
What
When court users are selecting the indictment decision and continue from that page, if
postponedIndefinetly
is selected, the "Select new court date" input box would flash for a second. This pr fixes that.Screenshots / Gifs
Before
Screen.Recording.2024-11-20.at.11.09.09.mov
After
Screen.Recording.2024-11-20.at.11.07.01.mov
Checklist:
Summary by CodeRabbit
New Features
SCHEDULING
actions.REDISTRIBUTING
decisions, resetting thejudgeId
as needed.Bug Fixes
Improvements