-
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
fix(web): Add locale to organization page fetch #17015
Conversation
WalkthroughThe changes in this pull request involve modifying the Changes
Possibly related PRs
Suggested reviewers
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
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #17015 +/- ##
=======================================
Coverage 35.59% 35.59%
=======================================
Files 6924 6924
Lines 146382 146382
Branches 41560 41563 +3
=======================================
+ Hits 52100 52104 +4
+ Misses 94282 94278 -4 Flags with carried forward coverage won't be shown. Click here to find out more.
... and 1 file with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
Datadog ReportAll test runs ✅ 21 Total Test Services: 0 Failed, 20 Passed Test ServicesThis report shows up to 10 services
|
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 and nitpick comments (2)
apps/web/pages/s/[...slugs]/index.tsx (2)
Line range hint
182-263
: Consider refactoring locale-based route handling.The current implementation has repeated locale checks and hardcoded route names. This could be improved for better maintainability.
Consider extracting the route mappings to constants and simplifying the logic:
+const ROUTE_MAPPINGS = { + is: { + news: 'frett', + events: 'vidburdir', + publishedMaterial: 'utgefid-efni' + }, + en: { + news: 'news', + events: 'events', + publishedMaterial: 'published-material' + } +}; + +const getLocalizedRoute = (route: keyof typeof ROUTE_MAPPINGS.en, locale: string) => + ROUTE_MAPPINGS[locale === 'is' ? 'is' : 'en'][route]; + if (slugs.length === 2) { - if (locale !== 'is') { - if (slugs[1] === 'news') { - return { - page: { - type: PageType.ALL_NEWS, - props: await OrganizationNewsList.getProps(context), - }, - } - } - // ... more conditions - } else { - if (slugs[1] === 'frett') { + const currentRoute = slugs[1]; + if (currentRoute === getLocalizedRoute('news', locale)) { return { page: { type: PageType.ALL_NEWS, props: await OrganizationNewsList.getProps(context), }, } - } - // ... more conditions } + // Similar refactoring for other routes
Line range hint
284-285
: Remove ts-ignore by fixing the type definition.The ts-ignore comment suggests an underlying type issue with the
withLocale
HOC that should be addressed properly.Consider:
- Adding proper type definitions for the
withLocale
HOC- Or creating a proper type assertion that explains why the type check can be safely ignored
If you need help with the type definitions, I can assist in creating them.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (1)
apps/web/pages/s/[...slugs]/index.tsx
(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
apps/web/pages/s/[...slugs]/index.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 (1)
apps/web/pages/s/[...slugs]/index.tsx (1)
147-147
: LGTM: Locale parameter addition looks correct.
The addition of the lang
parameter to the GraphQL query variables is consistent with the PR objective and properly uses the context locale with a fallback to 'is'.
Let's verify that the GraphQL schema supports this parameter:
✅ Verification successful
The lang
parameter is correctly supported in the GraphQL schema
Based on the search results, the lang
parameter is properly supported in the GraphQL schema and consistently used across the codebase:
- The input type is defined in
libs/cms/src/lib/dto/getOrganizationPage.input.ts
withlang
as a required string field - The query is defined in
apps/web/screens/queries/Organization.tsx
and accepts this input - Multiple components across the codebase use this parameter consistently with the same pattern
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Verify that the GraphQL schema supports the lang parameter
ast-grep --pattern 'type QueryGetOrganizationPageArgs {
input: {
$$$
lang: $_
$$$
}
}'
Length of output: 104
Script:
#!/bin/bash
# Let's try a different approach to find the GraphQL schema definition
# First, let's locate potential GraphQL schema files
fd "\.(graphql|gql)$"
# Then, let's search for the GetOrganizationPage query definition
rg "GetOrganizationPage.*input.*lang" -A 5
Length of output: 19998
Script:
#!/bin/bash
# Let's try to find the GraphQL query definition in TypeScript files
rg "GetOrganizationPage.*\{" -A 10 --type ts
# Also search for the query type definition
rg "type.*GetOrganizationPage" -A 10 --type ts
Length of output: 22401
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
Add locale to organization page fetch
Summary by CodeRabbit
New Features
Bug Fixes