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(service-portal): Signee view for parliamentary signature collection #16019

Merged
merged 8 commits into from
Sep 16, 2024

Conversation

juni-haukur
Copy link
Member

@juni-haukur juni-haukur commented Sep 16, 2024

...

Attach a link to issue if relevant

What

Specify what you're trying to achieve

Why

Specify why you need to achieve this

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

    • Updated button navigation in the Done form for improved user flow.
    • Introduced a new SignedList component for managing signed documents, including unsigning functionality.
    • Enhanced SigneeView component to display user-specific data and improve role-based rendering.
    • Dynamic rendering in SignatureListsParliamentary component based on user ownership status.
    • OwnerView component now accepts currentCollection prop for better data handling.
    • Added isPresidential field to the current collection query for enhanced data context.
  • Bug Fixes

    • Updated terminology for the Parliamentary collection type for clarity.
  • Improvements

    • Enhanced loading indicators and user feedback throughout various components.

@juni-haukur juni-haukur requested a review from a team as a code owner September 16, 2024 10:56
Copy link
Contributor

coderabbitai bot commented Sep 16, 2024

Walkthrough

The pull request includes modifications to various components within the application, focusing on the Done form's button URL, updates to constants related to parliamentary collections, and enhancements to several views (OwnerView, SignedList, SigneeView) to improve data handling and user interaction. Key changes involve the introduction of new props, hooks for data fetching, and updates to rendering logic based on user roles and collection states.

Changes

File Change Summary
libs/application/templates/.../Done.ts Updated button field URL from /minarsidur/min-gogn/listar/medmaelasofnun to /minarsidur/min-gogn/listar/althingis-medmaelasofnun.
libs/service-portal/signature-collection/src/lib/constants.ts Changed CollectionType value for Parliamentary from 'Alþingiskosningar' to 'Alþingiskosning NÝTT TEST'.
libs/service-portal/signature-collection/src/screens/Parliamentary/OwnerView/index.tsx Added currentCollection prop and integrated hooks for fetching owner-related lists.
libs/service-portal/signature-collection/src/screens/Parliamentary/SignedList/index.tsx Introduced SignedList component for managing signed documents with modal confirmation for unsigning.
libs/service-portal/signature-collection/src/screens/Parliamentary/SigneeView/index.tsx Enhanced functionality with currentCollection prop and conditional rendering based on user roles.
libs/service-portal/signature-collection/src/screens/Parliamentary/index.tsx Updated rendering logic to conditionally display OwnerView or SigneeView based on user ownership status.

Possibly related PRs

  • feat(application-plc): Procuration #15945: The changes in this PR involve modifications to the ParliamentaryListCreationService, which includes updates to how the owner property is populated based on the national ID, relating to parliamentary data and user roles.
  • feat(id-card): updates to application #15870: This PR includes changes to the Approved.ts file, which may involve similar form handling and user interaction logic as seen in the main PR's Done.ts file.
  • chore(clients-signature-collection): Update client #15931: The modifications in this PR to the clientConfig.json file introduce new API endpoints that may interact with the same data structures or user flows as the changes in the main PR, particularly regarding the parliamentary list functionalities.
  • fix(nafnskirteini): small string updates #15957: The changes in this PR to the Approved.ts file involve updates to how applicant data is processed, which could relate to the navigation and user interaction changes made in the main PR's Done.ts file.

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 generate interesting stats about this repository and render them as a table.
    -- @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/service-portal/signature-collection/src/screens/Parliamentary/OwnerView/index.tsx (1)

32-37: Remove the console log statement before deploying to production.

The changes introduce new functionality to the OwnerView component, allowing it to interact with user and owner data more effectively. This is a good enhancement.

However, please remember to remove the console log statement that outputs the listsForOwner before deploying to production, as it may expose sensitive data.

Apply this diff to remove the console log statement:

-  console.log(listsForOwner)
libs/service-portal/signature-collection/src/screens/Parliamentary/SignedList/index.tsx (1)

51-53: Consider providing more specific error messages.

To improve the user experience, consider providing more specific error messages based on the type of error encountered during the unsigning process. This will help users understand the issue better and take appropriate actions if needed.

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 46a5b69 and 11f5a84.

Files selected for processing (6)
  • libs/application/templates/signature-collection/parliamentary-list-signing/src/forms/Done.ts (1 hunks)
  • libs/service-portal/signature-collection/src/lib/constants.ts (1 hunks)
  • libs/service-portal/signature-collection/src/screens/Parliamentary/OwnerView/index.tsx (1 hunks)
  • libs/service-portal/signature-collection/src/screens/Parliamentary/SignedList/index.tsx (1 hunks)
  • libs/service-portal/signature-collection/src/screens/Parliamentary/SigneeView/index.tsx (1 hunks)
  • libs/service-portal/signature-collection/src/screens/Parliamentary/index.tsx (1 hunks)
Additional context used
Path-based instructions (6)
libs/service-portal/signature-collection/src/lib/constants.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/service-portal/signature-collection/src/screens/Parliamentary/index.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."
libs/application/templates/signature-collection/parliamentary-list-signing/src/forms/Done.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/service-portal/signature-collection/src/screens/Parliamentary/OwnerView/index.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."
libs/service-portal/signature-collection/src/screens/Parliamentary/SigneeView/index.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."
libs/service-portal/signature-collection/src/screens/Parliamentary/SignedList/index.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."
Additional comments not posted (12)
libs/service-portal/signature-collection/src/lib/constants.ts (1)

3-3: LGTM!

The change updates the representation of a specific collection type, potentially indicating a new testing phase or a different context for parliamentary elections. The change adheres to the TypeScript usage for defining constants and does not affect the overall structure or logic of the code.

libs/service-portal/signature-collection/src/screens/Parliamentary/index.tsx (5)

13-15: Effective use of custom hooks for data management.

The introduction of the useIsOwner and useGetCurrentCollection custom hooks is a good approach for managing the loading states and fetching the necessary data (ownership status and current collection) for the component.

Encapsulating this logic in separate hooks improves code readability and reusability.


19-22: Improved generalization of the IntroHeader component.

The modifications to the IntroHeader component's title and description, using more general messages from the m module, make the component more context-agnostic and reusable across different scenarios.

Using the formatMessage function with the useLocale hook ensures proper localization of the title and description.


23-33: Improved rendering logic based on loading states and user ownership.

The updated rendering logic in the SignatureListsParliamentary component enhances the user experience by considering the loading states and user ownership status.

  • Checking the loadingIsOwner and loadingCurrentCollection states before rendering the views ensures that the component waits for the necessary data to be available.
  • Rendering either the OwnerView or SigneeView based on the isOwner.success status allows for a dynamic display of the appropriate content.
  • Passing the currentCollection as a prop to both views ensures that the latest collection data is available to them.
  • Rendering a Skeleton component during loading states provides visual feedback to the user, indicating that data is being fetched.

These changes improve the overall user experience and make the component more robust in handling different scenarios.


7-8: Good organization of custom hooks in a separate module.

Importing the useGetCurrentCollection and useIsOwner hooks from the ../../hooks module promotes code organization and reusability.

Keeping custom hooks in a separate module allows for better maintainability and makes it easier to share the hooks across different components within the same feature or module.


3-3: Verify the reusability and consistency of the IntroHeader component.

The IntroHeader component is imported from the @island.is/service-portal/core module, which suggests it is a shared component used across the service portal.

Please ensure that the IntroHeader component is consistently used and styled across different pages and features within the service portal to maintain a cohesive user experience.

Verification successful

IntroHeader component usage is consistent and widespread

The verification process confirms that the IntroHeader component is indeed a widely used, shared component across the service portal. It is consistently imported from the core modules and used in various screens and features, including user information, health, education, assets, and more.

Key observations:

  • Imported from '@island.is/portals/core' or '@island.is/service-portal/core'
  • Used in multiple modules and screens throughout the project
  • Consistent usage pattern with props like 'title' and 'intro'

This widespread and consistent usage promotes a cohesive user experience across different parts of the service portal, as initially suggested in the review comment.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage and consistency of the IntroHeader component across the service portal.

# Test: Search for the IntroHeader component usage. Expect: Consistent usage across different pages and features.
rg --type tsx -A 5 $'IntroHeader'

Length of output: 60


Script:

#!/bin/bash
# Description: Verify the usage and consistency of the IntroHeader component across the service portal.

# Find all .tsx and .ts files, then search for IntroHeader usage
fd '\.(tsx|ts)$' | xargs rg 'IntroHeader' -n | grep -v '//' | grep -v '^\s*\*'

# If no results are found, search for the import statement to verify the component exists
if [ $? -ne 0 ]; then
  echo "No direct usage of IntroHeader found. Searching for import statements:"
  fd '\.(tsx|ts)$' | xargs rg "import.*IntroHeader.*from.*'@island.is/service-portal/core'" -n
fi

Length of output: 19356

libs/service-portal/signature-collection/src/screens/Parliamentary/OwnerView/index.tsx (3)

17-21: LGTM!

The imported hooks are relevant to the component's functionality and the relative import path is a good practice.


22-23: LGTM!

The imported useAuth hook and SignatureCollection type are relevant to the component's functionality and the external imports are a good practice.


25-29: Verify the parent component is updated to pass the currentCollection prop.

The OwnerView component now accepts a new prop currentCollection of type SignatureCollection, which enhances its functionality. This is a good change and the prop type is defined using TypeScript, which is a best practice.

Please ensure that the parent component that renders OwnerView is updated to pass the currentCollection prop.

Run the following script to verify the parent component usage:

Verification successful

The parent components have been correctly updated to pass the currentCollection prop.

Our verification process has confirmed that the OwnerView component is being used correctly in both the Parliamentary and Presidential screens. In both cases, the currentCollection prop is being passed to the OwnerView component as required:

  1. In libs/service-portal/signature-collection/src/screens/Parliamentary/index.tsx:

    <OwnerView currentCollection={currentCollection} />
  2. In libs/service-portal/signature-collection/src/screens/Presidential/index.tsx:

    <OwnerView currentCollection={currentCollection} />

The import statements in both files also confirm that the OwnerView component is being imported correctly from the local directory.

This verification confirms that the changes to the OwnerView component have been properly implemented in the parent components, ensuring that the currentCollection data is available where needed.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the parent component passes the `currentCollection` prop to `OwnerView`.

# Test: Search for the `OwnerView` component usage. Expect: `currentCollection` prop is passed.
rg --type tsx -A 5 $'<OwnerView'

Length of output: 61


Script:

#!/bin/bash
# Description: Verify the parent component passes the `currentCollection` prop to `OwnerView`.

# Search for files containing 'OwnerView' in their name
echo "Files containing 'OwnerView' in their name:"
fd -e ts -e tsx OwnerView

# Search for usage of <OwnerView> component in .ts and .tsx files
echo "Usage of <OwnerView> component:"
rg -t ts -t tsx '<OwnerView' -A 5

# Search for import statements of OwnerView
echo "Import statements for OwnerView:"
rg -t ts -t tsx 'import.*OwnerView'

Length of output: 408


Script:

#!/bin/bash
# Description: Verify the parent component passes the `currentCollection` prop to `OwnerView` using a more inclusive search strategy.

# Check repository structure
echo "Repository structure:"
tree -L 3

# Search for files containing 'OwnerView' in their name (case-insensitive)
echo "Files containing 'OwnerView' in their name (case-insensitive):"
find . -iname "*ownerview*"

# Search for usage of OwnerView component without specifying file types
echo "Usage of OwnerView component:"
grep -r -n -A 5 "<OwnerView" .

# Search for import statements of OwnerView without specifying file types
echo "Import statements for OwnerView:"
grep -r -n "import.*OwnerView" .

Length of output: 22936

libs/service-portal/signature-collection/src/screens/Parliamentary/SigneeView/index.tsx (1)

Line range hint 1-120: Great work on enhancing the SigneeView component! The changes significantly improve the user experience and provide a personalized view based on user roles and data availability.

The component now efficiently retrieves user-specific data using custom hooks and conditionally renders the appropriate content. The rendering logic is well-structured and handles different scenarios effectively, such as displaying an empty state when no lists are available, rendering the signed list and user-specific action cards when lists are present, showing a warning message for actors, and presenting a loading skeleton while data is being fetched.

The use of TypeScript for defining props and importing types ensures type safety and improves code maintainability. The component also follows good practices by importing only the necessary modules, which helps with tree-shaking and optimizing the bundle size.

Overall, the changes are well-implemented and align with the goals of providing a user-centric experience in the SigneeView component.

libs/service-portal/signature-collection/src/screens/Parliamentary/SignedList/index.tsx (2)

15-144: LGTM!

The SignedList component is well-structured and follows best practices for reusability and TypeScript usage. It effectively uses hooks for data fetching and state management, and provides a good user experience with clear feedback and updates.


15-144: Adheres to the additional instructions.

The component adheres to the guidelines mentioned in the additional instructions:

  • It is reusable across different NextJS apps.
  • It uses TypeScript for defining props and exporting types.
  • It follows effective tree-shaking and bundling practices.

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 11f5a84 and 8b05b2d.

Files selected for processing (2)
  • libs/application/templates/signature-collection/parliamentary-list-creation/src/forms/Done.ts (1 hunks)
  • libs/service-portal/signature-collection/src/screens/Parliamentary/OwnerView/ViewList/Signees.tsx (1 hunks)
Additional context used
Path-based instructions (2)
libs/application/templates/signature-collection/parliamentary-list-creation/src/forms/Done.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/service-portal/signature-collection/src/screens/Parliamentary/OwnerView/ViewList/Signees.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."
Additional comments not posted (1)
libs/application/templates/signature-collection/parliamentary-list-creation/src/forms/Done.ts (1)

65-65: LGTM!

The change to the button URL aligns with the PR objective of implementing a signee view for parliamentary signature collection. It should redirect users to the new signee view without introducing any breaking changes or errors.

Copy link

codecov bot commented Sep 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 36.81%. Comparing base (a4803a3) to head (12f8349).
Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main   #16019   +/-   ##
=======================================
  Coverage   36.81%   36.81%           
=======================================
  Files        6721     6721           
  Lines      137879   137874    -5     
  Branches    39204    39202    -2     
=======================================
+ Hits        50761    50762    +1     
+ Misses      87118    87112    -6     
Flag Coverage Δ
api 3.39% <ø> (ø)
api-domains-auth-admin 49.89% <ø> (ø)
application-system-api 41.67% <ø> (ø)
application-template-api-modules 23.44% <ø> (-0.02%) ⬇️
application-ui-shell 21.74% <ø> (ø)
services-auth-admin-api 52.85% <ø> (ø)
services-auth-delegation-api 61.29% <ø> (-0.08%) ⬇️
services-auth-ids-api 54.01% <ø> (+0.01%) ⬆️
services-auth-personal-representative 47.92% <ø> (-0.05%) ⬇️
services-auth-personal-representative-public 43.84% <ø> (-0.04%) ⬇️
services-auth-public-api 51.80% <ø> (ø)
services-user-notification 47.58% <ø> (-0.03%) ⬇️
services-user-profile 62.26% <ø> (ø)

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

see 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 a4803a3...12f8349. Read the comment docs.

@datadog-island-is
Copy link

datadog-island-is bot commented Sep 16, 2024

Datadog Report

All test runs 6433dcf 🔗

14 Total Test Services: 0 Failed, 14 Passed
🔻 Test Sessions change in coverage: 3 decreased, 29 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 3.08s 1 no change Link
api-domains-auth-admin 0 0 0 18 0 13.77s 1 no change Link
application-system-api 0 0 0 111 2 3m 18.62s 1 no change Link
application-template-api-modules 0 0 0 109 0 1m 53.03s 1 no change Link
application-ui-shell 0 0 0 74 0 36.82s 1 no change Link
auth-api-lib 0 0 0 20 0 29.44s 1 no change Link
services-auth-admin-api 0 0 0 107 0 2m 49.4s 1 no change Link
services-auth-delegation-api 0 0 0 256 0 2m 52.97s 1 decreased (-0.26%) Link
services-auth-ids-api 0 0 0 145 0 55.96s 1 no change Link
services-auth-personal-representative 0 0 0 59 0 1m 16.97s 1 decreased (-0.02%) Link

🔻 Code Coverage Decreases vs Default Branch (3)

  • services-auth-delegation-api - jest 60.04% (-0.26%) - Details
  • services-auth-personal-representative - jest 50.06% (-0.02%) - Details
  • services-auth-personal-representative-public - jest 45.91% (-0.01%) - Details

@juni-haukur juni-haukur added the automerge Merge this PR as soon as all checks pass label Sep 16, 2024
@lodmfjord lodmfjord added the high priority VIP-Kodiak PR label Sep 16, 2024
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 high priority VIP-Kodiak PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants