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

fix(j-s): Civil claimants national id #16780

Merged
merged 11 commits into from
Nov 18, 2024
Merged

Conversation

oddsson
Copy link
Member

@oddsson oddsson commented Nov 8, 2024

Save civil claimants national id even though its not found in the national registry

Asana

What

We are not saving a civil claimant's national id to database when the national id is not found in the national registry. This PR fixes that. It also refactors the Toast component in Island UI. The refactoring includes

  • Updating to a newer desing
  • Start using the newer Icon component instead of the old deprecated one.

Why

If the national registry is down, we still want to keep the national id set by the prosecutor.

Screenshots / Gifs

Screen.Recording.2024-11-08.at.12.09.54.mov

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

    • Enhanced data handling for civil claimants in the Processing component, improving robustness.
  • Style

    • Increased width and adjusted padding of toast notifications for better visibility and responsiveness.
    • Repositioned close button for improved user experience in toast notifications.
  • Refactor

    • Simplified component imports and updated icon management in toast notifications.

@oddsson oddsson requested review from a team as code owners November 8, 2024 12:20
@oddsson oddsson requested a review from albinagu November 8, 2024 12:20
Copy link
Contributor

coderabbitai bot commented Nov 8, 2024

Walkthrough

The pull request introduces changes to three main files: Processing.tsx, Toast.css.ts, and Toast.tsx. The Processing.tsx file updates the logic for handling personData and civilClaimantNationalIdUpdate, improving data management for civil claimants. The Toast.css.ts file modifies the styling of toast notifications, including size and padding adjustments. Lastly, Toast.tsx alters import statements, updates icon management, and simplifies the ToastContainer component's export declaration.

Changes

File Path Change Summary
apps/judicial-system/web/src/routes/Prosecutor/Indictments/Processing/Processing.tsx Updated logic for handling personData and civilClaimantNationalIdUpdate, modified construction of the update object, and streamlined setting of nationalIdNotFound.
libs/island-ui/core/src/lib/Toast/Toast.css.ts Increased toast container width, adjusted padding and minimum height for mobile optimization, and changed close button alignment.
libs/island-ui/core/src/lib/Toast/Toast.tsx Changed import statements, updated icon names in RenderMessage, modified layout of Box components, and simplified the export statement for ToastContainer.

Possibly related PRs

Suggested labels

high priority

Suggested reviewers

  • thorkellmani

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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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

🧹 Outside diff range and nitpick comments (2)
libs/island-ui/core/src/lib/Toast/Toast.tsx (1)

36-45: Consider making the icon size configurable.

The icon size is hardcoded to "large". For better reusability across different contexts, consider making it a prop with "large" as the default.

-const RenderMessage = ({
-  message,
-  type,
-}: {
-  message: string
-  type: 'error' | 'success' | 'warning' | 'info'
-}) => {
+interface RenderMessageProps {
+  message: string
+  type: 'error' | 'success' | 'warning' | 'info'
+  iconSize?: 'small' | 'medium' | 'large'
+}
+
+const RenderMessage = ({
+  message,
+  type,
+  iconSize = 'large',
+}: RenderMessageProps) => {
   // ...
-        <Icon icon={icons[type]} color={colors[type]} size="large" />
+        <Icon icon={icons[type]} color={colors[type]} size={iconSize} />
apps/judicial-system/web/src/routes/Prosecutor/Indictments/Processing/Processing.tsx (1)

267-267: Consider adding a loading state for national registry lookups.

The nationalIdNotFound state is set immediately when no items are found, but there's no indication to the user that a lookup is in progress. This could lead to a confusing user experience when there's network latency.

Consider adding a loading state:

+ const [isLookingUpNationalId, setIsLookingUpNationalId] = useState<boolean>(false)

  useEffect(() => {
    if (!civilClaimantNationalIdUpdate) {
      return
    }

+   setIsLookingUpNationalId(true)
    const items = personData?.items || []
    const person = items[0]

    setNationalIdNotFound(items.length === 0)
+   setIsLookingUpNationalId(false)

    // ... rest of the code
  }, [personData])

Then update the UI to show a loading indicator:

    {civilClaimant.nationalId?.length === 11 && nationalIdNotFound && (
      <Text color="red600" variant="eyebrow" marginTop={1}>
        {formatMessage(core.nationalIdNotFoundInNationalRegistry)}
      </Text>
    )}
+   {civilClaimant.nationalId?.length === 11 && isLookingUpNationalId && (
+     <Text variant="eyebrow" marginTop={1}>
+       {formatMessage(core.lookingUpNationalRegistry)}
+     </Text>
+   )}
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 7bbf5b8 and a2ba7a0.

📒 Files selected for processing (3)
  • apps/judicial-system/web/src/routes/Prosecutor/Indictments/Processing/Processing.tsx (1 hunks)
  • libs/island-ui/core/src/lib/Toast/Toast.css.ts (3 hunks)
  • libs/island-ui/core/src/lib/Toast/Toast.tsx (3 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
apps/judicial-system/web/src/routes/Prosecutor/Indictments/Processing/Processing.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."
libs/island-ui/core/src/lib/Toast/Toast.css.ts (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
libs/island-ui/core/src/lib/Toast/Toast.tsx (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
📓 Learnings (1)
apps/judicial-system/web/src/routes/Prosecutor/Indictments/Processing/Processing.tsx (2)
Learnt from: gudjong
PR: island-is/island.is#15421
File: apps/judicial-system/web/src/routes/Prosecutor/Indictments/Processing/Processing.tsx:55-61
Timestamp: 2024-07-03T15:43:13.884Z
Learning: The `updateCase` method in the `apps/judicial-system/web/src/routes/Prosecutor/Indictments/Processing/Processing.tsx` file has its own error handling, and additional error handling in the `initialize` function is not necessary.
Learnt from: gudjong
PR: island-is/island.is#15421
File: apps/judicial-system/web/src/routes/Prosecutor/Indictments/Processing/Processing.tsx:55-61
Timestamp: 2024-10-08T15:39:04.351Z
Learning: The `updateCase` method in the `apps/judicial-system/web/src/routes/Prosecutor/Indictments/Processing/Processing.tsx` file has its own error handling, and additional error handling in the `initialize` function is not necessary.
🔇 Additional comments (5)
libs/island-ui/core/src/lib/Toast/Toast.tsx (1)

54-54: LGTM! Type declaration simplified correctly.

The removal of React.PropsWithChildren is appropriate since the component doesn't utilize children props. This change maintains type safety while improving code clarity.

libs/island-ui/core/src/lib/Toast/Toast.css.ts (3)

17-17: LGTM: Toast container width adjustment

The width increase to 432px provides more space for content while maintaining mobile responsiveness.


163-163: LGTM: Improved close button alignment

The close button's vertical centering provides better visual balance within the toast notification.


100-100: Verify design specs alignment

The padding and height adjustments follow responsive design principles and use theme tokens correctly. However, please verify that these specific values align with the updated design specifications:

  • Desktop: padding increased to theme.spacing[2]
  • Mobile: padding theme.spacing[1] and reduced height of 48px

Also applies to: 111-112

✅ Verification successful

Let me gather more information about the theme spacing values to better understand the consistency of these changes.


Based on the extensive search results, I can now provide a definitive response about the Toast padding changes:

Toast padding adjustments follow design system spacing tokens correctly

The changes to the Toast component's padding (from theme.spacing[1] to theme.spacing[2] for desktop and back to theme.spacing[1] for mobile with 48px height) are consistent with how spacing tokens are used throughout the codebase. The codebase shows a clear pattern of using these specific theme spacing values for component padding across different breakpoints.

The evidence shows:

  • Consistent usage of theme.spacing[1] and theme.spacing[2] for padding across many components
  • Similar responsive padding patterns in other components like Buttons, Cards, and Modals
  • These specific spacing values being used as standard increments in the design system
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any other toast-related styling files to ensure consistent spacing
fd -e css -e scss -e ts -e tsx --full-path '.*[tT]oast.*' | grep -v 'Toast.css.ts' | xargs rg 'spacing|height|padding'

Length of output: 274


Script:

#!/bin/bash
# Search for theme spacing definitions and usage
ast-grep --pattern 'spacing[$_]'

# Also check for any toast-related style constants or theme configurations
rg -g '!*.{test,spec}.*' -A 3 'theme.*spacing|spacing.*theme'

Length of output: 324452

apps/judicial-system/web/src/routes/Prosecutor/Indictments/Processing/Processing.tsx (1)

Line range hint 260-277: Verify the handling of undefined person data.

The current implementation has a potential issue where person?.name could be undefined when no person is found, but we still update the civil claimant with a potentially undefined name while preserving their national ID.

Consider explicitly handling the undefined case:

    const update = {
      caseId: workingCase.id,
      civilClaimantId: civilClaimantNationalIdUpdate?.civilClaimantId || '',
-     name: person?.name,
+     name: person?.name || workingCase.civilClaimants?.find(
+       (c) => c.id === civilClaimantNationalIdUpdate?.civilClaimantId
+     )?.name,
      nationalId: civilClaimantNationalIdUpdate?.nationalId,
    }

Let's verify the current behavior when person data is not found:

libs/island-ui/core/src/lib/Toast/Toast.tsx Outdated Show resolved Hide resolved
Copy link

codecov bot commented Nov 8, 2024

Codecov Report

Attention: Patch coverage is 14.28571% with 6 lines in your changes missing coverage. Please review.

Project coverage is 36.37%. Comparing base (16dd1fb) to head (5b1aac7).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...s/Prosecutor/Indictments/Processing/Processing.tsx 0.00% 6 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #16780      +/-   ##
==========================================
- Coverage   36.45%   36.37%   -0.08%     
==========================================
  Files        6903     6898       -5     
  Lines      144565   145188     +623     
  Branches    41278    41572     +294     
==========================================
+ Hits        52704    52817     +113     
- Misses      91861    92371     +510     
Flag Coverage Δ
air-discount-scheme-web 0.00% <ø> (ø)
api 3.34% <ø> (ø)
api-domains-communications 39.58% <ø> (ø)
api-domains-education 30.57% <ø> (ø)
application-api-files 62.35% <ø> (ø)
application-core 70.75% <ø> (-0.32%) ⬇️
application-system-api 41.02% <ø> (-0.01%) ⬇️
application-template-api-modules 27.68% <ø> (-0.03%) ⬇️
application-templates-accident-notification 28.98% <ø> (ø)
application-templates-car-recycling 3.12% <ø> (ø)
application-templates-criminal-record 25.87% <ø> (ø)
application-templates-driving-license 18.14% <ø> (ø)
application-templates-estate 12.14% <100.00%> (ø)
application-templates-example-payment 24.80% <ø> (ø)
application-templates-financial-aid 15.48% <ø> (ø)
application-templates-general-petition 23.07% <ø> (ø)
application-templates-inheritance-report 6.52% <ø> (ø)
application-templates-marriage-conditions 15.04% <ø> (ø)
application-templates-mortgage-certificate 43.36% <ø> (ø)
application-templates-parental-leave 29.86% <ø> (ø)
application-types 6.60% <ø> (ø)
application-ui-components 1.27% <ø> (ø)
application-ui-shell 20.83% <100.00%> (ø)
auth-react 21.85% <100.00%> (ø)
clients-charge-fjs-v2 24.11% <ø> (ø)
contentful-apps 4.69% <ø> (ø)
file-storage 45.80% <ø> (ø)
financial-aid-backend 51.29% <ø> (ø)
financial-aid-shared 17.81% <ø> (ø)
island-ui-core 28.88% <0.00%> (ø)
judicial-system-web 27.16% <14.28%> (-0.01%) ⬇️
nest-aws 53.04% <ø> (ø)
portals-admin-regulations-admin 1.85% <ø> (ø)
portals-core 15.89% <100.00%> (ø)
services-auth-personal-representative 45.63% <ø> (ø)
services-endorsements-api 53.21% <ø> (ø)
shared-components 26.90% <100.00%> (ø)
shared-form-fields 31.26% <100.00%> (ø)
web 1.77% <ø> (ø)

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

Files with missing lines Coverage Δ
libs/island-ui/core/src/lib/Toast/Toast.tsx 35.29% <100.00%> (ø)
...s/Prosecutor/Indictments/Processing/Processing.tsx 0.00% <0.00%> (ø)

... and 57 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 16dd1fb...5b1aac7. Read the comment docs.

@datadog-island-is
Copy link

datadog-island-is bot commented Nov 8, 2024

Datadog Report

All test runs 11aa622 🔗

36 Total Test Services: 0 Failed, 35 Passed
🔻 Test Sessions change in coverage: 2 decreased, 156 no change

Test Services
This report shows up to 10 services
Service Name Failed Known Flaky New Flaky Passed Skipped Total Time Code Coverage Change Test Service View
air-discount-scheme-web 0 0 0 2 0 8.83s 1 no change Link
api 0 0 0 4 0 3.03s 1 no change Link
api-domains-communications 0 0 0 5 0 34.55s 1 no change Link
api-domains-education 0 0 0 8 0 22.28s 1 no change Link
application-api-files 0 0 0 2 0 5.27s 1 no change Link
application-core 0 0 0 97 0 20.33s 1 decreased (-0.2%) Link
application-system-api 0 0 0 112 2 3m 27.68s 1 decreased (-0.01%) Link
application-template-api-modules 0 0 0 113 0 2m 34.88s 1 no change Link
application-templates-accident-notification 0 0 0 148 0 20.6s 1 no change Link
application-templates-criminal-record 0 0 0 2 0 12.16s 1 no change Link

🔻 Code Coverage Decreases vs Default Branch (2)

  • application-core - jest 78.49% (-0.2%) - Details
  • application-system-api - jest 36.69% (-0.01%) - Details

Copy link
Member

@Toti91 Toti91 left a comment

Choose a reason for hiding this comment

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

LGTM

@oddsson oddsson added the automerge Merge this PR as soon as all checks pass label Nov 14, 2024
@thorkellmani thorkellmani added automerge Merge this PR as soon as all checks pass and removed automerge Merge this PR as soon as all checks pass labels Nov 18, 2024
@thorkellmani
Copy link
Member

Cycled automerge since it was blocking the queue 🙇

@oddsson oddsson removed the request for review from albinagu November 18, 2024 11:00
@kodiakhq kodiakhq bot merged commit f1ff30d into main Nov 18, 2024
132 checks passed
@kodiakhq kodiakhq bot deleted the j-s/civil-claimant-national-id-fix branch November 18, 2024 11:59
jonnigs pushed a commit that referenced this pull request Nov 26, 2024
* Save civil claimants national id even though its not found in the national registry

* Remove debug code

* Remove debug code

* Remove debug code

* Fix validation

* Add React back

---------

Co-authored-by: Guðjón Guðjónsson <gudjon@kolibri.is>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
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.

4 participants