Skip to content

ref: header separating shop and main header and removing footer#59

Merged
ViktorSvertoka merged 1 commit into
developfrom
lso/feat/shop
Dec 18, 2025
Merged

ref: header separating shop and main header and removing footer#59
ViktorSvertoka merged 1 commit into
developfrom
lso/feat/shop

Conversation

@liudmylasovetovs
Copy link
Copy Markdown
Collaborator

@liudmylasovetovs liudmylasovetovs commented Dec 18, 2025

Description

This PR implements route-aware header switching for the shop section without restructuring the main platform routes.

The solution introduces a server-side scope detection via middleware and conditionally renders the appropriate header in the locale layout:

  • Shop pages (/[locale]/shop/**) render the dedicated Shop header with product categories and shop navigation.
  • All other pages render the default platform header.
  • The shop-specific footer has been fully removed; the global platform footer is now consistently used across the entire application, including the shop.

This approach avoids moving or refactoring non-shop routes owned by other team members and follows production-safe Next.js App Router patterns.


Related Issue

Issue: #<issue_number>


Changes

  • Added route scope detection (shop | site) in middleware.ts based on pathname.
  • Propagated scope via request headers (x-app-scope) for server components.
  • Updated app/[locale]/layout.tsx to conditionally render ShopHeader or DefaultHeader on the server.
  • Removed all parallel route (@header) slot files after deprecating that approach.
  • Removed shop footer and unified footer rendering through the global platform footer.
  • Kept app/[locale]/shop/layout.tsx focused only on shop-specific providers (theme, cart).

Database Changes (if applicable)

  • Schema migration required
  • Seed data updated
  • Breaking changes to existing queries
  • Transaction-safe migration
  • Migration tested locally on Neon

How Has This Been Tested?

  • Tested locally
  • Verified in development environment
  • Checked responsive layout (header differences between platform and shop)
  • Tested accessibility (keyboard / screen reader)

Manual verification:

  • /en, /pl, /uk → platform header
  • /en/shop, /pl/shop, /uk/shop → shop header with categories
  • Global footer present on all pages
  • No duplicated headers or footers

Screenshots (if applicable)


Checklist

Before submitting

  • Code has been self-reviewed
  • No TypeScript or console errors
  • Code follows project conventions
  • Scope is limited to this feature/fix
  • No unrelated refactors included
  • English used in code, commits, and docs
  • New dependencies discussed with team
  • Database migration tested locally (if applicable)
  • GitHub Projects card moved to In Review

Reviewers

Summary by CodeRabbit

  • New Features

    • Introduced scope-based header rendering for the shop section with a dedicated header component.
    • Added conditional admin navigation visibility controlled by a feature flag.
  • Refactor

    • Reorganized shop layout structure, removing redundant header and footer wrappers.
    • Simplified navigation routing with updated Shop link destination.
    • Reordered middleware request processing to prioritize authentication checks.

✏️ Tip: You can customize this high-level summary in your review settings.

@netlify
Copy link
Copy Markdown

netlify Bot commented Dec 18, 2025

Deploy Preview for develop-devlovers ready!

Name Link
🔨 Latest commit 6d5e956
🔍 Latest deploy log https://app.netlify.com/projects/develop-devlovers/deploys/694458f401afcd00087299c9
😎 Deploy Preview https://deploy-preview-59--develop-devlovers.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Dec 18, 2025

Walkthrough

The PR introduces scope-based header rendering by adding middleware logic to determine application scope ("shop" or "site") from the request pathname, setting an x-app-scope header, and using this header in the root layout to conditionally render ShopHeader or the default header. The shop layout is simplified to remove redundant header and footer components.

Changes

Cohort / File(s) Summary
Middleware scope routing
frontend/middleware.ts
Introduces getScopeFromPathname helper to derive "shop" or "site" scope from pathname; reorders operations to run auth check first; adds x-app-scope header to requests; adjusts i18n redirect/rewrite handling to preserve scope header.
Root layout scope-based rendering
frontend/app/[locale]/layout.tsx
Retrieves x-app-scope header to conditionally render ShopHeader for "shop" scope or default header with navigation; adds NEXT_PUBLIC_ENABLE_ADMIN feature flag for admin nav link; restores auth actions and language switcher in non-shop path.
Shop layout cleanup
frontend/app/[locale]/shop/layout.tsx
Removes Header, Footer, and admin feature flag logic; simplifies layout to render only ThemeProvider and CartProvider wrappers around main content.

Sequence Diagram

sequenceDiagram
    participant Client
    participant Middleware
    participant RootLayout
    participant ShopHeader
    participant DefaultHeader
    
    Client->>Middleware: HTTP Request
    Middleware->>Middleware: getScopeFromPathname()
    Note over Middleware: Extract scope ("shop" or "site")
    Middleware->>Middleware: Run authMiddleware
    Middleware->>Middleware: Set x-app-scope header
    Middleware-->>Client: NextResponse with x-app-scope
    
    Client->>RootLayout: Request
    RootLayout->>RootLayout: Read x-app-scope header
    alt scope === "shop"
        RootLayout->>ShopHeader: Render ShopHeader
        ShopHeader-->>RootLayout: ShopHeader component
    else scope === "site"
        RootLayout->>DefaultHeader: Render DefaultHeader
        DefaultHeader->>DefaultHeader: Show nav links, auth, language switcher
        DefaultHeader-->>RootLayout: DefaultHeader component
    end
    RootLayout-->>Client: Rendered page
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Areas requiring attention:
    • getScopeFromPathname logic: verify pathname parsing correctly identifies "shop" vs "site" scope across all locales
    • Header conditionalrendering in root layout: ensure x-app-scope header is reliably set and read
    • Middleware ordering: confirm auth check runs before scope computation and i18n logic doesn't interfere with header propagation
    • Shop layout simplification: verify no unintended removal of required layout functionality

Poem

🐰 A scope-based quest through pathnames wide,
Where headers guide us, left and right divide,
Shop or site, the middleware does declare,
Rendering headers with conditional care,
Cleaner layouts blooming everywhere! 🌿

Pre-merge checks and finishing touches

❌ 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%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main changes: header refactoring to separate shop and main headers, and footer removal across the application.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch lso/feat/shop

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

Copy link
Copy Markdown
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

🧹 Nitpick comments (2)
frontend/app/[locale]/shop/layout.tsx (1)

14-16: Consider removing empty lines for cleaner formatting.

The empty lines at 14 and 16 appear to be artifacts from removing the header and footer components. Consider removing them for cleaner code formatting.

🔎 Apply this diff to clean up the empty lines:
       <CartProvider>
         <div className="flex min-h-screen flex-col">
-            
           <main className="flex-1">{children}</main>
-            
         </div>
       </CartProvider>
frontend/middleware.ts (1)

63-67: Setting x-app-scope on redirect responses is unnecessary.

When the intl middleware returns a redirect (with a location header), setting x-app-scope on that response (line 65) has no effect because redirect responses don't carry custom headers to the subsequent request. The middleware will execute again on the redirected request and recalculate the scope anyway.

While harmless, you can simplify the code by removing this header assignment for redirects and only setting it for rewrites.

🔎 Optional: Remove unnecessary header assignment on redirects
-  const isRewriteOrRedirect = intlResponse.headers.has("location") || intlResponse.headers.has("x-middleware-rewrite")
-  if (isRewriteOrRedirect) {
+  const isRewrite = intlResponse.headers.has("x-middleware-rewrite")
+  if (isRewrite) {
     intlResponse.headers.set("x-app-scope", scope)
     return intlResponse
   }
+  
+  // For redirects, just return the response - middleware will run again
+  if (intlResponse.headers.has("location")) {
+    return intlResponse
+  }
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 298fdc3 and 6d5e956.

📒 Files selected for processing (3)
  • frontend/app/[locale]/layout.tsx (3 hunks)
  • frontend/app/[locale]/shop/layout.tsx (1 hunks)
  • frontend/middleware.ts (1 hunks)
🔇 Additional comments (4)
frontend/app/[locale]/layout.tsx (2)

12-13: LGTM! Correct async headers() usage for Next.js 15+.

The import and usage of await headers() correctly follows Next.js 15+ conventions where request APIs are asynchronous. The fallback to 'site' provides a safe default scope, and the showAdminNavLink flag is properly derived from the environment variable.

Also applies to: 32-33


43-113: LGTM! Clean scope-based header rendering.

The conditional rendering logic correctly delegates to ShopHeader for shop routes while preserving the existing navigation and authentication controls for site routes. The structure is clear and aligns with the PR objectives of route-aware header switching.

frontend/middleware.ts (2)

46-49: LGTM! Solid scope detection logic.

The getScopeFromPathname function correctly strips the locale prefix using a positive lookahead to ensure only the locale at the start is matched. The return type is properly constrained to the union type, and the shop detection logic is straightforward.


59-60: LGTM! Correct header propagation for Next.js middleware.

The implementation correctly creates a new Headers object with x-app-scope and passes it to NextResponse.next(), making the scope header available to downstream server components that read it via headers().

Also applies to: 69-71

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread frontend/middleware.ts
Comment on lines +65 to +69
intlResponse.headers.set("x-app-scope", scope)
return intlResponse
}

return intlResponse;
return NextResponse.next({
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Preserve intl middleware response for locale headers

When the request isn’t rewritten you’re now returning NextResponse.next instead of the intlResponse from createIntlMiddleware, so locale headers (e.g., x-next-intl-locale) generated by next-intl never reach the app. Because i18n/request.ts falls back to the default language when requestLocale is missing, localized URLs like /en/... or /pl/... will render default-language messages unless the request happens to hit the rewrite/redirect branch.

Useful? React with 👍 / 👎.

@ViktorSvertoka ViktorSvertoka merged commit fdf4039 into develop Dec 18, 2025
5 checks passed
@ViktorSvertoka ViktorSvertoka deleted the lso/feat/shop branch December 18, 2025 19:59
liudmylasovetovs pushed a commit that referenced this pull request Jan 9, 2026
ref: header separating shop and main header and removing footer
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