-
Notifications
You must be signed in to change notification settings - Fork 61
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
chore(web): Stop importing GraphQL types from api/schema #17356
base: main
Are you sure you want to change the base?
Conversation
WalkthroughThis pull request involves a comprehensive update of import statements across multiple files in the web application. The primary change is migrating type and component imports from Changes
Possibly related PRs
Suggested Reviewers
Suggested labels
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this 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
🧹 Nitpick comments (7)
apps/web/screens/Organization/StafraentIsland/ApiCatalogue.tsx (1)
49-49
: Relative path import
Using relative paths can be fragile if the project structure changes. Consider an absolute import path if available.apps/web/screens/Home/Home.tsx (2)
33-33
: Be mindful ofdocument
usage in a Next.js environment.Directly accessing
document
may fail during SSR. Consider guarding with a runtime check (e.g.,typeof window !== 'undefined'
) or a React effect hook if editing DOM elements. This prevents potential reference errors in a server-side context.
Line range hint
66-102
: Assess naming of thegetProps
function for Next.js compatibility.While defining
Home.getProps
can work as a custom utility, considergetStaticProps
orgetServerSideProps
naming for conventional Next.js patterns. This can improve clarity and developer experience while ensuring correct SSR or SSG handling.apps/web/screens/Login/Login.tsx (1)
5-13
: Ensure consistent styling and minimal complexity in imports.The reorganized imports look clear. However, if these UI components are used widely across the codebase, consider dedicated UI modules for shared imports to keep each screen lightweight and consistent.
apps/web/components/ServiceWeb/Forms/StandardForm/StandardForm.tsx (2)
Line range hint
95-98
: Conditional fields logicThe conditional rendering of fields based on
categoryId
andinstitutionSlugBelongsToMannaudstorg
orinstitutionSligBelongsToDirectorateOfImmigration
is well-defined. Double-check that these conditions are not duplicated in other parts of the code, to adhere to the DRY principle.
Line range hint
214-220
: Enhanced validation checksUse of Yup or a similar validation library can simplify complex validations and error messages, although the current approach with React Hook Form rules is acceptable. Consider centralizing repeated validation rules for maintainability.
apps/web/components/connected/fiskistofa/calculators/StraddlingStockCalculator/machine.ts (1)
1-3
: Specify a more explicit type argument for ApolloClient
It's generally safer and clearer to replaceApolloClient<object>
with a more specific type argument to improve maintainability and type safety.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (25)
apps/web/components/Charts/v2/hooks/chart.ts
(1 hunks)apps/web/components/OfficialJournalOfIceland/OJOIAdvertCards.tsx
(1 hunks)apps/web/components/ServiceWeb/Forms/StandardForm/StandardForm.tsx
(1 hunks)apps/web/components/TableOfContents/TableOfContents.tsx
(1 hunks)apps/web/components/connected/electronicRegistrationStatistics/MonthlyStatistics/MonthlyStatistics.tsx
(1 hunks)apps/web/components/connected/fiskistofa/ShipSearch/ShipSearch.tsx
(1 hunks)apps/web/components/connected/fiskistofa/calculators/CatchQuotaCalculator/CatchQuotaCalculator.tsx
(1 hunks)apps/web/components/connected/fiskistofa/calculators/CatchQuotaCalculator/machine.ts
(1 hunks)apps/web/components/connected/fiskistofa/calculators/StraddlingStockCalculator/StraddlingStockCalculator.tsx
(1 hunks)apps/web/components/connected/fiskistofa/calculators/StraddlingStockCalculator/machine.ts
(1 hunks)apps/web/components/connected/syslumenn/TableLists/BrokersList/BrokersList.tsx
(1 hunks)apps/web/components/connected/syslumenn/TableLists/JourneymanList/JourneymanList.tsx
(1 hunks)apps/web/components/connected/syslumenn/TableLists/MasterList/MasterList.tsx
(1 hunks)apps/web/screens/Adgerdir/Article.tsx
(1 hunks)apps/web/screens/Adgerdir/Home.tsx
(1 hunks)apps/web/screens/Adgerdir/components/AdgerdirArticles/AdgerdirArticles.tsx
(1 hunks)apps/web/screens/Adgerdir/components/CardsSlider/CardsSlider.tsx
(1 hunks)apps/web/screens/Adgerdir/components/FeaturedNews/FeaturedNews.tsx
(1 hunks)apps/web/screens/Adgerdir/components/LatestNews/LatestNews.tsx
(1 hunks)apps/web/screens/Home/Home.tsx
(1 hunks)apps/web/screens/LifeEvents/LifeEvents.tsx
(1 hunks)apps/web/screens/Login/Login.tsx
(1 hunks)apps/web/screens/OfficialJournalOfIceland/hooks/useAdverts.ts
(1 hunks)apps/web/screens/Organization/SocialInsuranceAdministration/PensionCalculator.tsx
(1 hunks)apps/web/screens/Organization/StafraentIsland/ApiCatalogue.tsx
(2 hunks)
✅ Files skipped from review due to trivial changes (6)
- apps/web/components/Charts/v2/hooks/chart.ts
- apps/web/components/connected/fiskistofa/calculators/CatchQuotaCalculator/CatchQuotaCalculator.tsx
- apps/web/screens/Adgerdir/components/LatestNews/LatestNews.tsx
- apps/web/screens/Adgerdir/components/CardsSlider/CardsSlider.tsx
- apps/web/screens/LifeEvents/LifeEvents.tsx
- apps/web/screens/Organization/SocialInsuranceAdministration/PensionCalculator.tsx
🧰 Additional context used
📓 Path-based instructions (19)
apps/web/components/connected/syslumenn/TableLists/JourneymanList/JourneymanList.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/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/connected/fiskistofa/calculators/StraddlingStockCalculator/StraddlingStockCalculator.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/connected/syslumenn/TableLists/BrokersList/BrokersList.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/connected/syslumenn/TableLists/MasterList/MasterList.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/ServiceWeb/Forms/StandardForm/StandardForm.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/Adgerdir/components/FeaturedNews/FeaturedNews.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/TableOfContents/TableOfContents.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/connected/fiskistofa/ShipSearch/ShipSearch.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/hooks/useAdverts.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/Adgerdir/components/AdgerdirArticles/AdgerdirArticles.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/Adgerdir/Article.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/Adgerdir/Home.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/Login/Login.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/connected/fiskistofa/calculators/StraddlingStockCalculator/machine.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/Home/Home.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/connected/electronicRegistrationStatistics/MonthlyStatistics/MonthlyStatistics.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/Organization/StafraentIsland/ApiCatalogue.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/connected/fiskistofa/calculators/CatchQuotaCalculator/machine.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."
🔇 Additional comments (62)
apps/web/components/connected/fiskistofa/calculators/StraddlingStockCalculator/StraddlingStockCalculator.tsx (1)
16-16
: Good alignment with the updated import path.
This change correctly updates the import path to reference @island.is/web/graphql/schema
, aligning the component with newer GraphQL schema conventions. Confirm that all references to CatchQuotaCategory
remain compatible with the new schema definitions throughout the codebase.
apps/web/screens/Adgerdir/components/AdgerdirArticles/AdgerdirArticles.tsx (16)
4-4
: Use of useContext
is correct and aligned with React best practices.
Everything looks good here for leveraging context from React.
7-7
: Reintroduction of useState
import is correct.
This import is essential for managing internal state.
10-10
: Use of uniq
is good for deduplication of tag IDs.
Lodash methods are well-suited for simplifying array manipulation. No issues found.
15-15
: Inline
import from Island UI is properly included.
Ensures consistent styling and layout.
17-17
: Stack
import from Island UI is properly included.
Allows vertical spacing between components.
18-18
: Text
import from Island UI is properly handled.
Matches the usage in the file.
19-19
: Tiles
import from Island UI is used correctly.
Enables a grid layout for cards.
23-23
: ADGERDIR_COMPANIES_TAG_ID
import follows consistency with constants.
This appears to be used correctly for filtering.
25-25
: GraphQL schema import is aligned with the new path.
Importing AdgerdirPage
and AdgerdirTag
from @island.is/web/graphql/schema
centralizes GraphQL type definitions in the web layer.
26-26
: useNamespace
import enhances localization and i18n usage.
Ensures that the namespace object is properly fetched and applied.
27-27
: useLinkResolver
import is consistent with linking patterns in the codebase.
Crucial for generating dynamic links as per the project’s routing strategy.
29-29
: Button
import from a custom UI directory is appropriate.
Maintains a consistent UI system across components.
30-30
: Card
import from a custom UI directory is consistent.
No issues found with structure or usage here.
31-31
: ColorSchemeContext
import ensures a consistent color scheme across the UI.
Leverages contextual theming effectively.
32-32
: Tag
import from a custom UI directory aligns with theming and styling.
Use of standardized design components is consistent with best practices.
34-34
: CSS module import for AdgerdirArticles.css
is correctly referenced.
No issues with naming or usage.
apps/web/components/connected/syslumenn/TableLists/BrokersList/BrokersList.tsx (1)
15-15
: Verify new import path correctness.
The increased granularity of the new import path from @island.is/web/graphql/schema
looks correct. Ensure that all references to the Query
type from the old source have been updated across the codebase to avoid type mismatches.
apps/web/components/connected/electronicRegistrationStatistics/MonthlyStatistics/MonthlyStatistics.tsx (2)
14-14
: Confirm alignment with updated endpoint.
Changing ConnectedComponent
to the new schema path is consistent with project-wide restructuring. Verify downstream usage to confirm no references to the old import remain.
[approve]
18-18
: Re-check local import usage.
This import is relocated, but the actual functionality appears unchanged. Confirm that CustomLegend
is used as expected without introducing any regression.
apps/web/components/connected/syslumenn/TableLists/JourneymanList/JourneymanList.tsx (1)
21-21
: Validate Journeyman types usage.
Introducing JourneymanLicence
from the updated schema helps maintain consistency across the endpoints. Ensure that all Journeyman
-related references have transitioned to the new import without leftover dependencies from the old schema.
apps/web/components/connected/syslumenn/TableLists/MasterList/MasterList.tsx (1)
21-21
: Confirm full transition to the new schema.
Including MasterLicence
from @island.is/web/graphql/schema
replaces the old API import. Validate that references to MasterLicence
are consistent throughout the logic and CSV exports.
apps/web/screens/Organization/StafraentIsland/ApiCatalogue.tsx (5)
3-7
: Imports for Window Size and Router: Looks Good
These imports for useWindowSize
, useRouter
, useQuery
, and @contentful/rich-text-types
are well-structured and appropriate for their usage in the component.
8-14
: GraphQL consts import
The newly introduced imports from @island.is/api-catalogue/consts
appear consistent with the filter logic in this file.
25-31
: Island UI theme and components
Well-organized imports for theme and specialized components. No issues here.
34-34
: ContentLanguage & QueryGetApiCatalogueArgs updates
Switching to these updated schema imports ensures consistency across the codebase.
Also applies to: 37-37
42-48
: Namespace & layout imports
These newly introduced hooks and layout imports align with project-wide best practices for code organization.
apps/web/components/connected/fiskistofa/calculators/CatchQuotaCalculator/machine.ts (3)
1-1
: Apollo client and XState
The combined import of assign
and createMachine
from xstate
alongside ApolloClient
is fine, ensuring the state machine can interact with the GraphQL client.
4-4
: sortAlpha utility
Using the shared sortAlpha
utility is a straightforward approach to sorting logic. No concerns here.
12-18
: Updated GraphQL schema imports
These schema type imports (e.g., QuotaType
, Ship
) are properly defined and used, enhancing your machine context's type safety.
apps/web/components/OfficialJournalOfIceland/OJOIAdvertCards.tsx (1)
3-3
: Schema import path
Switching OfficialJournalOfIcelandAdvertsResponse
to @island.is/web/graphql/schema
is consistent with the general schema consolidation in this PR.
apps/web/components/TableOfContents/TableOfContents.tsx (1)
4-4
: Slice type path
Importing Slice
from @island.is/web/graphql/schema
fits well with the rest of the codebase refactoring.
apps/web/screens/OfficialJournalOfIceland/hooks/useAdverts.ts (1)
6-6
: Adverts schema import path
Replacing the advert response types to reference @island.is/web/graphql/schema
promotes consistency across the application.
apps/web/screens/Home/Home.tsx (2)
2-13
: Check alignment with Next.js best practices for import structure and maintainability.
These extensive import changes appear consistent, but ensure all exposed modules from @island.is/web/components
and @island.is/web/graphql/schema
remain consistent across the codebase. Confirm that none of the old references from @island.is/api/schema
are still in use in this file or other related modules.
19-22
: Confirm the correctness of new GraphQL type imports.
You switched to @island.is/web/graphql/schema
. Verify any differences in field names or structures. This is especially important for typed queries or fragment usage, ensuring alignment with the updated schema.
apps/web/components/connected/fiskistofa/ShipSearch/ShipSearch.tsx (1)
15-19
: Verify GraphQL schema coherence after import path change.
Since the import path changed from @island.is/api/schema
to @island.is/web/graphql/schema
, confirm that all other references to the old schema have been removed or updated. Also verify that the new schema fields (e.g., FiskistofaShipBasicInfoResponse
) match your query shape to avoid runtime type mismatches.
apps/web/screens/Login/Login.tsx (1)
15-15
: Check SSR usage of client-specific globals.
webLoginButtonSelect
and window?.plausible
rely on client-side resources. If this page renders SSR, ensure you have appropriate guards or fallback logic, as these references may be undefined at build time.
apps/web/screens/Adgerdir/components/FeaturedNews/FeaturedNews.tsx (1)
7-8
: Validate accurate usage of newly imported UI components and GraphQL types.
The addition of Button
, GridColumn
, and Stack
alongside switching from @island.is/api/schema
to @island.is/web/graphql/schema
is fine, but confirm that the News
type fields match the new schema and no required fields were dropped in the transition.
Also applies to: 12-16
apps/web/screens/Adgerdir/Article.tsx (10)
2-2
: Ensure consistent usage of React functionality
Imports from React, including hooks like useEffect
, useRef
, and useState
, look fine. Verify that these hooks are used consistently and that they address any potential memory leak or unmounted component issues, especially if the lifecycle of the rendered DOM portal is dynamic.
6-13
: Adhere to Next.js file structure conventions
These imports from @island.is/island-ui
and @island.is/web/graphql
are appropriate for a Next.js app within apps/web
. They align well with the recommended approach of local component usage and typed GraphQL schema usage.
14-16
: Social sharing strategy
The HeadWithSocialSharing
import is a good approach for setting up social media metadata. Just ensure that all essential meta tags (e.g., og:image
, og:title
) are populated consistently across your site.
17-22
: Use typed query arguments for clarity
Switching to @island.is/web/graphql/schema
for QueryGetAdgerdirPageArgs
, QueryGetAdgerdirPagesArgs
, QueryGetAdgerdirTagsArgs
, and QueryGetNamespaceArgs
is beneficial. Keeping all your type definitions in one central location can reduce confusion. Continue verifying that all references to these query argument types have been updated to prevent type mismatches.
23-25
: Namespace hook usage
useNamespace
is effectively used to manage localized content. Confirm that each string key has a matching fallback in case the API fails to deliver certain fields.
26-29
: Layout consistency
SidebarLayout
and CustomNextError
usage is correct. Ensure each layout component remains consistent with your Next.js routing and static generation patterns (e.g., ensuring getProps
or getStaticProps
usage where relevant).
30-35
: Link resolution logic
Using useLinkResolver
to dynamically generate URL paths is a good pattern. Confirm that slug-based links in the code are tested to avoid 404s from unexpected or malformed slugs.
37-41
: Component segmentation
Components like AdgerdirArticles
, Breadcrumbs
, ColorSchemeContext
, and ProcessEntry
are organized well. Maintaining a clear file structure in apps/web/screens/Adgerdir/
is helpful for discoverability.
Line range hint 46-46
: Exporting typed Screen
components
Leveraging Screen<AdgerdirArticleProps>
ensures you retain strong type safety for your Next.js pages. This is in line with TypeScript best practices for Next.js apps.
Line range hint 78-136
: Error handling in getProps
Throwing a CustomNextError
if getAdgerdirPage
is missing elegantly handles 404 scenarios. This is aligned with standard Next.js error handling. Ensure the backend or headless CMS always returns expected data or a well-defined null object if not found, to avoid unexpected 500s.
apps/web/screens/Adgerdir/Home.tsx (8)
5-15
: Consistent usage of island.is UI components
Using Slice
from @island.is/island-ui/contentful
and layout primitives (e.g., Box
, Stack
) helps maintain a uniform design system. Ensure there are no custom, untested modifications to these components that could affect performance or behavior.
17-22
: Accurate locale usage
Leveraging Locale
from @island.is/shared/types
and useI18n
helps ensure text is displayed correctly. Confirm the fallback flow if activeLocale
is undefined or if content is not available.
26-31
: GraphQL schema changes
References to ContentLanguage
, QueryGetAdgerdirPagesArgs
, QueryGetAdgerdirTagsArgs
, QueryGetGroupedMenuArgs
, and QueryGetNamespaceArgs
from @island.is/web/graphql/schema
keep your data layer coherent. Consistency across the entire web app is crucial, so continue verifying all references are kept in sync.
37-39
: Hook usage check
useNamespace
, useLinkResolver
, and useI18n
are used properly. Validate that each hook’s return value is consumed in a type-safe manner, especially if a particular field might be missing or null.
46-47
: Importing local utilities
Local utility imports (formatMegaMenuCategoryLinks
, formatMegaMenuLinks
) keep your code DRY and organized. Ensure these utilities remain well tested so that changes to the link formatting logic don’t introduce regressions.
48-55
: GraphQL queries structure
The queries for GET_ADGERDIR_FRONTPAGE_QUERY
, GET_ADGERDIR_PAGES_QUERY
, GET_ADGERDIR_TAGS_QUERY
, GET_CATEGORIES_QUERY
, and GET_GROUPED_MENU_QUERY
show that you’re modularizing your GraphQL operations properly. Continue verifying that the relevant resolvers exist and respond with the expected schema on the server side.
58-60
: Breadcrumbs usage
The Breadcrumbs
component is used effectively to show user navigation context. Confirm that the routing definitions or link resolvers handle edge cases, like nested routes or missing data.
Line range hint 136-177
: getProps + Mega Menu data
This approach effectively fetches all required data for the Home
component, including handling multiple parallel GraphQL queries and merging their results. Keep in mind potential performance implications regarding how large these queries can get.
apps/web/components/ServiceWeb/Forms/StandardForm/StandardForm.tsx (3)
Line range hint 33-41
: Migration to @island.is/web/graphql/schema
Switching your types (Organizations
, SupportCategory
, etc.) and introducing GetSupportSearchResultsQuery/Variables
from the new schema is consistent with the rest of the PR. Verify that all references to the old schema have been removed to avoid confusion or mismatched imports.
Line range hint 108-112
: Debouncing side effects
Using useDebounce
for search subject changes is a good approach for performance. Continue ensuring that once the subject is cleared, the suggestions state is also reset to avoid leftover references or memory overhead.
Line range hint 267-281
: Form submission logic
Appending user-entered fields into the message
and sending that to onSubmit
is straightforward. Be mindful of data privacy concerns, ensuring that no sensitive user data is improperly stored or logged, and that the email body is sanitized if needed.
apps/web/components/connected/fiskistofa/calculators/StraddlingStockCalculator/machine.ts (3)
4-5
: Imports for Next.js
These imports look good. They adhere to the recommended approach of modularizing utilities and custom Apollo client initialization for Next.js.
9-9
: Confirm usage of FiskistofaQuotaTypeResponse
Ensure references to this type are consistently updated and no stale imports from @island.is/api/schema
remain.
✅ Verification successful
No stale imports found - type is correctly imported
The verification shows that FiskistofaQuotaTypeResponse
is properly imported from local module paths:
- In resolver:
./models/quotaType
- Defined in:
libs/api/domains/fiskistofa/src/lib/models/quotaType.ts
There are no instances of importing this type from @island.is/api/schema
, and all usages are consistent with the local module imports.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Searching for old imports of FiskistofaQuotaTypeResponse from @island.is/api/schema
rg "FiskistofaQuotaTypeResponse" -A 3 | rg "@island.is/api/schema"
Length of output: 64
Script:
#!/bin/bash
# Let's first find all occurrences of FiskistofaQuotaTypeResponse to understand its usage
rg "FiskistofaQuotaTypeResponse" -B 2 -A 2
Length of output: 4613
12-14
: Migrate all GraphQL imports to the new schema path
The import path for GraphQL types has changed to @island.is/web/graphql/schema
. Verify there are no outdated references to the old schema.
Datadog ReportAll test runs ✅ 10 Total Test Services: 0 Failed, 10 Passed Test ServicesThis report shows up to 10 services
🔻 Code Coverage Decreases vs Default Branch (1)
|
There was a problem hiding this 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
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
apps/web/components/connected/syslumenn/TableLists/JourneymanList/JourneymanList.tsx
(1 hunks)apps/web/components/connected/syslumenn/utils/search.ts
(2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- apps/web/components/connected/syslumenn/TableLists/JourneymanList/JourneymanList.tsx
🧰 Additional context used
📓 Path-based instructions (1)
apps/web/components/connected/syslumenn/utils/search.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."
🔇 Additional comments (1)
apps/web/components/connected/syslumenn/utils/search.ts (1)
22-24
: Remove Generic Constraint with Caution
By removing the Record<string, string | null>
constraint from <T>
, you gain flexibility but also lose built-in guarantees that each key property is a string. This can lead to runtime errors if items in the list contain non-string or missing values. Consider whether you need an additional type guard or runtime check to ensure that item[key]
is safely convertible to a string.
There was a problem hiding this 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 comments (3)
apps/web/screens/Adgerdir/Home.tsx (3)
Line range hint
61-66
: Remove ts-ignore and properly type megaMenuDataThe
megaMenuData
prop uses a ts-ignore comment. Consider properly typing this prop to maintain type safety.interface HomeProps { frontpage: Query['getAdgerdirFrontpage'] pages: Query['getAdgerdirPages'] tags: Query['getAdgerdirTags'] namespace: Query['getNamespace'] megaMenuData: { menus: Array<{ title: string menuLinks: Array<{ // Add appropriate types based on actual data structure }> }> } }
Line range hint
89-91
: Remove unnecessary ts-ignore commentsThere are multiple ts-ignore comments that should be addressed. Consider properly typing the namespace and items to maintain type safety.
const n = useNamespace(namespace as Record<string, string>) const { items: tagsItems } = tags as { items: Array</* appropriate type */> }Also applies to: 96-98
Line range hint
234-308
: Add error handling for GraphQL queriesThe
getProps
method executes multiple GraphQL queries in parallel but lacks error handling. Consider adding try-catch blocks and proper error handling.Home.getProps = async ({ apolloClient, locale }) => { try { const [ frontpageResult, tagsResult, pagesResult, namespace, megaMenuData, categories, ] = await Promise.all([ // ... existing queries ... ]) // ... existing transformation ... return { // ... existing return ... } } catch (error) { console.error('Failed to fetch data:', error) // Handle error appropriately throw error } }
🧹 Nitpick comments (3)
apps/web/screens/Adgerdir/Home.tsx (3)
17-33
: Consider grouping type imports for better maintainabilityThe type imports from
@island.is/web/graphql/schema
could be organized better. Consider grouping all Query-related types together.import { Locale } from '@island.is/shared/types' import { - ContentLanguage, - GetArticleCategoriesQuery, - GetGroupedMenuQuery, Query, QueryGetAdgerdirPagesArgs, QueryGetAdgerdirTagsArgs, QueryGetArticleCategoriesArgs, QueryGetGroupedMenuArgs, QueryGetNamespaceArgs, + ContentLanguage, + GetArticleCategoriesQuery, + GetGroupedMenuQuery, } from '@island.is/web/graphql/schema'
Line range hint
182-227
: Consider extracting slice rendering logicThe slice rendering logic in the map function is complex and could be extracted into a separate component for better maintainability.
interface SliceProps { slice: AdgerdirFeaturedNewsSlice | AdgerdirGroupSlice index: number groupSliceCount: number } const SliceRenderer: React.FC<SliceProps> = ({ slice, index, groupSliceCount }) => { const colorScheme = groupSliceCount % 2 ? 'blue' : 'green' switch (slice.__typename) { case 'AdgerdirFeaturedNewsSlice': return <FeaturedNews key={index} items={slice.featured} /> case 'AdgerdirGroupSlice': return ( <CovidColorSchemeContext.Provider value={{ colorScheme }}> {/* ... existing GroupSlice rendering ... */} </CovidColorSchemeContext.Provider> ) default: return null } }
Line range hint
310-326
: Extract mega menu data transformationThe mega menu data transformation logic could be extracted into a utility function for better reusability and testing.
// utils/megaMenu.ts export const transformMegaMenuData = ( locale: Locale, megaMenuData: any, categories: any, ) => ({ asideTopLinks: formatMegaMenuLinks( locale, megaMenuData?.menus?.[0]?.menuLinks ?? [], ), asideBottomTitle: megaMenuData?.menus?.[1]?.title ?? '', asideBottomLinks: formatMegaMenuLinks( locale, megaMenuData?.menus?.[1]?.menuLinks ?? [], ), mainLinks: formatMegaMenuCategoryLinks(locale, categories), })
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
apps/web/components/ServiceWeb/Forms/StandardForm/StandardForm.tsx
(1 hunks)apps/web/screens/Adgerdir/Home.tsx
(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- apps/web/components/ServiceWeb/Forms/StandardForm/StandardForm.tsx
🧰 Additional context used
📓 Path-based instructions (1)
apps/web/screens/Adgerdir/Home.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."
Stop importing GraphQL types from api/schema
What
@island.is/web/graphql/schema
Why
Checklist:
Summary by CodeRabbit
New Features
Bug Fixes
Refactor
Documentation