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): move intro header to layout #16078

Closed
wants to merge 13 commits into from

Conversation

thorkellmani
Copy link
Member

@thorkellmani thorkellmani commented Sep 19, 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

    • Introduced FootNote and IntroHeader components to enhance layout context and navigation experience.
    • Added a mechanism to display contextual information based on the active navigation item.
  • Bug Fixes

    • Removed IntroHeader and FootNote components from several screens to simplify user interface.
  • Chores

    • Cleaned up imports and commented out unused components in various screens to streamline code.

@thorkellmani thorkellmani added the deploy-feature Deploys features to dev label Sep 19, 2024
Copy link
Contributor

coderabbitai bot commented Sep 19, 2024

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The pull request introduces several changes across multiple components and files within the service portal. Key modifications include the addition of new imports and components, updates to navigation structures, and the removal of the IntroHeader and FootNote components from various screens. The NarrowLayout.tsx component now utilizes a new activeItem variable to conditionally render the IntroHeader and FootNote components based on the current navigation context, enhancing layout functionality.

Changes

File Path Change Summary
apps/service-portal/src/components/Layout/NarrowLayout.tsx Introduced isValidElement import (unused), added FootNote and IntroHeader components, and created activeItem variable for active navigation item rendering.
apps/service-portal/src/components/Layout/FullWidthLayout.tsx Removed React import, with no functional impact on the component.
libs/service-portal/social-insurance-maintenance/src/screens/* Removed IntroHeader and FootNote components from multiple screens, simplifying the component structure and eliminating introductory context.
libs/service-portal/social-insurance-maintenance/src/screens/IncomePlan/IncomePlan.tsx Removed IntroHeader and FootNote components from the rendered output.
libs/service-portal/social-insurance-maintenance/src/screens/IncomePlanDetail/IncomePlanDetail.tsx Removed IntroHeader and Hidden components from the rendered output.
libs/service-portal/social-insurance-maintenance/src/screens/PaymentPlan/PaymentPlan.tsx Removed IntroHeader and FootNote components from the rendered output.

Possibly related PRs

  • fix(service-portal): Update notification icon styling #15219: The changes in this PR involve the AvatarImage component, which is related to the layout structure in NarrowLayout.tsx where the IntroHeader component is introduced. Both PRs deal with components that affect the visual presentation in the service portal.
  • fix(service-portal): Add error toast to overveiw #16021: This PR enhances error handling in the overview section, which may relate to the overall user experience improvements in the NarrowLayout.tsx where contextual information is provided based on the active navigation item.

Suggested labels

automerge


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

codecov bot commented Sep 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 36.64%. Comparing base (9ef986b) to head (5a1c21a).
Report is 357 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #16078      +/-   ##
==========================================
- Coverage   36.76%   36.64%   -0.13%     
==========================================
  Files        6785     6763      -22     
  Lines      139900   139459     -441     
  Branches    39772    39572     -200     
==========================================
- Hits        51435    51103     -332     
+ Misses      88465    88356     -109     
Flag Coverage Δ
api 3.37% <ø> (-0.03%) ⬇️
application-system-api 41.66% <ø> (+0.04%) ⬆️
application-template-api-modules 24.40% <ø> (+0.66%) ⬆️
application-ui-shell 21.29% <ø> (-0.01%) ⬇️
portals-admin-regulations-admin 1.88% <ø> (ø)
portals-core 16.17% <ø> (ø)

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

Files with missing lines Coverage Δ
libs/service-portal/core/src/lib/messages.ts 50.00% <ø> (ø)
libs/service-portal/health/src/lib/navigation.ts 0.00% <ø> (ø)
.../src/screens/AidsAndNutrition/AidsAndNutrition.tsx 0.00% <ø> (ø)
...creens/DentistRegistration/DentistRegistration.tsx 0.00% <ø> (ø)
...ce-portal/health/src/screens/Dentists/Dentists.tsx 0.00% <ø> (ø)
...l/health/src/screens/HealthCenter/HealthCenter.tsx 0.00% <ø> (ø)
...alth/src/screens/HealthOverview/HealthOverview.tsx 0.00% <ø> (ø)

... and 148 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 148403d...5a1c21a. Read the comment docs.

Copy link
Contributor

Affected services are: portals-admin,service-portal,system-e2e,
Feature deployment of your services will begin shortly. Your feature will be accessible here:
https://featintro-to-layout-beta.dev01.devland.is/minarsidur
https://featintro-to-layout-beta.dev01.devland.is/stjornbord

Deployed services: service-portal,portals-admin.
Excluded services: ``

@datadog-island-is
Copy link

datadog-island-is bot commented Sep 19, 2024

Datadog Report

All test runs 1b21b48 🔗

9 Total Test Services: 0 Failed, 8 Passed
🔻 Test Sessions change in coverage: 1 decreased (-0.01%), 44 no change

Test 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.83s 1 no change Link
application-system-api 0 0 0 131 2 3m 21.4s 1 no change Link
application-template-api-modules 0 0 0 135 0 2m 2.75s 1 decreased (-0.01%) Link
application-ui-shell 0 0 0 74 0 35.55s 1 no change Link
portals-admin-ids-admin 0 0 0 2 0 8.06s 1 no change Link
portals-admin-regulations-admin 0 0 0 24 0 15.07s 1 no change Link
portals-core 0 0 0 20 0 20.63s 1 no change Link
service-portal-core 0 0 0 5 0 2.02s N/A Link
service-portal-health 0 0 0 0 0 658.7ms 1 no change Link

🔻 Code Coverage Decreases vs Default Branch (1)

  • application-template-api-modules - jest 26.06% (-0.01%) - Details

@thorkellmani thorkellmani marked this pull request as ready for review September 23, 2024 13:38
@thorkellmani thorkellmani requested review from a team as code owners September 23, 2024 13:38
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: 4

Outside diff range and nitpick comments (4)
libs/service-portal/social-insurance-maintenance/src/lib/navigation.ts (1)

35-35: LGTM! Consider consistent naming for translation messages.

The addition of intro properties with translation messages for both incomePlan and latestIncomePlan items enhances the user experience by providing more context. This is consistent with good internationalization practices and the overall structure of the navigation items.

For better consistency, consider aligning the naming convention of the translation messages. For example:

intro: m.incomePlanIntro, // Instead of m.incomePlanDescription
intro: m.latestIncomePlanIntro, // Instead of m.incomePlanDetail

This would make the naming more predictable and easier to maintain across the application.

Also applies to: 40-40

libs/service-portal/social-insurance-maintenance/src/screens/PaymentPlan/PaymentPlan.tsx (1)

Line range hint 1-102: Overall assessment of changes and adherence to coding guidelines

The changes made to this component align partially with the PR objectives and adhere to the coding guidelines. However, there are a few points to consider:

  1. The removal of the IntroHeader aligns with the PR objective, but ensure it's properly implemented in the new layout.
  2. The removal of the FootNote component needs clarification, as it wasn't mentioned in the PR objectives.
  3. The component still adheres to TypeScript usage for props and maintains its overall structure.
  4. Consider the impact on user experience, especially regarding the removal of introductory information and footnotes in the printed version.

To improve code quality and maintainability:

  1. Remove unused imports if the commented-out components are no longer needed.
  2. Update any relevant documentation to reflect these changes in the user interface.

Consider adding a comment explaining the relocation of the IntroHeader and the reason for removing the FootNote, to improve code maintainability:

+ // IntroHeader moved to layout component
  {/*<IntroHeader
    ...
  />*/}

  // ... (rest of the component)

+ // FootNote removed due to [reason]
  {/*<Hidden print>
      <FootNote serviceProviderSlug="tryggingastofnun" />
    </Hidden>*/}
libs/service-portal/social-insurance-maintenance/src/screens/IncomePlanDetail/IncomePlanDetail.tsx (1)

Line range hint 1-129: Approve overall structure with minor suggestions

The component structure adheres to the coding guidelines for files in the libs directory:

  • It's reusable across different NextJS apps.
  • TypeScript is used effectively for props and types.
  • The code structure supports tree-shaking and bundling practices.

Minor suggestions for improvement:

  1. Consider using more specific types for the data, loading, and error variables from the useGetIncomePlanDetailQuery hook.
  2. The EmptyTable component could be conditionally rendered to avoid unnecessary checks.
libs/service-portal/health/src/lib/navigation.ts (1)

8-10: LGTM! Consider type-checking for consistency.

The addition of description, serviceProvider, and serviceProviderTooltip properties enhances the context provided for the health navigation item. This is a good improvement for user experience.

Consider adding type definitions for these new properties in the PortalNavigationItem interface to ensure type safety and consistency across the application.

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 52f1575 and ab8b28c.

Files selected for processing (19)
  • apps/service-portal/src/components/Layout/FullWidthLayout.tsx (1 hunks)
  • apps/service-portal/src/components/Layout/NarrowLayout.tsx (5 hunks)
  • libs/portals/core/src/types/portalCore.ts (2 hunks)
  • libs/service-portal/core/src/lib/messages.ts (1 hunks)
  • libs/service-portal/health/src/lib/navigation.ts (5 hunks)
  • libs/service-portal/health/src/screens/AidsAndNutrition/AidsAndNutrition.tsx (0 hunks)
  • libs/service-portal/health/src/screens/DentistRegistration/DentistRegistration.tsx (0 hunks)
  • libs/service-portal/health/src/screens/Dentists/Dentists.tsx (0 hunks)
  • libs/service-portal/health/src/screens/HealthCenter/HealthCenter.tsx (0 hunks)
  • libs/service-portal/health/src/screens/HealthOverview/HealthOverview.tsx (0 hunks)
  • libs/service-portal/health/src/screens/Medicine/wrapper/MedicineWrapper.tsx (0 hunks)
  • libs/service-portal/health/src/screens/OrganDonation/OrganDonation.tsx (0 hunks)
  • libs/service-portal/health/src/screens/Payments/wrapper/PaymentsWrapper.tsx (0 hunks)
  • libs/service-portal/health/src/screens/Therapies/wrapper/TherapiesWrapper.tsx (0 hunks)
  • libs/service-portal/health/src/screens/Vaccinations/VaccinationsWrapper.tsx (0 hunks)
  • libs/service-portal/social-insurance-maintenance/src/lib/navigation.ts (2 hunks)
  • libs/service-portal/social-insurance-maintenance/src/screens/IncomePlan/IncomePlan.tsx (2 hunks)
  • libs/service-portal/social-insurance-maintenance/src/screens/IncomePlanDetail/IncomePlanDetail.tsx (2 hunks)
  • libs/service-portal/social-insurance-maintenance/src/screens/PaymentPlan/PaymentPlan.tsx (3 hunks)
Files not reviewed due to no reviewable changes (10)
  • libs/service-portal/health/src/screens/AidsAndNutrition/AidsAndNutrition.tsx
  • libs/service-portal/health/src/screens/DentistRegistration/DentistRegistration.tsx
  • libs/service-portal/health/src/screens/Dentists/Dentists.tsx
  • libs/service-portal/health/src/screens/HealthCenter/HealthCenter.tsx
  • libs/service-portal/health/src/screens/HealthOverview/HealthOverview.tsx
  • libs/service-portal/health/src/screens/Medicine/wrapper/MedicineWrapper.tsx
  • libs/service-portal/health/src/screens/OrganDonation/OrganDonation.tsx
  • libs/service-portal/health/src/screens/Payments/wrapper/PaymentsWrapper.tsx
  • libs/service-portal/health/src/screens/Therapies/wrapper/TherapiesWrapper.tsx
  • libs/service-portal/health/src/screens/Vaccinations/VaccinationsWrapper.tsx
Files skipped from review due to trivial changes (1)
  • libs/service-portal/social-insurance-maintenance/src/screens/IncomePlan/IncomePlan.tsx
Additional context used
Path-based instructions (8)
apps/service-portal/src/components/Layout/FullWidthLayout.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."
apps/service-portal/src/components/Layout/NarrowLayout.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/portals/core/src/types/portalCore.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/core/src/lib/messages.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/health/src/lib/navigation.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/social-insurance-maintenance/src/lib/navigation.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/social-insurance-maintenance/src/screens/IncomePlanDetail/IncomePlanDetail.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/social-insurance-maintenance/src/screens/PaymentPlan/PaymentPlan.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 (13)
libs/service-portal/social-insurance-maintenance/src/lib/navigation.ts (1)

17-17: LGTM! Good addition of descriptive intro.

The addition of the intro property with a translation message enhances the user experience by providing more context for the payment plan section. This change is consistent with good internationalization practices and the overall structure of the navigation items.

libs/service-portal/social-insurance-maintenance/src/screens/PaymentPlan/PaymentPlan.tsx (2)

Line range hint 24-33: Verify the relocation of the IntroHeader component

The removal of the IntroHeader component from this file aligns with the PR objective of moving it to a layout. However, please ensure that:

  1. The IntroHeader is properly implemented in the new layout to maintain consistent user experience.
  2. The unused import for IntroHeader is removed to keep the code clean.

To confirm the proper relocation of the IntroHeader, please run the following script:

#!/bin/bash
# Description: Verify the relocation of IntroHeader component

# Test 1: Check for IntroHeader usage in layout files
echo "Searching for IntroHeader usage in layout files:"
rg --type typescript "IntroHeader" libs/service-portal/*/src/layouts

# Test 2: Verify removal of IntroHeader import if unused
echo "Checking for unused IntroHeader import:"
ast-grep --lang typescript --pattern 'import { $$$, IntroHeader, $$$ } from "@island.is/service-portal/core"' libs/service-portal/social-insurance-maintenance/src/screens/PaymentPlan/PaymentPlan.tsx

94-96: Clarify the intention behind removing the FootNote component

The FootNote component has been commented out, which wasn't explicitly mentioned in the PR objectives. Please address the following points:

  1. Explain the reasoning behind removing the FootNote, especially since it was only visible in the print version.
  2. If the FootNote is no longer needed, remove the unused import to maintain code cleanliness.
  3. Ensure that removing this component doesn't negatively impact the printed version of the page.

To confirm the proper handling of the FootNote component, please run the following script:

libs/service-portal/health/src/lib/navigation.ts (5)

72-72: LGTM! Consistent improvement of nested items.

The addition of intro properties to nested child navigation items (dentist registration and health center registration) maintains consistency with parent items and improves the depth of information in the navigation structure.

Also applies to: 85-85


93-93: LGTM! Consistent improvement for medicine section.

The addition of the intro property to the medicine navigation item is consistent with the changes made to other sections and enhances the information available to users.


Line range hint 1-155: Overall improvement to navigation structure and user experience.

The changes to this file consistently enhance the navigation structure of the health section in the service portal. The additions of intro, description, serviceProvider, and serviceProviderTooltip properties across various navigation items provide more context and improve user guidance. These modifications align well with the PR objectives and adhere to the coding guidelines for library files.

Key improvements:

  1. Added descriptive properties to the main health navigation item.
  2. Consistent addition of intro properties to child and nested child navigation items.
  3. Specified a different service provider for the vaccinations section.

These changes will likely result in a more informative and user-friendly navigation experience in the health section of the service portal.


125-127: LGTM! Verify handling of different service providers.

The addition of intro, serviceProvider, and serviceProviderTooltip properties to the vaccinations section enhances the context provided to users. The different serviceProvider for this section is noteworthy.

Please run the following script to check for consistent handling of different service providers:

#!/bin/bash
# Check for consistent handling of different service providers

# Search for usage of serviceProvider in relevant components
echo "Checking usage of serviceProvider in components:"
rg "serviceProvider" --type typescript --type tsx libs/service-portal

# Check if there's special handling for 'landlaeknir' provider
echo "Checking for special handling of 'landlaeknir' provider:"
rg "landlaeknir" --type typescript --type tsx libs/service-portal

Ensure that the application correctly handles and displays information for different service providers, particularly for the 'landlaeknir' provider in the vaccinations section.


18-18: LGTM! Verify message object references.

The addition of intro properties to various child navigation items enhances user guidance by providing introductory text for each section. This is a positive change for user experience.

Please run the following script to ensure all referenced message objects exist:

Also applies to: 23-23, 45-45, 62-62, 67-67

libs/portals/core/src/types/portalCore.ts (2)

3-3: LGTM: Import statement updated correctly

The addition of ReactNode to the import statement is appropriate and consistent with its usage in the new introComponent property. This change adheres to the coding guideline of using TypeScript for defining props and exporting types.


52-59: LGTM: Enhancements to PortalNavigationItem interface

The additions of intro and introComponent properties to the PortalNavigationItem interface are well-implemented and documented. These changes adhere to the coding guidelines by:

  1. Enhancing reusability across different NextJS apps with flexible options for intro content.
  2. Correctly using TypeScript for defining the new props.
  3. Supporting effective tree-shaking through the optional nature of these properties.

The use of MessageDescriptor for intro maintains consistency with other text properties and supports internationalization, while ReactNode for introComponent allows for complex JSX elements.

apps/service-portal/src/components/Layout/FullWidthLayout.tsx (2)

Line range hint 1-214: LGTM: File structure and implementation

The overall structure and implementation of this file adhere to NextJS best practices and make effective use of TypeScript for type safety. The component uses efficient state management with React hooks. No further issues or improvements are apparent.


9-9: Remove unused import

The Text component is imported but not used in this file. Consider removing this import to keep the code clean and prevent potential bundle size increases.

Let's check if there are any lint rules in place to catch unused imports:

If these checks don't find any relevant configuration, consider adding appropriate lint rules to catch unused imports automatically.

libs/service-portal/core/src/lib/messages.ts (1)

1479-1483: LGTM: New message added correctly

The new incomePlanDetail message has been added correctly, following the existing pattern and conventions. The message ID is properly prefixed, and the multi-line default message is consistent with other similar messages in the file.

To ensure the new message is properly exported and can be tree-shaken, let's run the following check:

@thorkellmani thorkellmani requested a review from a team as a code owner September 23, 2024 13:49
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: 2

Outside diff range and nitpick comments (7)
apps/service-portal/src/components/Layout/NarrowLayout.tsx (1)

1-1: Remove unused import isValidElement

The isValidElement function is imported from 'react' but is not used in the component. To keep the code clean and avoid potential linting issues, consider removing this unused import.

Apply this diff to remove the unused import:

-import { ReactNode, isValidElement } from 'react'
+import { ReactNode } from 'react'

Also applies to: 14-15, 25-25

libs/portals/core/src/types/portalCore.ts (1)

Line range hint 52-78: LGTM! Consider enhancing documentation for clarity.

The new properties (intro, introComponent, and displayIntroHeader) are well-defined and consistent with the existing interface structure. They enhance the flexibility of the PortalNavigationItem interface, potentially improving reusability across different NextJS apps.

Consider adding a brief explanation of how these properties interact with each other in the comments. For example:

/**
 * Text for the intro header of the module.
 * Used when `displayIntroHeader` is true and `introComponent` is not provided.
 */
intro?: MessageDescriptor

/**
 * Custom JSX element for the intro header of the module.
 * Takes precedence over `intro` when both are provided.
 */
introComponent?: ReactNode

/**
 * Determines whether an intro header should be rendered by navigation.
 * When true, either `intro` or `introComponent` will be used.
 */
displayIntroHeader?: boolean

This additional context helps developers understand how to use these properties effectively.

libs/service-portal/health/src/lib/navigation.ts (5)

8-10: LGTM! Consider adding type annotations for clarity.

The addition of description, serviceProvider, and serviceProviderTooltip properties enhances the information provided for the health navigation item. Using message references promotes internationalization and reusability.

Consider adding explicit type annotations to these new properties for improved clarity:

description: string;
serviceProvider: string;
serviceProviderTooltip: string;

25-26: LGTM! Consider adding intro to sub-items for consistency.

The addition of intro and displayIntroHeader properties to the therapies item and its sub-items is consistent with the established pattern. This enhances the context provided to users and supports internationalization.

For consistency, consider adding an intro property to the physical therapy sub-item as well:

{
  displayIntroHeader: true,
  name: messages.physicalTherapy,
  intro: messages.physicalTherapyIntro, // Add this line
  path: HealthPaths.HealthTherapiesPhysical,
  navHide: true,
},

Also applies to: 30-30


37-37: LGTM! Consider adding intro properties for completeness.

The addition of displayIntroHeader to the speech and occupational therapy sub-items maintains consistency with the established pattern.

For completeness and consistency with the previous suggestion, consider adding intro properties to these sub-items as well:

{
  displayIntroHeader: true,
  name: messages.speechTherapy,
  intro: messages.speechTherapyIntro, // Add this line
  path: HealthPaths.HealthTherapiesSpeech,
  navHide: true,
},
{
  displayIntroHeader: true,
  name: messages.occupationalTherapy,
  intro: messages.occupationalTherapyIntro, // Add this line
  path: HealthPaths.HealthTherapiesOccupational,
  navHide: true,
},

Also applies to: 42-42


51-52: LGTM! Consider adding intro properties to sub-items.

The addition of displayIntroHeader and intro properties to the payments item and its sub-items maintains consistency with the established pattern and enhances the context provided to users.

For consistency with previous suggestions, consider adding intro properties to the payment participation and payment overview sub-items:

{
  displayIntroHeader: true,
  name: messages.paymentParticipation,
  intro: messages.paymentParticipationIntro, // Add this line
  path: HealthPaths.HealthPaymentParticipation,
  navHide: true,
},
{
  displayIntroHeader: true,
  name: messages.paymentOverview,
  intro: messages.paymentOverviewIntro, // Add this line
  path: HealthPaths.HealthPaymentOverview,
  navHide: true,
},

Also applies to: 56-56, 62-62


107-108: LGTM! Consider adding intro properties to sub-items for consistency.

The addition of intro and displayIntroHeader properties to the medicine item and its sub-items maintains consistency with the established pattern and enhances the context provided to users.

For consistency with previous items, consider adding intro properties to all medicine sub-items:

{
  name: messages.medicinePurchaseTitle,
  intro: messages.medicinePurchaseIntro, // Add this line
  displayIntroHeader: true,
  path: HealthPaths.HealthMedicinePurchase,
  navHide: true,
},
{
  name: messages.medicineCalculatorTitle,
  intro: messages.medicineCalculatorIntro, // Add this line
  path: HealthPaths.HealthMedicineCalculator,
  displayIntroHeader: true,
  activeIfExact: true,
  navHide: true,
},
{
  name: messages.medicineLicenseIntroTitle,
  intro: messages.medicineLicenseIntroIntro, // Add this line
  path: HealthPaths.HealthMedicineCertificates,
  displayIntroHeader: true,
  activeIfExact: true,
  navHide: true,
  children: [
    {
      name: messages.medicineLicenseTitle,
      intro: messages.medicineLicenseIntro, // Add this line
      path: HealthPaths.HealthMedicineCertificate,
      displayIntroHeader: true,
      activeIfExact: true,
      navHide: true,
    },
  ],
},

Also applies to: 113-113, 120-120, 127-127, 134-134

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between ab8b28c and 5a6741c.

Files selected for processing (5)
  • apps/service-portal/src/components/Layout/NarrowLayout.tsx (5 hunks)
  • libs/portals/core/src/types/portalCore.ts (3 hunks)
  • libs/service-portal/education/src/utils/tagSelector.ts (1 hunks)
  • libs/service-portal/health/src/lib/navigation.ts (3 hunks)
  • libs/service-portal/social-insurance-maintenance/src/lib/navigation.ts (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • libs/service-portal/social-insurance-maintenance/src/lib/navigation.ts
Additional context used
Path-based instructions (4)
apps/service-portal/src/components/Layout/NarrowLayout.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/portals/core/src/types/portalCore.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/education/src/utils/tagSelector.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/health/src/lib/navigation.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."
Biome
apps/service-portal/src/components/Layout/NarrowLayout.tsx

[error] 155-155: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

Additional comments not posted (7)
apps/service-portal/src/components/Layout/NarrowLayout.tsx (3)

77-79: Skip comment generation

An existing comment already addresses the issue with the callback function in the find method.


166-166: Skip comment generation

An existing comment already addresses the issue with consistent serviceProviderSlug usage in the FootNote component.


Line range hint 1-171: Approve overall component structure and implementation

The NarrowLayout component demonstrates good adherence to NextJS best practices, efficient state management, and proper use of TypeScript for type safety. The component structure and logic for rendering navigation items and conditional content are well-implemented.

Tools
Biome

[error] 155-155: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

libs/service-portal/health/src/lib/navigation.ts (4)

19-20: LGTM! Consistent and informative additions.

The addition of intro and displayIntroHeader properties to the overview child item enhances the context provided to users. The use of message references for the intro text supports internationalization, which is excellent for reusability across different locales.


70-72: LGTM! Consistent and informative additions.

The addition of displayIntroHeader and intro properties to the aids and nutrition, dentists, and dentist registration items maintains consistency with the established pattern. The use of message references for intro texts supports internationalization and enhances the context provided to users.

Also applies to: 77-78, 82-82, 84-84


92-93: LGTM! Consistent and informative additions.

The addition of intro and displayIntroHeader properties to the health center and health center registration items maintains consistency with the established pattern. The use of message references for intro texts supports internationalization and enhances the context provided to users.

Also applies to: 98-99


144-147: LGTM! Consider adding intro properties to sub-items and clarify additional properties.

The addition of intro and displayIntroHeader properties to the vaccinations, organ donation, and their sub-items maintains consistency with the established pattern and enhances the context provided to users.

For consistency with previous items, consider adding intro properties to all sub-items:

{
  name: messages.generalVaccinations,
  intro: messages.generalVaccinationsIntro, // Add this line
  displayIntroHeader: true,
  path: HealthPaths.HealthVaccinationsGeneral,
  navHide: true,
},
{
  name: messages.otherVaccinations,
  intro: messages.otherVaccinationsIntro, // Add this line
  displayIntroHeader: true,
  path: HealthPaths.HealthVaccinationsOther,
  navHide: true,
},
// ...
{
  name: messages.changeRegistration,
  intro: messages.changeRegistrationIntro, // Add this line
  path: HealthPaths.HealthOrganDonationRegistration,
  displayIntroHeader: true,
  navHide: true,
},

The vaccinations item has additional properties (serviceProvider and serviceProviderTooltip) that are not present in other items. Could you clarify the purpose of these properties and whether they should be added to other items for consistency?

Also applies to: 152-152, 158-158, 166-167, 173-173

Verification successful

LGTM! Consider adding intro properties to sub-items for consistency.

The addition of intro and displayIntroHeader properties to the vaccinations, organ donation, and their sub-items maintains consistency with the established pattern and enhances the context provided to users.

  • For consistency with previous items, consider adding intro properties to all sub-items:
{
  name: messages.generalVaccinations,
  intro: messages.generalVaccinationsIntro, // Add this line
  displayIntroHeader: true,
  path: HealthPaths.HealthVaccinationsGeneral,
  navHide: true,
},
{
  name: messages.otherVaccinations,
  intro: messages.otherVaccinationsIntro, // Add this line
  displayIntroHeader: true,
  path: HealthPaths.HealthVaccinationsOther,
  navHide: true,
},
// ...
{
  name: messages.changeRegistration,
  intro: messages.changeRegistrationIntro, // Add this line
  path: HealthPaths.HealthOrganDonationRegistration,
  displayIntroHeader: true,
  navHide: true,
},
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other occurrences of serviceProvider and serviceProviderTooltip
rg --type typescript 'serviceProvider|serviceProviderTooltip' libs/

Length of output: 104


Script:

#!/bin/bash
# Search for other occurrences of serviceProvider and serviceProviderTooltip with corrected file type
rg --type ts 'serviceProvider|serviceProviderTooltip' libs/

Length of output: 23041

Comment on lines 3 to 7
finished: 'mint',
unfinished: 'purple',
rated: 'blue',
m: 'blue',
failed: 'red',
Copy link
Contributor

@coderabbitai coderabbitai bot Sep 23, 2024

Choose a reason for hiding this comment

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

Improve consistency and type safety in the tagSelector function

The changes to use English keys improve international accessibility. However, there are a few points to address:

  1. The 'Féll á önn' key remains in Icelandic, inconsistent with the other English keys.
  2. The function lacks an explicit return type.
  3. The use of as any type assertion could be improved for better type safety.

Consider applying the following changes:

  1. Translate 'Féll á önn' to English (e.g., 'failed_term').
  2. Add an explicit return type to the function.
  3. Use a more specific type for the color mapping object.

Here's a suggested implementation:

type ColorKey = 'finished' | 'unfinished' | 'rated' | 'm' | 'failed' | 'failed_term';
type ColorValue = 'mint' | 'purple' | 'blue' | 'red';

const colorMap: Record<ColorKey, ColorValue> = {
  finished: 'mint',
  unfinished: 'purple',
  rated: 'blue',
  m: 'blue',
  failed: 'red',
  failed_term: 'red',
};

export const tagSelector = (str: string): ColorValue => {
  return (str in colorMap) ? colorMap[str as ColorKey] : 'blue';
};

This implementation improves type safety and makes the color mapping more explicit and maintainable.

To make the color mapping more flexible and reusable, consider extracting it to a separate constant or configuration file. This would allow easier modifications and potential reuse across different parts of the application.

Copy link
Member

Choose a reason for hiding this comment

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

This is a mapper to map the results from the API to the matching color. Has this been changed in the service as well?

Copy link
Contributor

Choose a reason for hiding this comment

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

@thordurhhh, thank you for the clarification. Since the tagSelector function maps the API results to matching colors and the service still returns Icelandic strings, it makes sense to keep the mapper keys as they are. My previous suggestion would only be applicable if the API responses have changed to English. Please disregard the suggestion if the service has not been updated.

(_/)
(•_•)
( ? )


Learnings added
Learnt from: thordurhhh
PR: island-is/island.is#16078
File: libs/service-portal/education/src/utils/tagSelector.ts:3-7
Timestamp: 2024-09-23T14:05:19.464Z
Learning: The `tagSelector` function maps the Icelandic strings returned from the API to matching colors, and the service currently returns Icelandic strings.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

Comment on lines 155 to 164
{activeItem && activeItem?.displayIntroHeader && (
<IntroHeader
title={activeItem.name}
intro={activeItem.intro}
introComponent={activeItem.introComponent}
serviceProviderSlug={
activeItem.serviceProvider ?? activeParent?.serviceProvider
}
/>
)}
Copy link
Contributor

Choose a reason for hiding this comment

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

Optimize conditional rendering using optional chaining

The current conditional rendering can be simplified using optional chaining for better readability and to avoid potential issues with falsy values.

Apply this diff to optimize the conditional rendering:

-{activeItem && activeItem?.displayIntroHeader && (
+{activeItem?.displayIntroHeader && (
   <IntroHeader
     title={activeItem.name}
     intro={activeItem.intro}
     introComponent={activeItem.introComponent}
     serviceProviderSlug={
       activeItem.serviceProvider ?? activeParent?.serviceProvider
     }
   />
 )}
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.

Suggested change
{activeItem && activeItem?.displayIntroHeader && (
<IntroHeader
title={activeItem.name}
intro={activeItem.intro}
introComponent={activeItem.introComponent}
serviceProviderSlug={
activeItem.serviceProvider ?? activeParent?.serviceProvider
}
/>
)}
{activeItem?.displayIntroHeader && (
<IntroHeader
title={activeItem.name}
intro={activeItem.intro}
introComponent={activeItem.introComponent}
serviceProviderSlug={
activeItem.serviceProvider ?? activeParent?.serviceProvider
}
/>
)}
Tools
Biome

[error] 155-155: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

Copy link
Member

@disaerna disaerna left a comment

Choose a reason for hiding this comment

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

Few minor comments.

But thinking, why not remove all intro headers components in this PR?

@thorkellmani thorkellmani marked this pull request as draft September 23, 2024 14:47
@thorkellmani thorkellmani deleted the feat/intro-to-layout branch November 5, 2024 15:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deploy-feature Deploys features to dev
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants