Skip to content

Refactor: consolidate constants and remove duplicate Header barrel#374

Merged
dmnktoe merged 8 commits into
mainfrom
cursor/refactor-structure-19c6
May 1, 2026
Merged

Refactor: consolidate constants and remove duplicate Header barrel#374
dmnktoe merged 8 commits into
mainfrom
cursor/refactor-structure-19c6

Conversation

@dmnktoe

@dmnktoe dmnktoe commented May 1, 2026

Copy link
Copy Markdown
Owner

Description & Technical Solution

This refactor improves the project’s “first view” structure by consolidating duplicate constant folders and removing confusing duplicate component entrypoints. It also moves root-level Jest mocks under src and remaps Jest accordingly. Finally, it standardizes layout exports, flattens the Header component structure, and fixes CI lint/test issues introduced by the refactor.

  • Consolidated src/constant/* into src/constants/* and updated all imports/tests accordingly.
  • Moved __mocks__/next-intl.jssrc/__mocks__/next-intl.js and updated jest.config.js moduleNameMapper.
  • Standardized layout module API to support consistent named imports (import { Header, Footer, Layout, Page, Container } from '@/components/layout').
  • Flattened the Header implementation files from src/components/layout/header/* into src/components/layout/* and removed the now-empty folder.

CI/Jest follow-up fixes

  • Converted src/__mocks__/next-intl.js to ESM exports (avoids require() lint rule).
  • Added a getMessages() export to the mock so import { getMessages } from 'next-intl/server' (used by src/app/[locale]/layout.tsx) is present and callable under Jest’s moduleNameMapper.
  • Sorted imports/exports flagged by simple-import-sort.
  • Updated Jest transformIgnorePatterns to include cobe so ESM-only cobe code is transformed in tests.

Checklist

  • I have commented my code, particularly in hard-to-understand areas.
  • Already rebased against main branch.

Screenshots

N/A (refactor only).

Open in Web Open in Cursor 

Summary by CodeRabbit

Release Notes

  • New Features

    • Enhanced header with improved internationalization support and optimized mobile navigation controls.
  • Refactor

    • Standardized import paths across the codebase.
    • Reorganized module structure for improved maintainability.
  • Tests

    • Updated Jest configuration for better mock file handling.

Co-authored-by: Domenik Töfflinger <dmnktoe@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented May 1, 2026

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@dmnktoe has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 54 minutes and 47 seconds before requesting another review.

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: cc1d64a0-1258-4119-a767-753c04e237ea

📥 Commits

Reviewing files that changed from the base of the PR and between 3e04c44 and da1832d.

📒 Files selected for processing (1)
  • src/__mocks__/next-intl.js
📝 Walkthrough

Walkthrough

This PR migrates import paths from @/constant to @/constants, refactors layout/Page exports to named exports, removes the old header implementation and replaces it with a new in-file Header, and updates Jest config and the next-intl mock to ES module named exports and transform rules.

Changes

Cohort / File(s) Summary
Jest config & mocks
jest.config.js, src/__mocks__/next-intl.js
Resolve next-intl to src/__mocks__/next-intl.js; add cobe to transform whitelist; convert mock from CommonJS to ES named exports.
Environment constants & related imports
src/app/layout.tsx, src/app/[locale]/layout.tsx, src/app/api/.../route.ts, src/components/helpers/ConsentProvider.tsx, src/components/.../Footer.tsx, src/components/.../InfoBar.tsx, src/components/templates/*, src/constants/__tests__/*, src/lib/**
Updated import specifiers from @/constant/* to @/constants/* across env, company and responsive-image modules and tests.
Page/Layout import/export refactor
src/components/layout/Page.tsx, src/components/layout/Layout.tsx, src/components/layout/index.ts, src/app/[locale]/*/page.tsx, src/components/templates/*LeistungenView.tsx
Convert Page and Layout usages to named imports/exports (Page, Layout, exported PageProps); update barrel to export Page and types.
Header restructuring
src/components/layout/Header.tsx, src/components/layout/header/Header.tsx, src/components/layout/Layout.tsx, src/components/layout/DesktopNav.tsx, src/components/layout/MobileNavDrawer.tsx, src/components/layout/ServicesDropdownMenu.tsx, src/components/layout/header.types, src/components/__tests__/Header.test.tsx
Removed old header/Header.tsx; added new in-file Header.tsx implementation with client rendering, useTranslations-driven navigation, DesktopNav/MobileNavDrawer wiring, language picker and mobile menu state; updated type imports and test import paths.
Type import reorganization
src/components/layout/DesktopNav.tsx, src/components/layout/MobileNavDrawer.tsx, src/components/layout/ServicesDropdownMenu.tsx, src/components/layout/index.ts
Switch type imports from ./types to ./header.types; expose NavItemProps/SubItem from barrel as type-only exports.
Small import adjustments in pages/tests
src/app/[locale]/*/page.tsx, src/components/__tests__/*, other small files listed in diff
Updated many files to use the new named exports or adjusted module paths; no functional logic changes in these files.

Sequence Diagram

sequenceDiagram
    participant User
    participant Header as Header Component
    participant i18n as useTranslations
    participant Nav as Navigation
    participant Menu as MobileNavDrawer
    participant LP as LanguagePicker

    User->>Header: load page
    Header->>i18n: request 'common' translations
    i18n-->>Header: navigation items, labels
    Header->>Nav: render desktop or mobile nav with items

    alt Desktop
        Header->>Nav: render DesktopNav
    else Mobile
        User->>Header: tap mobile menu button
        Header->>Menu: open MobileNavDrawer
        User->>Menu: select item
        Menu-->>Header: onNavigate -> close menu
    end

    User->>Header: open language picker
    Header->>LP: open
    LP-->>Header: language selected
    Header->>i18n: refresh translations
    i18n-->>Header: updated navigation items
    Header->>Nav: re-render
Loading

Estimated Code Review Effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly Related PRs

Poem

🐰 I hopped through constants, plural and neat,
Rewired the header, gave nav new feet,
Mocks now speak ES with named exports bright,
Translations guide nav through day and night,
A carrot of refactor — tidy, light! 🥕

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main refactoring effort—consolidating constants and removing a duplicate Header barrel—which aligns with the primary changes shown in the changeset.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed PR description covers all major refactoring changes with clear structure and objectives, though the checklist items remain unchecked.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cursor/refactor-structure-19c6

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.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 54 minutes and 47 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

cursoragent and others added 4 commits May 1, 2026 14:52
Co-authored-by: Domenik Töfflinger <dmnktoe@users.noreply.github.com>
Co-authored-by: Domenik Töfflinger <dmnktoe@users.noreply.github.com>
Co-authored-by: Domenik Töfflinger <dmnktoe@users.noreply.github.com>
Co-authored-by: Domenik Töfflinger <dmnktoe@users.noreply.github.com>
@dmnktoe dmnktoe marked this pull request as ready for review May 1, 2026 15:05
@sentry

sentry Bot commented May 1, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.28571% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.45%. Comparing base (12b37c5) to head (da1832d).
⚠️ Report is 9 commits behind head on main.

Files with missing lines Patch % Lines
src/components/layout/Layout.tsx 75.00% 1 Missing ⚠️
src/components/layout/Page.tsx 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #374      +/-   ##
==========================================
- Coverage   77.49%   76.45%   -1.04%     
==========================================
  Files          83       86       +3     
  Lines        1142     1185      +43     
  Branches      305      322      +17     
==========================================
+ Hits          885      906      +21     
- Misses        257      279      +22     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/components/layout/DesktopNav.tsx (1)

3-10: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Resolve import-sort lint warning before merge.

CI reports simple-import-sort/imports in this file; please run autofix or reorder imports to match the configured grouping.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/components/layout/DesktopNav.tsx` around lines 3 - 10, Reorder the
imports in DesktopNav.tsx to satisfy simple-import-sort by grouping and ordering
them (builtin/module-level, external packages, React hooks, project absolute
imports, then relative local imports): ensure imports for 'clsx' and
'next/navigation' come together as external packages, 'react' is imported as
usual, followed by '@/components/ui' (UnderlineLink) and then local relative
imports './ServicesDropdownMenu' and './header.types' (NavItemProps); either run
your autofix (eslint --fix) or manually reorder these import lines so they match
the configured import groups.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@jest.config.js`:
- Around line 15-16: The jest mapping sends all next-intl/* imports to the same
mock which lacks the server export getMessages used by
src/app/[locale]/layout.tsx; update the mock or split the mapper: either add a
getMessages export (matching signature used in layout.tsx) to
src/__mocks__/next-intl.js (so imports from 'next-intl/server' work) or change
moduleNameMapper entries so '^next-intl$' maps to the existing mock and a more
specific pattern (e.g. '^next-intl/server$' or other subpaths) maps to a
different mock that implements getMessages; ensure getMessages symbol is present
and callable where layout.tsx imports it.

In `@src/__mocks__/next-intl.js`:
- Line 65: Sort the named exports in the export list to satisfy
simple-import-sort/exports: change the order of the symbols in the export
statement so they are alphabetically ordered (getTranslations,
NextIntlClientProvider, useLocale, useTranslations) — update the export
statement that currently references NextIntlClientProvider, getTranslations,
useLocale, useTranslations to the normalized alphabetical order.

In `@src/components/layout/Header.tsx`:
- Around line 3-17: Run the import sorter to fix import ordering in Header.tsx:
reorder the import block so external packages (react, next-intl,
react-icons/vsc) come first, then absolute app imports grouped by path (e.g.,
'@/components/ui' and its subpaths like ButtonLink, UnderlineLink,
MobileMenuButton, Icons/Logo), then layout components (Container, DesktopNav,
MobileNavDrawer, MOBILE_NAV_PANEL_ID), hooks/utilities (useMobileMenu), types
(header.types), and finally default or local component imports (LanguagePicker);
ensure the named symbols to look for are useTranslations, React,
VscCallOutgoing, Container, LanguagePicker, ButtonLink, UnderlineLink,
MobileMenuButton, Logo, useMobileMenu, DesktopNav, MobileNavDrawer,
MOBILE_NAV_PANEL_ID, and NavItemProps so the sorter and linter pass.

In `@src/components/layout/index.ts`:
- Around line 1-8: The barrel exports are not sorted, causing a
simple-import-sort/exports lint warning; reorder the export statements (e.g.,
alphabetically by exported identifier: Container, Footer, Header, InfoBar,
Layout, Page, and the type export NavItemProps/SubItem) so the lines export *
from './Container'; export * from './Footer'; export * from './Header'; export *
from './InfoBar'; export type { NavItemProps, SubItem } from './header.types';
export { Layout } from './Layout'; export { Page } from './Page'; or run ESLint
autofix to apply the correct ordering.

---

Outside diff comments:
In `@src/components/layout/DesktopNav.tsx`:
- Around line 3-10: Reorder the imports in DesktopNav.tsx to satisfy
simple-import-sort by grouping and ordering them (builtin/module-level, external
packages, React hooks, project absolute imports, then relative local imports):
ensure imports for 'clsx' and 'next/navigation' come together as external
packages, 'react' is imported as usual, followed by '@/components/ui'
(UnderlineLink) and then local relative imports './ServicesDropdownMenu' and
'./header.types' (NavItemProps); either run your autofix (eslint --fix) or
manually reorder these import lines so they match the configured import groups.
🪄 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: 5b51e601-45c7-4ac1-9f1b-cc30afc79a57

📥 Commits

Reviewing files that changed from the base of the PR and between 12b37c5 and ac7308a.

📒 Files selected for processing (50)
  • jest.config.js
  • src/__mocks__/next-intl.js
  • src/app/[locale]/agb/page.tsx
  • src/app/[locale]/cookie-richtlinie/page.tsx
  • src/app/[locale]/datenschutz/page.tsx
  • src/app/[locale]/downloads/page.tsx
  • src/app/[locale]/impressum/page.tsx
  • src/app/[locale]/kontakt/page.tsx
  • src/app/[locale]/layout.tsx
  • src/app/[locale]/leistungen/page.tsx
  • src/app/[locale]/leistungen/vertrieb/page.tsx
  • src/app/[locale]/newsroom/[slug]/page.tsx
  • src/app/[locale]/newsroom/page.tsx
  • src/app/[locale]/not-found.tsx
  • src/app/[locale]/page.tsx
  • src/app/[locale]/unternehmen/page.tsx
  • src/app/api/cms/assets/[...slug]/route.ts
  • src/app/api/draft/route.ts
  • src/app/layout.tsx
  • src/components/__tests__/Header.test.tsx
  • src/components/helpers/ConsentProvider.tsx
  • src/components/layout/DesktopNav.tsx
  • src/components/layout/Footer.tsx
  • src/components/layout/Header.tsx
  • src/components/layout/InfoBar.tsx
  • src/components/layout/Layout.tsx
  • src/components/layout/MobileNavDrawer.tsx
  • src/components/layout/Page.tsx
  • src/components/layout/ServicesDropdownMenu.tsx
  • src/components/layout/header.types.ts
  • src/components/layout/header/Header.tsx
  • src/components/layout/index.ts
  • src/components/templates/ContactInfo.tsx
  • src/components/templates/DistributionProducts.tsx
  • src/components/templates/ImageBanner/ImageBanner.tsx
  • src/components/templates/LegalNoticeText.tsx
  • src/components/templates/PrivacyContent.tsx
  • src/components/templates/ProduktionLeistungenView.tsx
  • src/components/templates/ReparaturLeistungenView.tsx
  • src/constants/__tests__/responsive-image-sizes.test.ts
  • src/constants/company.ts
  • src/constants/env.ts
  • src/constants/responsive-image-sizes.ts
  • src/lib/__tests__/directus-urls.test.ts
  • src/lib/__tests__/logger.test.ts
  • src/lib/directus-logging.ts
  • src/lib/directus-urls.ts
  • src/lib/directus-visual-editor.ts
  • src/lib/directus.ts
  • src/lib/logger.ts
💤 Files with no reviewable changes (1)
  • src/components/layout/header/Header.tsx

Comment thread jest.config.js
Comment thread src/__mocks__/next-intl.js Outdated
Comment on lines +3 to +17
import { useTranslations } from 'next-intl';
import * as React from 'react';
import { VscCallOutgoing } from 'react-icons/vsc';

import { Container } from '@/components/layout/Container';
import LanguagePicker from '@/components/templates/LanguagePicker';
import { ButtonLink, UnderlineLink } from '@/components/ui';
import { MobileMenuButton } from '@/components/ui/Buttons/MobileMenuButton';
import { Logo } from '@/components/ui/Icons';

import { useMobileMenu } from '@/utils/useMobileMenu';

import { DesktopNav } from './DesktopNav';
import { MOBILE_NAV_PANEL_ID, MobileNavDrawer } from './MobileNavDrawer';
import type { NavItemProps } from './header.types';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Run the import sorter on this file.

This import block still fails simple-import-sort/imports, so the refactor leaves a CI warning behind.

🧰 Tools
🪛 GitHub Actions: CI

[warning] 3-3: ESLint (simple-import-sort/imports): warning at 3:1 — Run autofix to sort these imports!

🪛 GitHub Check: ⬣ ESLint

[warning] 3-3:
Run autofix to sort these imports!

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/components/layout/Header.tsx` around lines 3 - 17, Run the import sorter
to fix import ordering in Header.tsx: reorder the import block so external
packages (react, next-intl, react-icons/vsc) come first, then absolute app
imports grouped by path (e.g., '@/components/ui' and its subpaths like
ButtonLink, UnderlineLink, MobileMenuButton, Icons/Logo), then layout components
(Container, DesktopNav, MobileNavDrawer, MOBILE_NAV_PANEL_ID), hooks/utilities
(useMobileMenu), types (header.types), and finally default or local component
imports (LanguagePicker); ensure the named symbols to look for are
useTranslations, React, VscCallOutgoing, Container, LanguagePicker, ButtonLink,
UnderlineLink, MobileMenuButton, Logo, useMobileMenu, DesktopNav,
MobileNavDrawer, MOBILE_NAV_PANEL_ID, and NavItemProps so the sorter and linter
pass.

Comment on lines 1 to +8
export * from './Container';
export * from './Footer';
export type { NavItemProps, SubItem } from './header.types';
export * from './Header';
export * from './InfoBar';
export * from './Layout';

export { Layout } from './Layout';
export { Page } from './Page';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Resolve export-sort lint warning before merge.

Line 1 triggers simple-import-sort/exports in CI; please reorder exports (or run ESLint autofix) so the barrel stays lint-clean.

🧰 Tools
🪛 GitHub Actions: CI

[warning] 1-1: ESLint (simple-import-sort/exports): warning at 1:1 — Run autofix to sort these exports!

🪛 GitHub Check: ⬣ ESLint

[warning] 1-1:
Run autofix to sort these exports!

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/components/layout/index.ts` around lines 1 - 8, The barrel exports are
not sorted, causing a simple-import-sort/exports lint warning; reorder the
export statements (e.g., alphabetically by exported identifier: Container,
Footer, Header, InfoBar, Layout, Page, and the type export NavItemProps/SubItem)
so the lines export * from './Container'; export * from './Footer'; export *
from './Header'; export * from './InfoBar'; export type { NavItemProps, SubItem
} from './header.types'; export { Layout } from './Layout'; export { Page } from
'./Page'; or run ESLint autofix to apply the correct ordering.

cursoragent and others added 2 commits May 1, 2026 15:14
Co-authored-by: Domenik Töfflinger <dmnktoe@users.noreply.github.com>
@dmnktoe dmnktoe merged commit 8ab8082 into main May 1, 2026
8 checks passed
@dmnktoe dmnktoe deleted the cursor/refactor-structure-19c6 branch May 7, 2026 11:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants