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(service-portal): Filtering mailbox documents #16219

Merged
merged 9 commits into from
Oct 25, 2024

Conversation

disaerna
Copy link
Member

@disaerna disaerna commented Oct 1, 2024

Mailbox - Health documents

What

  • Removing health document filtering logic from frontend to backend.
  • Fixing health category filtering
  • Add filter for law and order documents

Why

  • It is possible to manipulate the graphql to display health data 🐛
  • Remove courtcase/law and order documents if user is an actor

Screenshots / Gifs

Attach Screenshots / Gifs to help reviewers understand the scope of the pull request

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 document retrieval and filtering based on user roles, allowing for more nuanced access to documents.
    • Added validation for document actions to ensure only valid document IDs are processed.
  • Bug Fixes

    • Removed unnecessary checks for user legal status and age, simplifying document fetching logic.
  • Chores

    • Removed deprecated utility functions and associated unit tests to streamline the codebase.

@disaerna disaerna requested review from a team as code owners October 1, 2024 10:55
Copy link
Contributor

coderabbitai bot commented Oct 1, 2024

Walkthrough

The changes in this pull request involve significant updates to the document handling and user management functionalities within the application. Key modifications include altering method signatures to accept user objects instead of national IDs, enhancing validation checks for document actions, and refining document retrieval logic based on user roles. Additionally, some properties and utility functions related to user data have been removed or simplified, streamlining the overall structure while maintaining existing functionalities.

Changes

File Path Change Summary
libs/api/domains/documents/src/lib/documentV2.resolver.ts Updated documentsV2 method to accept a User object and added validation to postMailAction for empty input.documentIds.
libs/api/domains/documents/src/lib/documentV2.service.ts Modified listDocuments to accept a User object and refined document filtering logic based on user roles. Enhanced findDocumentById to return additional properties.
libs/api/domains/documents/src/lib/models/v2/documents.input.ts Removed isLegalGuardian property from DocumentsInput class, simplifying the input model.
libs/auth/react/src/lib/auth/Auth.state.ts Removed formatUser function that added dateOfBirth to user profiles, leading to direct assignment of action.payload to userInfo.
libs/auth/react/src/lib/utils/getBirthday.spec.ts Deleted unit tests for the getBirthday function, covering various scenarios for extracting date of birth from national ID.
libs/service-portal/documents/src/hooks/useDocumentList.ts Eliminated checks for legal guardianship and age verification, simplifying document fetching logic.

Possibly related PRs

Suggested labels

automerge, high priority

Suggested reviewers

  • thorkellmani
  • eirikurn

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/auth/react/src/lib/auth/Auth.state.ts (1)

Line range hint 1-89: Overall assessment: Improved code simplicity with potential implications.

The changes in this file consistently remove the formatUser function and simplify user info assignment. These modifications align well with the coding guidelines for the libs directory, improving code simplicity and maintainability.

However, it's crucial to consider the following:

  1. The removal of the dateOfBirth property might affect other parts of the codebase that expect this field to be present.
  2. TypeScript types may need to be updated to reflect the new structure of the userInfo object.

To ensure a smooth transition:

  1. Conduct a thorough review of components and functions that interact with the userInfo object, particularly those that might have relied on the dateOfBirth property.
  2. Update relevant documentation to reflect the changes in the userInfo structure.
  3. Consider adding a migration guide or update notes for other developers working on the project.
libs/api/domains/documents/src/lib/documentV2.resolver.ts (1)

Line range hint 146-151: Improved input validation for postMailAction

The addition of input validation for input.documentIds is a great improvement. It prevents unnecessary processing when no document IDs are provided and adds a helpful warning log for debugging purposes.

To maintain consistency with the rest of the codebase, consider using a constant for the log category:

this.logger.warn('No document ids provided for posting action', {
  category: LOG_CATEGORY,
  action: input.action,
})

This change adheres to the coding guidelines by enhancing the overall quality and maintainability of the code.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 9ef986b and 3a4c4c9.

📒 Files selected for processing (6)
  • libs/api/domains/documents/src/lib/documentV2.resolver.ts (1 hunks)
  • libs/api/domains/documents/src/lib/documentV2.service.ts (2 hunks)
  • libs/api/domains/documents/src/lib/models/v2/documents.input.ts (0 hunks)
  • libs/auth/react/src/lib/auth/Auth.state.ts (1 hunks)
  • libs/auth/react/src/lib/utils/getBirthday.spec.ts (0 hunks)
  • libs/service-portal/documents/src/hooks/useDocumentList.ts (0 hunks)
💤 Files with no reviewable changes (3)
  • libs/api/domains/documents/src/lib/models/v2/documents.input.ts
  • libs/auth/react/src/lib/utils/getBirthday.spec.ts
  • libs/service-portal/documents/src/hooks/useDocumentList.ts
🧰 Additional context used
📓 Path-based instructions (3)
libs/api/domains/documents/src/lib/documentV2.resolver.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/api/domains/documents/src/lib/documentV2.service.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/auth/react/src/lib/auth/Auth.state.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."
🔇 Additional comments (5)
libs/auth/react/src/lib/auth/Auth.state.ts (2)

52-53: LGTM! Simplified user info assignment.

The direct assignment of action.payload to userInfo simplifies the code and aligns with the coding guidelines for reusability and effective tree-shaking. This change removes the previously added dateOfBirth property derived from the national ID.

To ensure this change doesn't introduce unexpected behavior, please run the following script to check for any usage of dateOfBirth in the codebase:

#!/bin/bash
# Description: Check for usage of dateOfBirth property in the codebase

# Search for dateOfBirth usage in TypeScript and JavaScript files
rg --type-add 'web:*.{ts,tsx,js,jsx}' -t web 'dateOfBirth' -C 3

If there are any occurrences, make sure to update those parts of the code accordingly.


61-61: LGTM! Consistent simplification of user info assignment.

This change is consistent with the modification in the SIGNIN_SUCCESS case, maintaining the simplified approach to user info assignment. It adheres to the coding guidelines for the libs directory.

To ensure type safety, please verify and update the TypeScript types if the structure of userInfo has changed. Run the following script to check the User type definition:

If the User type includes a dateOfBirth property, consider updating it to reflect the new structure.

libs/api/domains/documents/src/lib/documentV2.resolver.ts (2)

78-78: Improved flexibility by passing the entire user object

This change enhances the listDocuments method's flexibility by passing the entire user object instead of just the nationalId. This modification allows for potential future expansions where additional user information might be needed without requiring further changes to the method signature.

The change adheres to the coding guidelines for the libs directory by improving the reusability of the component across different NextJS apps.


Line range hint 1-180: Overall assessment: Positive improvements to code flexibility and robustness

The changes in this file align well with the PR objectives and enhance the overall quality of the code. The modifications to the documentsV2 method improve flexibility, while the added validation in postMailAction increases robustness. These changes adhere to the coding guidelines for the libs directory, promoting reusability and maintainability.

No major issues were identified during the review. The suggested minor improvement for log consistency is optional and does not impact the overall quality of the changes.

libs/api/domains/documents/src/lib/documentV2.service.ts (1)

90-99: Logic for hiding health data is correct

The implementation correctly determines whether to hide health data based on the user's delegation type and the child's age over 15.

@thordurhhh thordurhhh added the deploy-feature Deploys features to dev label Oct 1, 2024
Copy link
Contributor

github-actions bot commented Oct 1, 2024

Affected services are: api,application-system-api,skilavottord-web,web,application-system-form,island-ui-storybook,portals-admin,service-portal,system-e2e,
Feature deployment of your services will begin shortly. Your feature will be accessible here:
https://service-portalfix-mailbox-age-check-api-catalogue.dev01.devland.is/api
https://service-portalfix-mailbox-age-check-application-callback-xrd.internal.dev01.devland.is/application-payment
https://service-portalfix-mailbox-age-check-application-callback-xrd.internal.dev01.devland.is/applications
https://service-portalfix-mailbox-age-check-application-payment-callback-xrd.internal.dev01.devland.is/application-payment
https://service-portalfix-mailbox-age-check-application-payment-callback-xrd.internal.dev01.devland.is/applications
https://service-portalfix-mailbox-age-check-beta.dev01.devland.is/
https://service-portalfix-mailbox-age-check-beta.dev01.devland.is/api
https://service-portalfix-mailbox-age-check-beta.dev01.devland.is/app/skilavottord/
https://service-portalfix-mailbox-age-check-beta.dev01.devland.is/minarsidur
https://service-portalfix-mailbox-age-check-beta.dev01.devland.is/samradsgatt
https://service-portalfix-mailbox-age-check-beta.dev01.devland.is/stjornbord
https://service-portalfix-mailbox-age-check-beta.dev01.devland.is/umsoknir
https://service-portalfix-mailbox-age-check-ui.dev01.devland.is/

Deployed services: application-system-api,application-system-form,service-portal,portals-admin,api,web,skilavottord-web,island-ui-storybook,application-system-api-worker,consultation-portal.
Excluded services: ``

Copy link

codecov bot commented Oct 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 36.70%. Comparing base (300e3ce) to head (5d16162).
Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #16219      +/-   ##
==========================================
- Coverage   36.80%   36.70%   -0.10%     
==========================================
  Files        6854     6847       -7     
  Lines      142228   141732     -496     
  Branches    40559    40434     -125     
==========================================
- Hits        52342    52019     -323     
+ Misses      89886    89713     -173     
Flag Coverage Δ
api 3.37% <ø> (ø)
application-api-files 56.76% <ø> (ø)
application-system-api 41.37% <ø> (ø)
application-template-api-modules 27.81% <ø> (-0.02%) ⬇️
application-templates-accident-notification 29.27% <ø> (ø)
application-templates-car-recycling 3.12% <ø> (ø)
application-templates-driving-license 18.34% <ø> (ø)
application-templates-estate 12.31% <ø> (+<0.01%) ⬆️
application-templates-financial-aid 15.49% <ø> (ø)
application-templates-general-petition 23.44% <ø> (ø)
application-templates-inheritance-report 6.49% <ø> (ø)
application-templates-marriage-conditions 15.17% <ø> (ø)
application-templates-mortgage-certificate 43.59% <ø> (ø)
application-templates-parental-leave 29.96% <ø> (ø)
application-ui-components 1.28% <ø> (ø)
application-ui-shell 21.38% <ø> (+0.02%) ⬆️
auth-react 22.47% <ø> (-0.34%) ⬇️
nest-core ?
portals-admin-regulations-admin 1.85% <ø> (ø)
portals-core 16.16% <ø> (+0.01%) ⬆️
shared-components 27.77% <ø> (+0.06%) ⬆️
shared-form-fields 31.57% <ø> (ø)
web 1.80% <ø> (ø)

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

Files with missing lines Coverage Δ
libs/auth/react/src/lib/auth/Auth.state.ts 54.54% <ø> (-7.00%) ⬇️
...al/graphql/src/hooks/documents/useListDocuments.ts 14.28% <ø> (ø)

... and 110 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 300e3ce...5d16162. Read the comment docs.

@datadog-island-is
Copy link

datadog-island-is bot commented Oct 1, 2024

Datadog Report

All test runs b8bd5ce 🔗

23 Total Test Services: 0 Failed, 21 Passed
🔻 Test Sessions change in coverage: 1 decreased (-0.41%), 4 increased, 101 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
api 0 0 0 4 0 2.88s 1 no change Link
application-api-files 0 0 0 12 0 6.75s 1 no change Link
application-system-api 0 0 0 131 2 3m 38.69s 1 no change Link
application-template-api-modules 0 0 0 123 0 2m 44.87s 1 no change Link
application-templates-accident-notification 0 0 0 148 0 21.73s 1 no change Link
application-templates-driving-license 0 0 0 13 0 17.39s 1 no change Link
application-templates-financial-aid 0 0 0 11 0 16.64s 1 no change Link
application-templates-general-petition 0 0 0 5 0 11.55s 1 no change Link
application-templates-health-insurance 0 0 0 0 0 532.16ms 1 no change Link
application-templates-mortgage-certificate 0 0 0 3 0 22.57s 1 no change Link

🔻 Code Coverage Decreases vs Default Branch (1)

  • auth-react - jest 31.72% (-0.41%) - Details

Copy link
Member

@thorkellmani thorkellmani left a comment

Choose a reason for hiding this comment

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

LGTM

@disaerna disaerna changed the title fix(service-portal): health delegation bug and move logic to service fix(service-portal): Filtering mailbox documents Oct 25, 2024
@disaerna disaerna added the automerge Merge this PR as soon as all checks pass label Oct 25, 2024
Copy link
Member

@eirikurn eirikurn left a comment

Choose a reason for hiding this comment

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

Great!

@disaerna disaerna removed the deploy-feature Deploys features to dev label Oct 25, 2024
@kodiakhq kodiakhq bot merged commit bf795c2 into main Oct 25, 2024
156 checks passed
@kodiakhq kodiakhq bot deleted the service-portal/fix-mailbox-age-check branch October 25, 2024 15:48
disaerna added a commit that referenced this pull request Oct 25, 2024
* fix: health delegation bug and move logic to service

* feat: hide law and order and health data if certain delegation

* console

* fix: add correct id

* remove birthday use (v1 is deprecated)

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
kodiakhq bot added a commit that referenced this pull request Oct 25, 2024
* fix(clients): prod path (#16554)

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>

* fix(my-pages): Law and Order - error handling (#16506)

* fix: remove button if error

* feat: audit and log error if lawyer list fails

* feat: detailed logs

* fix: remove noice

* revert message prop

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>

* fix(service-portal): Filtering mailbox documents  (#16219)

* fix: health delegation bug and move logic to service

* feat: hide law and order and health data if certain delegation

* console

* fix: add correct id

* remove birthday use (v1 is deprecated)

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>

* fix(my-pages): display error message on urgent files on dashboard (#16572)

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
@coderabbitai coderabbitai bot mentioned this pull request Oct 29, 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.

4 participants