Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ojoi): Bug fixes and add adverts to web project. #16388

Merged
merged 4 commits into from
Oct 15, 2024

Conversation

jonbjarnio
Copy link
Member

@jonbjarnio jonbjarnio commented Oct 14, 2024

What

Bugfixes and advert on web frontpage

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

Release Notes

  • New Features

    • Introduced a new component for displaying advertisement cards for the Official Journal of Iceland.
    • Enhanced the home screen to fetch and display adverts from multiple departments with improved loading and error handling.
  • Bug Fixes

    • Updated the handling of optional advertisement props in the search list view to prevent errors when no adverts are provided.
  • Localization

    • Added new messages for better user experience in Icelandic, including error messages and labels for adverts.
  • Improvements

    • Updated date formatting for signatures to allow for flexible display options.
    • Improved the layout of category display in advertisement cards for better readability.

@jonbjarnio jonbjarnio requested a review from a team as a code owner October 14, 2024 15:34
Copy link
Contributor

coderabbitai bot commented Oct 14, 2024

Walkthrough

The pull request introduces several changes across multiple files related to the Official Journal of Iceland application. A new React component, OJOIAdvertCards, is added to render advertisement cards. The OJOISearchListView component's adverts prop is modified to be optional. The OJOIHome screen is enhanced with Apollo Client queries to fetch advertisements from different departments, and new messages for localization are added. Additionally, there are updates to the Chairman and RegularMember components for input field properties, as well as modifications to constants and message definitions for consistency.

Changes

File Change Summary
apps/web/components/OfficialJournalOfIceland/OJOIAdvertCards.tsx Introduced new component OJOIAdvertCards to render advertisement cards, accepting adverts and locale props.
apps/web/components/OfficialJournalOfIceland/OJOIAdvertCard.tsx Modified OJOIAdvertCard to allow categories to wrap onto multiple lines by updating the Box component properties.
apps/web/components/OfficialJournalOfIceland/OJOISearchListView.tsx Changed adverts prop from required to optional, allowing for undefined values.
apps/web/components/OfficialJournalOfIceland/index.ts Added export statement for OJOIAdvertCards component.
apps/web/screens/OfficialJournalOfIceland/OJOIHome.tsx Enhanced functionality to fetch adverts using Apollo Client for three departments, combined results into a single array, and updated UI layout for displaying adverts with loading/error handling.
apps/web/screens/OfficialJournalOfIceland/messages.ts Added new messages for localization: latestAdverts, emptySearchResult, errorFetchingAdvertsTitle, and errorFetchingAdvertsMessage.
libs/application/templates/official-journal-of-iceland/src/components/signatures/Chairman.tsx Modified property references in SignatureMember components.
libs/application/templates/official-journal-of-iceland/src/components/signatures/RegularMember.tsx Updated input fields to swap roles of name and after properties in SignatureMember components.
libs/application/templates/official-journal-of-iceland/src/lib/constants.ts Added new constant OJOI_DF with value 'd. MMMM yyyy.'.
libs/application/templates/official-journal-of-iceland/src/lib/messages/attachments.ts Updated default messages for attachment terminology in Icelandic.
libs/application/templates/official-journal-of-iceland/src/lib/messages/publishing.ts Modified communicationIntro message to provide relevant instructions in Icelandic instead of placeholder text.
libs/application/templates/official-journal-of-iceland/src/lib/utils.ts Updated date formatting logic in signatureTemplate function to use the new OJOI_DF constant.

Possibly related PRs

Suggested reviewers

  • kksteini
  • thorkellmani

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

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

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

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

Other keywords and placeholders

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

Documentation and Community

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

Copy link

codecov bot commented Oct 14, 2024

Codecov Report

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

Project coverage is 36.75%. Comparing base (4ab0c90) to head (08ca994).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
.../web/screens/OfficialJournalOfIceland/OJOIHome.tsx 0.00% 9 Missing ⚠️
...nents/OfficialJournalOfIceland/OJOIAdvertCards.tsx 0.00% 4 Missing ⚠️
...onents/OfficialJournalOfIceland/OJOIAdvertCard.tsx 0.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #16388      +/-   ##
==========================================
- Coverage   36.75%   36.75%   -0.01%     
==========================================
  Files        6807     6808       +1     
  Lines      140978   140991      +13     
  Branches    40149    40156       +7     
==========================================
- Hits        51818    51816       -2     
- Misses      89160    89175      +15     
Flag Coverage Δ
api 3.37% <ø> (ø)
api-domains-auth-admin 48.48% <ø> (ø)
application-system-api 41.42% <ø> (ø)
application-template-api-modules 27.88% <ø> (-0.02%) ⬇️
application-ui-shell 21.35% <ø> (ø)
services-auth-admin-api 51.89% <ø> (ø)
services-auth-delegation-api 57.32% <ø> (ø)
services-auth-ids-api 51.42% <ø> (-0.01%) ⬇️
services-auth-personal-representative 45.16% <ø> (ø)
services-auth-personal-representative-public 41.28% <ø> (+0.04%) ⬆️
services-auth-public-api 48.90% <ø> (-0.01%) ⬇️
services-user-notification 47.02% <ø> (ø)
services-user-profile 62.10% <ø> (-0.08%) ⬇️
web 1.82% <0.00%> (-0.01%) ⬇️

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

Files with missing lines Coverage Δ
...ts/OfficialJournalOfIceland/OJOISearchListView.tsx 0.00% <ø> (ø)
...s/web/screens/OfficialJournalOfIceland/messages.ts 0.00% <ø> (ø)
...onents/OfficialJournalOfIceland/OJOIAdvertCard.tsx 0.00% <0.00%> (ø)
...nents/OfficialJournalOfIceland/OJOIAdvertCards.tsx 0.00% <0.00%> (ø)
.../web/screens/OfficialJournalOfIceland/OJOIHome.tsx 0.00% <0.00%> (ø)

... and 2 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 4ab0c90...08ca994. Read the comment docs.

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

🧹 Outside diff range and nitpick comments (10)
libs/application/templates/official-journal-of-iceland/src/lib/constants.ts (2)

7-7: Consider adding a comment explaining the purpose of OJOI_DF.

The new constant OJOI_DF has been added with the value 'd. MMMM yyyy.'. While the format suggests it's a date format string, it would be helpful to add a brief comment explaining its specific purpose and usage within the Official Journal of Iceland application.

Consider adding a comment above the constant, like this:

// Date format string for displaying dates in the Official Journal of Iceland (e.g., "1. January 2023.")
export const OJOI_DF = 'd. MMMM yyyy.'

This addition aligns with the coding guidelines for libs/**/* files by improving code readability and maintainability across different NextJS apps.


Line range hint 1-83: Consider improving file organization and documentation.

The file adheres to the coding guidelines for libs/**/* files by using TypeScript and defining reusable constants and types. However, consider the following improvements to enhance maintainability and readability:

  1. Group related constants and enums together, separating them with comments explaining their purpose.
  2. Add brief comments for non-obvious constants or enums to explain their usage.
  3. Consider splitting this file into smaller, more focused files if it grows larger (e.g., separate files for date-related constants, file-related constants, etc.).

Here's an example of how you could start reorganizing the file:

// Date and time constants
export const OJOI_DF = 'd. MMMM yyyy.'
export const INTERVAL_TIMER = 3000
export const DEBOUNCE_INPUT_TIMER = 333

// File-related constants
export const ALLOWED_FILE_TYPES = ['.pdf', '.doc', '.docx']
export const FILE_SIZE_LIMIT = 10000000

// Regular expressions
export const emailRegex = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i

// Enums
export enum AnswerOption {
  YES = 'yes',
  NO = 'no',
}

export enum ApplicationAttachmentType {
  ORIGINAL = 'frumrit',
  ADDITIONS = 'fylgiskjol',
}

// ... (continue grouping and commenting)

These changes will improve the overall structure and make the file easier to maintain as it grows.

apps/web/components/OfficialJournalOfIceland/OJOISearchListView.tsx (3)

13-13: Prop type change looks good, consider using nullish coalescing for default value.

The change to make the adverts prop optional is a good improvement, allowing the component to handle cases where advertisements might not be available. This change enhances the component's flexibility and adheres to TypeScript best practices.

Consider providing a default empty array using nullish coalescing to simplify the usage within the component:

adverts?: OfficialJournalOfIcelandAdvertsResponse['adverts'] = []

This would allow you to remove the optional chaining operator (?.) when mapping over adverts, making the code slightly cleaner.


30-30: Usage of optional chaining is correct, consider memoization for performance.

The use of optional chaining (?.) when mapping over adverts is correct and consistent with the new prop type. This ensures that the component doesn't throw an error if adverts is undefined.

For potential performance optimization, consider memoizing the mapped JSX if adverts is expected to be a large array:

const memoizedAdverts = useMemo(() => 
  adverts?.map((ad) => (
    // ... existing JSX
  )),
  [adverts]
);

// Then in your JSX:
{memoizedAdverts}

This would prevent unnecessary re-renders if the component re-renders for reasons unrelated to the adverts prop.


Line range hint 1-68: Overall structure adheres to NextJS and React best practices.

The component structure is well-organized and follows React and NextJS best practices. It's a functional component with proper use of TypeScript for type safety. The single responsibility of rendering a table of advertisements is maintained, which is good for modularity and maintainability.

For consistency and to follow modern React practices, consider using the FC type for the component definition:

import { FC } from 'react';

type OJOISearchListViewProps = {
  adverts?: OfficialJournalOfIcelandAdvertsResponse['adverts'];
  locale: Locale;
};

export const OJOISearchListView: FC<OJOISearchListViewProps> = ({
  adverts,
  locale,
}) => {
  // ... component body
};

This explicitly defines the component as a functional component and can help with type inference in some cases.

libs/application/templates/official-journal-of-iceland/src/lib/messages/publishing.ts (1)

24-25: LGTM! Consider adding a minor clarification.

The update to the communicationIntro message is appropriate and provides clear instructions in Icelandic, which is more suitable for the Official Journal of Iceland application. The change maintains the existing structure and doesn't affect reusability, TypeScript usage, or tree-shaking practices.

Consider adding a brief clarification about the purpose of providing multiple contact methods. For example:

- 'Hér getur þú skráð inn tölvupóstfang og/eða símanúmer þess sem best er að hafa samskipti við vegna málsins, hægt að skrá fleiri en einn.',
+ 'Hér getur þú skráð inn tölvupóstfang og/eða símanúmer þess sem best er að hafa samskipti við vegna málsins. Hægt er að skrá fleiri en einn tengilið til að tryggja góð samskipti.',

This addition clarifies the purpose of allowing multiple entries and maintains the helpful tone of the message.

libs/application/templates/official-journal-of-iceland/src/components/signatures/Chairman.tsx (3)

93-100: LGTM! Consider updating the component's name prop for consistency.

The changes to this SignatureMember component look good. The props have been correctly updated to use the "name" field instead of the "after" field.

For consistency, consider updating the name prop to remove the typo in "comittee":

-name={`signature.comittee.member.name`}
+name={`signature.committee.member.name`}

105-112: LGTM! Consider updating the component's name prop for consistency.

The changes to this SignatureMember component look good. The props have been correctly updated to use the "after" field instead of the "name" field.

For consistency, consider updating the name prop to remove the typo in "comittee":

-name={`signature.comittee.member.after`}
+name={`signature.committee.member.after`}

Line range hint 1-128: Overall, the changes look good. Consider a global rename for consistency.

The modifications to the Chairman component are correct and maintain its reusability across different NextJS apps. The TypeScript usage for props is preserved, and there are no apparent issues that would affect tree-shaking or bundling.

To improve consistency throughout the file, consider performing a global rename to correct the spelling of "committee":

sed -i 's/comittee/committee/g' libs/application/templates/official-journal-of-iceland/src/components/signatures/Chairman.tsx

This will ensure that all instances of "comittee" are replaced with the correct spelling "committee" throughout the file.

apps/web/screens/OfficialJournalOfIceland/OJOIHome.tsx (1)

84-92: Evaluate the use of 'fetchPolicy: no-cache'

The fetchPolicy is set to 'no-cache' for each query, which disables caching and forces the application to fetch fresh data every time. This may impact performance due to increased network requests. Consider whether this is necessary or if the default caching behavior can be utilized to improve performance.

Also applies to: 104-112, 124-132

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 83b076f and 10023be.

📒 Files selected for processing (11)
  • apps/web/components/OfficialJournalOfIceland/OJOIAdvertCards.tsx (1 hunks)
  • apps/web/components/OfficialJournalOfIceland/OJOISearchListView.tsx (2 hunks)
  • apps/web/components/OfficialJournalOfIceland/index.ts (1 hunks)
  • apps/web/screens/OfficialJournalOfIceland/OJOIHome.tsx (4 hunks)
  • apps/web/screens/OfficialJournalOfIceland/messages.ts (1 hunks)
  • libs/application/templates/official-journal-of-iceland/src/components/signatures/Chairman.tsx (1 hunks)
  • libs/application/templates/official-journal-of-iceland/src/components/signatures/RegularMember.tsx (2 hunks)
  • libs/application/templates/official-journal-of-iceland/src/lib/constants.ts (1 hunks)
  • libs/application/templates/official-journal-of-iceland/src/lib/messages/attachments.ts (3 hunks)
  • libs/application/templates/official-journal-of-iceland/src/lib/messages/publishing.ts (1 hunks)
  • libs/application/templates/official-journal-of-iceland/src/lib/utils.ts (2 hunks)
🧰 Additional context used
📓 Path-based instructions (11)
apps/web/components/OfficialJournalOfIceland/OJOIAdvertCards.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/web/components/OfficialJournalOfIceland/OJOISearchListView.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/web/components/OfficialJournalOfIceland/index.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/screens/OfficialJournalOfIceland/OJOIHome.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/web/screens/OfficialJournalOfIceland/messages.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."
libs/application/templates/official-journal-of-iceland/src/components/signatures/Chairman.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/official-journal-of-iceland/src/components/signatures/RegularMember.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/official-journal-of-iceland/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/application/templates/official-journal-of-iceland/src/lib/messages/attachments.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/application/templates/official-journal-of-iceland/src/lib/messages/publishing.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/application/templates/official-journal-of-iceland/src/lib/utils.ts (1)

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

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
🔇 Additional comments (16)
apps/web/components/OfficialJournalOfIceland/OJOIAdvertCards.tsx (3)

1-6: LGTM: Imports are well-organized and follow best practices.

The imports are correctly structured, using absolute imports as per NextJS best practices. They provide necessary types, components, and utilities for the implementation, enhancing type safety and maintainability.


8-11: LGTM: Props type is well-defined and follows TypeScript best practices.

The Props type is correctly defined, making good use of TypeScript features:

  • It leverages types from the API schema and shared types, ensuring consistency.
  • The adverts prop is optional, providing flexibility in component usage.
  • The locale prop is required, ensuring necessary information is always provided.

1-30: Overall, excellent implementation of the OJOIAdvertCards component.

This new component is well-structured, type-safe, and adheres to NextJS and React best practices. It efficiently renders advertisement cards using appropriate UI components and hooks. The code is clean, readable, and maintainable.

Key strengths:

  1. Proper use of TypeScript for enhanced type safety.
  2. Adherence to NextJS file structure and import practices.
  3. Efficient use of existing components and hooks.
  4. Clear and concise implementation of the component logic.

With the minor optimization suggestion implemented, this component will be a solid addition to the project.

libs/application/templates/official-journal-of-iceland/src/lib/messages/attachments.ts (4)

7-7: LGTM: Consistent terminology update

The change from "Viðaukar og fylgirit" to "Viðaukar og fylgiskjöl" appears to be a consistent terminology update in Icelandic. This modification aligns with the overall changes in the file and doesn't affect the code structure or reusability.


18-18: LGTM: Consistent terminology update

The change from "Viðaukar og fylgirit" to "Viðaukar og fylgiskjöl" is consistent with the previous update in line 7. This ensures uniformity in terminology throughout the messages object.


58-58: LGTM: Consistent terminology update

The change from "Fylgirit (I, II, III..)" to "Fylgiskjöl (I, II, III..)" aligns with the previous terminology updates in this file. This modification ensures consistency across all related messages.


Line range hint 1-62: Overall assessment: Changes adhere to coding guidelines

The modifications in this file consist of consistent terminology updates in Icelandic messages. These changes:

  1. Maintain the reusability of the messages across different NextJS apps.
  2. Preserve the existing TypeScript usage for defining props and exporting types.
  3. Do not affect tree-shaking or bundling practices.

The updates are well-structured and align with the coding guidelines for files in the libs/**/* pattern.

libs/application/templates/official-journal-of-iceland/src/components/signatures/RegularMember.tsx (1)

121-123: Clarify the purpose of swapping "name" and "after" fields

The changes in the SignatureMember components swap the roles of the "name" and "after" fields. While the implementation looks correct, there are some concerns:

  1. This swap might introduce inconsistencies in data handling if not applied uniformly across the application.
  2. The purpose of this change is not immediately clear. Could you provide more context on why this swap is necessary or beneficial?
  3. These changes might affect data persistence and retrieval. Have corresponding changes been made in the backend to handle this new structure?

To ensure consistency, let's check for other occurrences of these field names:

Please clarify the rationale behind these changes and confirm that they have been consistently applied throughout the codebase.

Also applies to: 128-128, 138-140, 145-145

✅ Verification successful

Verification Successful: Changes Are Localized

The modifications to the name and after fields in the RegularMember.tsx component are confined to this file only. No other parts of the codebase reference these fields, ensuring that the changes do not introduce inconsistencies elsewhere.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other occurrences of "signature.regular.member.name" and "signature.regular.member.after"
rg --type typescript "signature\.regular\.member\.(name|after)"

Length of output: 100


Script:

#!/bin/bash
# Search for other occurrences of "signature.regular.member.name" and "signature.regular.member.after" in TypeScript files
rg "signature\.regular\.member\.(name|after)" --glob "*.ts" --glob "*.tsx"

Length of output: 439

apps/web/screens/OfficialJournalOfIceland/messages.ts (5)

38-41: LGTM: New message for latest adverts added correctly.

The new latestAdverts message follows the existing pattern and naming conventions. The ID is consistent with other messages in the home section, and the default message is appropriately in Icelandic.


49-52: LGTM: New message for empty search result added correctly.

The new emptySearchResult message adheres to the existing pattern and naming conventions. The ID is consistent with other messages in the search section, and the default message is appropriately in Icelandic.


53-56: LGTM: New message for error fetching adverts title added correctly.

The new errorFetchingAdvertsTitle message follows the existing pattern and naming conventions. The ID is consistent with other messages in the search section, and the default message is appropriately in Icelandic.


57-61: LGTM: New message for error fetching adverts message added correctly.

The new errorFetchingAdvertsMessage message adheres to the existing pattern and naming conventions. The ID is consistent with other messages in the search section, and the default message is appropriately in Icelandic. The multi-line format improves readability for longer messages.


38-61: Summary: New messages align with PR objectives and enhance localization.

The added messages (latestAdverts, emptySearchResult, errorFetchingAdvertsTitle, and errorFetchingAdvertsMessage) are well-integrated into the existing file structure and follow consistent naming conventions. These additions enhance the localization support for advertisements and search functionality, aligning with the PR objective of adding advertisements to the web project.

The new messages provide appropriate text for:

  1. Displaying latest advertisements
  2. Handling empty search results
  3. Showing error messages when fetching advertisements fails

These changes will improve the user experience by providing localized feedback for various scenarios related to advertisements.

libs/application/templates/official-journal-of-iceland/src/lib/utils.ts (3)

16-16: LGTM: New import adheres to coding guidelines.

The addition of the OJOI_DF import from ./constants is consistent with the coding guidelines for the libs directory. It uses named imports, which is beneficial for tree-shaking and bundling practices.


214-215: LGTM: Improved date formatting using constant.

The update to use OJOI_DF for date formatting enhances flexibility and maintainability. It adheres to the coding guidelines for the libs directory by improving reusability across different NextJS apps. The preservation of the is locale maintains proper internationalization support.


Line range hint 1-324: Overall assessment: Changes adhere to coding guidelines and improve code quality.

The modifications in this file, particularly the new import and the updated date formatting in signatureTemplate, align well with the coding guidelines for the libs directory. These changes enhance reusability and maintainability while preserving TypeScript usage and effective tree-shaking practices. The code remains consistent with the existing structure and doesn't introduce any apparent issues.

@datadog-island-is
Copy link

datadog-island-is bot commented Oct 14, 2024

Datadog Report

All test runs abe57d4 🔗

15 Total Test Services: 0 Failed, 15 Passed
🔻 Test Sessions change in coverage: 1 decreased (-0.02%), 28 no change

Test Services
This report shows up to 10 services
Service Name Failed Known Flaky New Flaky Passed Skipped Total Time Code Coverage Change Test Service View
api 0 0 0 4 0 2.62s 1 no change Link
api-domains-auth-admin 0 0 0 18 0 12.02s 1 no change Link
application-system-api 0 0 0 120 2 2m 48.37s 1 no change Link
application-template-api-modules 0 0 0 123 0 2m 17.69s 1 no change Link
application-ui-shell 0 0 0 74 0 31.93s 1 no change Link
auth-api-lib 0 0 0 20 0 30.17s 1 no change Link
services-auth-admin-api 0 0 0 128 0 2m 59.29s 1 no change Link
services-auth-delegation-api 0 0 0 256 0 2m 58.73s 1 no change Link
services-auth-ids-api 0 0 0 152 0 57.13s 1 no change Link
services-auth-personal-representative 0 0 0 59 0 1m 13.67s 1 no change Link

🔻 Code Coverage Decreases vs Default Branch (1)

  • services-user-profile - jest 52.74% (-0.02%) - Details

@jonbjarnio jonbjarnio added the automerge Merge this PR as soon as all checks pass label Oct 15, 2024
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 (2)
apps/web/components/OfficialJournalOfIceland/OJOIAdvertCard.tsx (1)

62-70: Approved with a minor suggestion for improvement

The changes to the Box components improve the layout flexibility and spacing consistency for the categories. The addition of flexWrap="wrap" allows for better responsiveness, especially when there are many categories.

To further improve the code, consider implementing the optional chain suggestion:

- {categories && categories.length && (
+ {categories?.length && (

This change makes the code more concise and maintains the same functionality.

🧰 Tools
🪛 Biome

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

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

apps/web/screens/OfficialJournalOfIceland/OJOIHome.tsx (1)

173-202: LGTM: Latest adverts section well-implemented with a minor suggestion

The new section for latest adverts is well-implemented, handling loading states, errors, and conditional rendering of adverts appropriately. The use of SkeletonLoader for loading states and localized error messages are good practices.

Suggestion for improvement:
Consider adding an aria-live attribute to the Stack component containing the adverts to improve accessibility for screen readers. This will announce changes in the adverts content to users relying on assistive technologies.

Example:

- <Stack space={3}>
+ <Stack space={3} aria-live="polite">
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 10023be and 43d5c73.

📒 Files selected for processing (2)
  • apps/web/components/OfficialJournalOfIceland/OJOIAdvertCard.tsx (1 hunks)
  • apps/web/screens/OfficialJournalOfIceland/OJOIHome.tsx (4 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
apps/web/components/OfficialJournalOfIceland/OJOIAdvertCard.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/web/screens/OfficialJournalOfIceland/OJOIHome.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."
🪛 Biome
apps/web/components/OfficialJournalOfIceland/OJOIAdvertCard.tsx

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

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

🔇 Additional comments (4)
apps/web/screens/OfficialJournalOfIceland/OJOIHome.tsx (4)

Line range hint 3-27: LGTM: New imports added for adverts functionality

The new imports, including useQuery from Apollo Client and additional types, are correctly added to support the new adverts functionality.


35-49: LGTM: New component and query imports added

The new imports for OJOIAdvertCard, OJOIAdvertCards, and the ADVERTS_QUERY are correctly added to support the new adverts functionality.


155-172: LGTM: Main categories section added

The new section for main categories is well-implemented, using the project's UI components and following responsive design principles with GridRow and GridColumn. The addition of a title and a link to view all categories enhances user navigation.


75-91: Consider the impact of 'no-cache' fetch policy

The implementation of the useQuery hook to fetch adverts is correct and follows Apollo Client best practices. However, the 'no-cache' fetch policy will result in a network request on every render. While this ensures fresh data, it may impact performance, especially for frequently re-rendered components.

Consider if caching would be beneficial for your use case. If real-time data is not critical, you might want to use a different fetch policy like 'cache-first' or 'cache-and-network' to improve performance.

To verify the impact of the 'no-cache' policy, you can run the following command to check for multiple identical network requests:

This will help identify if there are multiple instances of this query that might benefit from caching.

✅ Verification successful

Verified: Single usage of 'ADVERTS_QUERY'

The search revealed only one instance of useQuery with ADVERTS_QUERY in the codebase. Therefore, the 'no-cache' fetch policy will not lead to multiple unnecessary network requests. The current implementation is appropriate if fresh data is required for this single query.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for network requests related to advert fetching
rg --type typescript "useQuery.*ADVERTS_QUERY" -A 10 -B 5

Length of output: 94


Script:

#!/bin/bash
# Search for network requests related to advert fetching in TypeScript files using file extensions
rg "useQuery.*ADVERTS_QUERY" -g "*.ts" -g "*.tsx" -A 10 -B 5

Length of output: 1643

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