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(web): Add default header for HSA organization #16131

Merged
merged 3 commits into from
Sep 27, 2024

Conversation

mannipje
Copy link
Member

@mannipje mannipje commented Sep 24, 2024

Add default header for HSA organization

What

Make it possible to use default header for Heilbrigðisstofnun Austurlands organization via config.

Why

A design that was approved by Digital Iceland

Screenshots / Gifs

Before

image

After

image

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 new styling options for the HSA header grid container, enhancing layout and responsiveness.
    • Added conditional rendering in the OrganizationHeader component to display either a DefaultHeader or the existing HeilbrigdisstofnunAusturlandsHeader based on specific conditions.
  • Bug Fixes

    • Improved the display logic for the organization header based on the organization type.

@mannipje mannipje added the automerge Merge this PR as soon as all checks pass label Sep 24, 2024
@mannipje mannipje requested a review from a team as a code owner September 24, 2024 10:55
Copy link
Contributor

coderabbitai bot commented Sep 24, 2024

Walkthrough

The changes in this pull request introduce new CSS styles for the OrganizationWrapper component and modify the rendering logic of the OrganizationHeader. New styles are defined for different header grid containers, enhancing layout capabilities. Additionally, the OrganizationHeader component now includes conditional rendering based on the organization type, allowing for dynamic header selection.

Changes

File Change Summary
apps/web/components/Organization/Wrapper/OrganizationWrapper.css.ts Added new styles: hsaHeaderGridContainerBase, hsaHeaderGridContainerWidthSubpage, and hsaHeaderGridContainerWidth.
apps/web/components/Organization/Wrapper/OrganizationWrapper.tsx Introduced conditional rendering in OrganizationHeader based on the usingDefaultHeader check.

Possibly related PRs

Suggested labels

automerge, high priority

Suggested reviewers

  • RunarVestmann

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: 0

Outside diff range and nitpick comments (5)
apps/web/components/Organization/Wrapper/OrganizationWrapper.css.ts (2)

108-118: LGTM with a minor suggestion for consistency.

The hsaHeaderGridContainerBase style is well-structured and follows the established pattern for organization-specific styles. It correctly uses themeUtils.responsiveStyle for responsive design, which aligns with NextJS best practices.

For consistency with other similar styles in this file, consider adding a background color or gradient for non-large screens. This would ensure a consistent appearance across all device sizes.


122-129: LGTM with a suggestion for accessibility.

The hsaHeaderGridContainerWidth style correctly extends the base style and adds a visually appealing background for large screens. The use of a content-delivered image URL is good for performance and content management.

Consider adding a fallback background color in case the image fails to load. This would improve accessibility and ensure a consistent appearance even in case of network issues. For example:

 background: `url('https://images.ctfassets.net/8k0h54kbe6bj/uc45ywvPOYsIUEQTNfE6s/72fd0f2229407e18c6e2908fb13f51c3/Header_HSA.png') no-repeat right bottom,linear-gradient(90deg, #CCDFFF 0%, #F6F6F6 84.85%)`,
+backgroundColor: '#F6F6F6', // Fallback color matching the end of the gradient
apps/web/components/Organization/Wrapper/OrganizationWrapper.tsx (3)

463-472: LGTM! Consider extracting the className logic for better readability.

The changes look good and provide a flexible way to switch between default and custom headers for the HSA organization. The conditional rendering based on the usingDefaultHeader configuration is a clean approach.

To improve readability, consider extracting the className logic into a separate variable:

+ const headerClassName = isSubpage
+   ? styles.hsaHeaderGridContainerWidthSubpage
+   : styles.hsaHeaderGridContainerWidth;

  return n('usingDefaultHeader', false) ? (
    <DefaultHeader
      {...defaultProps}
-     className={
-       isSubpage
-         ? styles.hsaHeaderGridContainerWidthSubpage
-         : styles.hsaHeaderGridContainerWidth
-     }
+     className={headerClassName}
    />
  ) : (
    <HeilbrigdisstofnunAusturlandsHeader
      organizationPage={organizationPage}
      logoAltText={logoAltText}
    />
  )

This change would make the code more readable and easier to maintain.


Line range hint 1-1141: Consider refactoring the OrganizationHeader component for better maintainability.

While the changes for the HSA organization are good, they highlight some potential areas for improvement in the overall structure of the OrganizationHeader component:

  1. The switch statement is quite long and might benefit from being split into smaller, more manageable functions.
  2. The 'hsa' case now has different behavior compared to other cases. Consider standardizing this approach across other organization types for consistency.
  3. The usingDefaultHeader configuration is used in multiple places. It might be beneficial to create a higher-level abstraction to handle this logic consistently across different organization types.

Here's a suggestion for refactoring:

  1. Create separate functions for each organization type, e.g., renderHSAHeader, renderSyslumennHeader, etc.
  2. Implement a consistent pattern for handling usingDefaultHeader across all organization types.
  3. Use a configuration object or map to associate organization types with their respective rendering functions.

This refactoring would make the code more modular, easier to maintain, and more consistent across different organization types.


Line range hint 1-1141: Consider code cleanup and consistent export style.

While not directly related to the current changes, there are a few areas that could be improved in the file:

  1. There are some TODO comments in the file. It would be beneficial to address these or create issues to track them.
  2. There appear to be some unused imports. Consider removing these to keep the code clean.
  3. The file uses a mix of default exports and named exports. For consistency, consider adopting a single export style throughout the project.

To address these points:

  1. Review and address TODO comments or create corresponding issues.
  2. Use a linter or IDE tool to identify and remove unused imports.
  3. Decide on a preferred export style (default or named) and apply it consistently across the project.

These changes would improve overall code quality and maintainability.

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 9c26661 and 552247c.

Files selected for processing (2)
  • apps/web/components/Organization/Wrapper/OrganizationWrapper.css.ts (1 hunks)
  • apps/web/components/Organization/Wrapper/OrganizationWrapper.tsx (1 hunks)
Additional context used
Path-based instructions (2)
apps/web/components/Organization/Wrapper/OrganizationWrapper.css.ts (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/web/components/Organization/Wrapper/OrganizationWrapper.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."
Additional comments not posted (3)
apps/web/components/Organization/Wrapper/OrganizationWrapper.css.ts (2)

120-120: LGTM! Consistent with other organization styles.

The hsaHeaderGridContainerWidthSubpage style correctly reuses the base style, which is consistent with the approach used for other organizations in this file. This promotes code reusability and easier maintenance.


107-129: Overall changes align well with PR objectives and coding guidelines.

The new styles for the HSA organization header are well-implemented and consistent with the existing patterns in the file. They follow NextJS best practices, make efficient use of CSS-in-JS with @vanilla-extract/css, and align with the PR objective of adding a default header for HSA based on the approved design.

The implementation demonstrates good use of TypeScript for type safety and follows the coding guidelines for the apps/**/* pattern, including efficient state management and adherence to NextJS best practices.

apps/web/components/Organization/Wrapper/OrganizationWrapper.tsx (1)

463-472: Changes align well with PR objectives and coding guidelines.

The implementation of the default header feature for the HSA organization is in line with the PR objectives. It uses conditional rendering, which is a common and efficient React pattern, adhering to the coding guidelines emphasizing NextJS best practices and efficient state management.

The changes don't introduce unnecessary complexity or state, keeping the component efficient and maintainable.

Copy link

codecov bot commented Sep 24, 2024

Codecov Report

Attention: Patch coverage is 0% with 4 lines in your changes missing coverage. Please review.

Project coverage is 36.77%. Comparing base (a8b2817) to head (41dd9e7).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...nents/Organization/Wrapper/OrganizationWrapper.tsx 0.00% 4 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #16131      +/-   ##
==========================================
+ Coverage   36.70%   36.77%   +0.07%     
==========================================
  Files        6776     6771       -5     
  Lines      139598   139276     -322     
  Branches    39683    39532     -151     
==========================================
- Hits        51242    51224      -18     
+ Misses      88356    88052     -304     
Flag Coverage Δ
air-discount-scheme-backend 54.11% <ø> (ø)
air-discount-scheme-web 0.00% <ø> (ø)
api 3.39% <ø> (ø)
api-domains-air-discount-scheme 36.88% <ø> (ø)
api-domains-assets 26.71% <ø> (ø)
api-domains-auth-admin 48.77% <ø> (ø)
api-domains-communications 39.99% <ø> (ø)
api-domains-criminal-record 47.81% <ø> (ø)
api-domains-driving-license 44.33% <ø> (ø)
api-domains-education 31.36% <ø> (ø)
api-domains-health-insurance 34.63% <ø> (ø)
api-domains-mortgage-certificate 35.67% <ø> (ø)
api-domains-payment-schedule 41.17% <ø> (ø)
application-api-files 57.62% <ø> (ø)
application-core 71.54% <ø> (ø)
application-system-api 41.63% <ø> (ø)
application-template-api-modules 23.70% <ø> (ø)
application-templates-accident-notification 22.14% <ø> (ø)
application-templates-car-recycling 3.12% <ø> (ø)
application-templates-criminal-record 26.63% <ø> (ø)
application-templates-driving-license 18.63% <ø> (ø)
application-templates-estate 12.34% <ø> (ø)
application-templates-example-payment 25.41% <ø> (ø)
application-templates-financial-aid 14.34% <ø> (ø)
application-templates-general-petition 23.68% <ø> (ø)
application-templates-health-insurance 26.62% <ø> (ø)
application-templates-inheritance-report 6.45% <ø> (ø)
application-templates-marriage-conditions 15.23% <ø> (ø)
application-templates-mortgage-certificate 43.96% <ø> (ø)
application-templates-parental-leave 30.15% <ø> (+0.12%) ⬆️
application-types 6.71% <ø> (ø)
application-ui-components 1.28% <ø> (ø)
application-ui-shell 21.29% <ø> (ø)
clients-charge-fjs-v2 24.11% <ø> (ø)
clients-driving-license 40.61% <ø> (ø)
clients-driving-license-book 43.88% <ø> (ø)
clients-financial-statements-inao 49.13% <ø> (ø)
clients-license-client 1.83% <ø> (ø)
clients-regulations 42.58% <ø> (ø)
clients-rsk-company-registry 29.76% <ø> (ø)
clients-rsk-personal-tax-return 38.00% <ø> (ø)
clients-smartsolutions 12.77% <ø> (ø)
clients-syslumenn 49.64% <ø> (ø)
cms 0.43% <ø> (ø)
cms-translations 39.11% <ø> (ø)
dokobit-signing 62.94% <ø> (ø)
download-service 44.61% <ø> (ø)
email-service 60.73% <ø> (ø)
feature-flags 90.76% <ø> (ø)
file-storage 53.13% <ø> (ø)
financial-aid-backend 56.53% <ø> (ø)
judicial-system-api 18.46% <ø> (ø)
judicial-system-audit-trail 68.86% <ø> (ø)
judicial-system-backend 54.84% <ø> (ø)
judicial-system-message 66.92% <ø> (ø)
judicial-system-message-handler 47.80% <ø> (ø)
judicial-system-scheduler 69.09% <ø> (ø)
license-api 42.51% <ø> (ø)
nest-config 78.13% <ø> (ø)
nest-feature-flags 51.97% <ø> (ø)
nova-sms 62.28% <ø> (ø)
portals-admin-regulations-admin 1.93% <ø> (ø)
portals-core 16.17% <ø> (ø)
services-auth-admin-api 51.96% <ø> (ø)
services-auth-delegation-api 57.85% <ø> (-0.07%) ⬇️
services-auth-ids-api 51.84% <ø> (-0.02%) ⬇️
services-auth-personal-representative 45.47% <ø> (+0.03%) ⬆️
services-auth-personal-representative-public 41.46% <ø> (-0.13%) ⬇️
services-auth-public-api 49.24% <ø> (ø)
services-endorsements-api 55.11% <ø> (ø)
services-sessions 65.82% <ø> (ø)
services-university-gateway 48.44% <ø> (ø)
services-user-notification 47.15% <ø> (ø)
services-user-profile 62.20% <ø> (-0.10%) ⬇️
web 1.83% <0.00%> (-0.01%) ⬇️

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

Files with missing lines Coverage Δ
...nents/Organization/Wrapper/OrganizationWrapper.tsx 0.00% <0.00%> (ø)

... and 34 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 a8b2817...41dd9e7. Read the comment docs.

@datadog-island-is
Copy link

datadog-island-is bot commented Sep 24, 2024

Datadog Report

All test runs 17ae5cc 🔗

70 Total Test Services: 0 Failed, 68 Passed
🔻 Test Sessions change in coverage: 4 decreased, 1 increased (+0.02%), 189 no change

Test Services
This report shows up to 10 services
Service Name Failed Known Flaky New Flaky Passed Skipped Total Time Code Coverage Change Test Service View
air-discount-scheme-backend 0 0 0 81 0 28.86s N/A Link
air-discount-scheme-web 0 0 0 2 0 7.52s N/A Link
api 0 0 0 4 0 3s N/A Link
api-domains-air-discount-scheme 0 0 0 6 0 19.81s N/A Link
api-domains-assets 0 0 0 3 0 12.88s 1 no change Link
api-domains-auth-admin 0 0 0 18 0 13.96s N/A Link
api-domains-communications 0 0 0 5 0 32.03s N/A Link
api-domains-criminal-record 0 0 0 5 0 10.1s 1 no change Link
api-domains-driving-license 0 0 0 23 0 27.52s N/A Link
api-domains-education 0 0 0 8 0 18.76s 1 no change Link

🔻 Code Coverage Decreases vs Default Branch (4)

  • services-auth-delegation-api - jest 51.26% (-0.19%) - Details
  • services-auth-personal-representative-public - jest 40.67% (-0.05%) - Details
  • services-user-profile - jest 52.7% (-0.04%) - Details
  • services-auth-ids-api - jest 45.01% (-0.01%) - Details

@kodiakhq kodiakhq bot removed the automerge Merge this PR as soon as all checks pass label Sep 24, 2024
Copy link
Contributor

kodiakhq bot commented Sep 24, 2024

This PR currently has a merge conflict. Please resolve this and then re-add the automerge label.

@mannipje mannipje added the automerge Merge this PR as soon as all checks pass label Sep 27, 2024
@kodiakhq kodiakhq bot merged commit 6d4e030 into main Sep 27, 2024
197 checks passed
@kodiakhq kodiakhq bot deleted the feature/add-default-header-for-hsa branch September 27, 2024 13:52
thoreyjona pushed a commit that referenced this pull request Oct 2, 2024
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Merge this PR as soon as all checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants