Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthrough
Accordion API and rendering enhancements
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
🧹 Nitpick comments (1)
src/app/(app)/[lang]/kepviselok/components/RepresentativeCard.tsx (1)
23-23: ⚡ Quick winUse dictionary-backed label for both languages.
Line 23 hardcodes HU text while EN uses translation lookup, which can cause copy drift. Prefer one dictionary key path for both locales.
Proposed refactor
- const detailsLabel = lang === "EN" ? t('representatives.view_details') : "Részletek" + const detailsLabel = t('representatives.view_details')🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/app/`(app)/[lang]/kepviselok/components/RepresentativeCard.tsx at line 23, The detailsLabel variable in RepresentativeCard.tsx uses inconsistent translation logic - it calls t('representatives.view_details') for English but hardcodes the Hungarian text "Részletas" directly. This creates copy drift and maintenance issues. Replace the entire conditional with a single translation lookup using t('representatives.view_details') for both languages, allowing the translation system to handle language selection automatically instead of hardcoding language-specific strings.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/app/`(app)/[lang]/engedelyek/components/PermissionsListClient.tsx:
- Around line 16-21: The `hasRichText` function currently only checks if the
root node has children in the array, but does not verify if those children
contain actual text content. A Lexical editor can have empty structural elements
that pass this check but display no meaningful content. Modify the `hasRichText`
function to recursively inspect the children nodes and check for the presence of
actual text content in the nested structure, ensuring that at least one text
node exists before returning true. This will prevent rendering the section
header when the richtext is structurally present but functionally empty. Note
that this same pattern may also appear in the code around lines 78-86.
In `@src/app/`(app)/[lang]/hirek/[slug]/components/RelatedNewsClient.tsx:
- Around line 61-63: The Link component in RelatedNewsClient.tsx is using a href
that points to `/hirek/${article.id}` without including the language segment,
which breaks routing since the page is located under the `[lang]` route
structure. Update the href attribute to include the language parameter by
constructing the path as `/${lang}/hirek/${article.id}` instead, ensuring you
capture the lang parameter (likely from useParams or route context) and include
it in the generated link path.
In `@src/app/`(app)/[lang]/kepviselok/components/representatives.helpers.ts:
- Around line 82-99: The formatFileSize function does not handle negative file
size values. When negative bytes are passed, Math.log of a negative number
returns NaN, causing the function to output "NaN undefined". Add a guard
condition in the formatFileSize function after the existing null and zero checks
to validate that bytes is not negative (bytes < 0), and return null in that case
before reaching the Math.log calculation to ensure malformed metadata does not
destabilize the UI.
In `@src/collections/Permissions.ts`:
- Around line 100-108: The externalLink field in the Permissions collection
currently accepts any free text without validation. Add a collection-level
validate function or field-level validation to the externalLink field that
checks the input is an absolute URL using only safe schemes (http or https).
This can be done by implementing a validation function that tests the URL format
using URL parsing or regex patterns, rejecting any malformed URLs or unsafe
schemes, and returning a validation error message if the URL doesn't match the
required pattern.
---
Nitpick comments:
In `@src/app/`(app)/[lang]/kepviselok/components/RepresentativeCard.tsx:
- Line 23: The detailsLabel variable in RepresentativeCard.tsx uses inconsistent
translation logic - it calls t('representatives.view_details') for English but
hardcodes the Hungarian text "Részletas" directly. This creates copy drift and
maintenance issues. Replace the entire conditional with a single translation
lookup using t('representatives.view_details') for both languages, allowing the
translation system to handle language selection automatically instead of
hardcoding language-specific strings.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: cac05654-1c5b-464f-bab6-ac8b44364ce1
📒 Files selected for processing (58)
src/app/(app)/[lang]/emlekeztetok/components/YearSection.tsxsrc/app/(app)/[lang]/engedelyek/components/PermissionsListClient.tsxsrc/app/(app)/[lang]/engedelyek/page.tsxsrc/app/(app)/[lang]/hatarozatok-tara/components/DecisionsArchiveClient.tsxsrc/app/(app)/[lang]/hirek/[slug]/components/BackNav.tsxsrc/app/(app)/[lang]/hirek/[slug]/components/FileIcon.tsxsrc/app/(app)/[lang]/hirek/[slug]/components/NewsDetail.tsxsrc/app/(app)/[lang]/hirek/[slug]/components/NewsDetailClient.tssrc/app/(app)/[lang]/hirek/[slug]/components/NewsDetailMain.tsxsrc/app/(app)/[lang]/hirek/[slug]/components/NewsDetailSidebar.tsxsrc/app/(app)/[lang]/hirek/[slug]/components/RelatedNewsClient.tsxsrc/app/(app)/[lang]/hirek/[slug]/components/ShareButton.tsxsrc/app/(app)/[lang]/hirek/[slug]/lib/news-utils.tssrc/app/(app)/[lang]/kepviselok/components/RepresentativeCard.tsxsrc/app/(app)/[lang]/kepviselok/components/RepresentativeModal.tsxsrc/app/(app)/[lang]/kepviselok/components/RepresentativesGrid.tsxsrc/app/(app)/[lang]/kepviselok/components/RepresentativesGridClient.tsxsrc/app/(app)/[lang]/kepviselok/components/representatives.helpers.tssrc/app/(app)/[lang]/kepviselok/components/skeletons/LoadingRepresentativeCard.tsxsrc/app/(app)/[lang]/kepviselok/components/skeletons/LoadingRepresentativesGrid.tsxsrc/app/(app)/[lang]/kepviselok/page.tsxsrc/app/(app)/[lang]/kisokosok/components/HelpPageList.tsxsrc/app/(app)/[lang]/kisokosok/components/skeletons/LoadingHelpPageGrid.tsxsrc/app/(app)/[lang]/kisokosok/page.tsxsrc/app/(app)/[lang]/nyelvoktatas/components/LanguageEducationContent.tsxsrc/app/(app)/[lang]/nyelvoktatas/page.tsxsrc/app/(app)/[lang]/oktatasi-szabalyzatok/loading.tsxsrc/app/(app)/[lang]/oktatasi-szabalyzatok/page.tsxsrc/app/(app)/[lang]/tanulmanyi-osztondij/components/StudyScholarshipContent.tsxsrc/app/(app)/[lang]/tanulmanyi-osztondij/page.tsxsrc/app/(app)/globals.csssrc/collections/News.tssrc/collections/Permissions.tssrc/components/common/Accordion.tsxsrc/components/common/FileCard.tsxsrc/components/regulations/RegulationsListClient.tsxsrc/components/regulations/skeletons/LoadingRegulationsGrid.tsxsrc/dictionaries/en/language_education.jsonsrc/dictionaries/en/news.jsonsrc/dictionaries/en/permissions.jsonsrc/dictionaries/en/regulations.jsonsrc/dictionaries/en/scholarships.jsonsrc/dictionaries/hu/language_education.jsonsrc/dictionaries/hu/news.jsonsrc/dictionaries/hu/permissions.jsonsrc/dictionaries/hu/regulations.jsonsrc/dictionaries/hu/scholarships.jsonsrc/globals/AcademicScholarshipFAQ.tssrc/lib/payload-cms.tssrc/migrations/20260619_105937_add_news_representative_and_contact_email.jsonsrc/migrations/20260619_105937_add_news_representative_and_contact_email.tssrc/migrations/20260619_141957_add_permissions_submission_and_external_link.jsonsrc/migrations/20260619_141957_add_permissions_submission_and_external_link.tssrc/migrations/20260619_173736_academic_scholarship_faq.jsonsrc/migrations/20260619_173736_academic_scholarship_faq.tssrc/migrations/index.tssrc/payload-types.tssrc/payload.config.ts
💤 Files with no reviewable changes (5)
- src/app/(app)/[lang]/hirek/[slug]/components/ShareButton.tsx
- src/app/(app)/[lang]/hirek/[slug]/components/FileIcon.tsx
- src/app/(app)/[lang]/hirek/[slug]/components/BackNav.tsx
- src/app/(app)/[lang]/hirek/[slug]/components/NewsDetailClient.ts
- src/app/(app)/[lang]/hirek/[slug]/lib/news-utils.ts
| // Lexical richtext can be "empty" (a root with no real content). Only render when there is something. | ||
| type LexicalData = Permission["submissionProcess_hu"]; | ||
| const hasRichText = (data: LexicalData): data is NonNullable<LexicalData> => { | ||
| const children = data?.root?.children; | ||
| return Array.isArray(children) && children.length > 0; | ||
| }; |
There was a problem hiding this comment.
hasRichText can return true for structurally-empty Lexical content.
The current guard checks only top-level child count, which can still be non-empty for blank editor state. This may show the section header with no real text. Check nested text content before rendering.
Suggested guard update
type LexicalData = Permission["submissionProcess_hu"];
const hasRichText = (data: LexicalData): data is NonNullable<LexicalData> => {
- const children = data?.root?.children;
- return Array.isArray(children) && children.length > 0;
+ const children = data?.root?.children;
+ if (!Array.isArray(children) || children.length === 0) return false;
+
+ const hasText = (nodes: unknown[]): boolean =>
+ nodes.some((node: any) => {
+ if (typeof node?.text === "string" && node.text.trim().length > 0) return true;
+ if (Array.isArray(node?.children)) return hasText(node.children);
+ return false;
+ });
+
+ return hasText(children as unknown[]);
};Also applies to: 78-86
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/app/`(app)/[lang]/engedelyek/components/PermissionsListClient.tsx around
lines 16 - 21, The `hasRichText` function currently only checks if the root node
has children in the array, but does not verify if those children contain actual
text content. A Lexical editor can have empty structural elements that pass this
check but display no meaningful content. Modify the `hasRichText` function to
recursively inspect the children nodes and check for the presence of actual text
content in the nested structure, ensuring that at least one text node exists
before returning true. This will prevent rendering the section header when the
richtext is structurally present but functionally empty. Note that this same
pattern may also appear in the code around lines 78-86.
| <Link | ||
| href={`/hirek/${article.id}`} | ||
| className="inline-flex items-center justify-between gap-4 text-xs font-bold text-[#862633]" |
There was a problem hiding this comment.
Preserve the [lang] segment in related-news links.
Line 62 links to /hirek/${article.id}, but this page is under /[lang]/hirek/[slug]. Dropping the locale segment can route users to a non-existent path.
Proposed fix
import { ArrowRight } from "lucide-react"
import Link from "next/link"
+import { useParams } from "next/navigation"
export function RelatedNewsClient({ relatedArticles }: { relatedArticles: News[] }) {
const { t, lang } = useTranslate()
+ const { lang: langParam } = useParams<{ lang: string }>()
@@
<Link
- href={`/hirek/${article.id}`}
+ href={`/${langParam}/hirek/${article.id}`}
className="inline-flex items-center justify-between gap-4 text-xs font-bold text-[`#862633`]"
>🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/app/`(app)/[lang]/hirek/[slug]/components/RelatedNewsClient.tsx around
lines 61 - 63, The Link component in RelatedNewsClient.tsx is using a href that
points to `/hirek/${article.id}` without including the language segment, which
breaks routing since the page is located under the `[lang]` route structure.
Update the href attribute to include the language parameter by constructing the
path as `/${lang}/hirek/${article.id}` instead, ensuring you capture the lang
parameter (likely from useParams or route context) and include it in the
generated link path.
Summary by CodeRabbit