Skip to content

Migration/n1 sd - #348

Closed
KaiUweCZE wants to merge 12 commits into
refactor/storefront-datafrom
migration/n1-sd
Closed

KaiUweCZE wants to merge 12 commits into
refactor/storefront-datafrom
migration/n1-sd

Conversation

@KaiUweCZE

@KaiUweCZE KaiUweCZE commented Mar 13, 2026 •

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

Release Notes

  • New Features

    • Enhanced product information display with badges and improved variant pricing
    • Improved checkout flow with better payment provider handling and error messages
  • Bug Fixes

    • Fixed pricing calculations and display clarity with dynamic tax handling
    • Resolved order retrieval and completion error handling
  • Performance Improvements

    • Optimised prefetch strategies with improved caching and cancellation support
  • UI/UX Improvements

    • Dynamic pricing labels clarifying subtotal calculations
    • Enhanced address validation and error feedback

@semanticdiff-com

semanticdiff-com Bot commented Mar 13, 2026 •

Copy link
Copy Markdown

Review changes with  SemanticDiff

Changed Files
File Status
  apps/n1/src/components/product-detail/product-info-panel.tsx  93% smaller
  apps/n1/src/app/ucet/profil/_components/address-list.tsx  89% smaller
  apps/n1/next.config.ts  84% smaller
  apps/n1/src/components/forms/register-form.tsx  64% smaller
  apps/n1/src/app/prihlaseni/page.tsx  63% smaller
  apps/n1/src/components/header/cart-content.tsx  55% smaller
  apps/n1/src/app/ucet/context/account-context.tsx  52% smaller
  apps/n1/src/app/ucet/profil/_components/order-list.tsx  51% smaller
  apps/n1/src/utils/cart/cart-validation.ts  48% smaller
  apps/n1/src/utils/cart/cart-helpers.ts  47% smaller
  apps/n1/src/app/ucet/objednavky/[id]/_components/order-detail.tsx  46% smaller
  apps/n1/src/app/pokladna/_components/save-address-panel.tsx  44% smaller
  apps/n1/src/app/pokladna/_components/order-summary.tsx  43% smaller
  apps/n1/src/components/address/address-form.tsx  41% smaller
  apps/n1/src/app/pokladna/_components/cart-item-row.tsx  37% smaller
  apps/n1/src/components/provider.tsx  37% smaller
  apps/n1/src/app/pokladna/_components/checkout-review.tsx  37% smaller
  apps/n1/src/components/header/cart-item.tsx  31% smaller
  apps/n1/src/hooks/use-login.ts  30% smaller
  apps/n1/src/hooks/use-register.ts  30% smaller
  apps/n1/src/app/(dynamic)/produkt/[handle]/error.tsx  29% smaller
  apps/n1/src/app/pokladna/_components/payment-form-section.tsx  26% smaller
  apps/n1/src/components/molecules/product-grid.tsx  26% smaller
  apps/n1/src/app/orders/[orderId]/page.tsx  21% smaller
  apps/n1/src/hooks/use-region.ts  21% smaller
  apps/n1/src/app/pokladna/_context/checkout-context.tsx  19% smaller
  apps/n1/src/app/ucet/layout.tsx  19% smaller
  apps/n1/src/hooks/use-prefetch-root-categories.ts  17% smaller
  apps/n1/src/hooks/use-customer.ts  16% smaller
  apps/n1/src/hooks/use-logout.ts  15% smaller
  apps/n1/src/app/ucet/objednavky/[id]/_components/order-detail-client.tsx  15% smaller
  apps/n1/src/app/pokladna/_components/shipping-method-section.tsx  12% smaller
  apps/n1/src/hooks/use-prefetch-products.ts  12% smaller
  apps/n1/src/hooks/use-prefetch-product.ts  12% smaller
  apps/n1/src/lib/medusa-client.ts  11% smaller
  apps/n1/src/app/api/feed/products/route.ts  10% smaller
  apps/n1/src/hooks/use-checkout-payment.ts  10% smaller
  apps/n1/src/app/pokladna/page.tsx  9% smaller
  apps/n1/src/hooks/use-orders.ts  8% smaller
  apps/n1/src/hooks/use-checkout-shipping.ts  7% smaller
  apps/n1/src/components/prefetch-manager.tsx  7% smaller
  apps/n1/src/hooks/use-cart.ts  6% smaller
  apps/n1/src/hooks/use-update-cart-address.ts  6% smaller
  apps/n1/src/utils/address-helpers.ts  6% smaller
  apps/n1/src/utils/format/format-product.ts  5% smaller
  apps/n1/src/hooks/use-auth.ts  3% smaller
  apps/n1/src/components/product-detail/related-products.tsx  1% smaller
  apps/n1/src/app/pokladna/_components/address-picker.tsx  1% smaller
  apps/n1/package.json  0% smaller
  apps/n1/src/app/(dynamic)/kategorie/[handle]/page.tsx  0% smaller
  apps/n1/src/app/(dynamic)/produkt/[handle]/page.tsx  0% smaller
  apps/n1/src/components/header/desktop-submenu.tsx  0% smaller
  apps/n1/src/components/product-detail/product-info-panel/add-to-cart-section.tsx  0% smaller
  apps/n1/src/data/static/categories.ts Unsupported file format
  apps/n1/src/hooks/prefetch-region.ts  0% smaller
  apps/n1/src/hooks/prefetch-utils.ts  0% smaller
  apps/n1/src/hooks/storefront-preset.ts  0% smaller
  apps/n1/src/hooks/use-addresses.ts  0% smaller
  apps/n1/src/hooks/use-complete-checkout.ts  0% smaller
  apps/n1/src/hooks/use-prefetch-pages.ts  0% smaller
  apps/n1/src/hooks/use-product.ts  0% smaller
  apps/n1/src/hooks/use-products.ts  0% smaller
  apps/n1/src/lib/errors.ts  0% smaller
  apps/n1/src/lib/loggers/cache.ts  0% smaller
  apps/n1/src/lib/loggers/fetch.ts  0% smaller
  apps/n1/src/lib/loggers/prefetch.ts  0% smaller
  apps/n1/src/lib/orders/errors.ts  0% smaller
  apps/n1/src/lib/prefetch-config.ts  0% smaller
  apps/n1/src/lib/pricing/cart-pricing.ts  0% smaller
  apps/n1/src/lib/product-query-params.ts  0% smaller
  apps/n1/src/lib/query-keys.ts  0% smaller
  apps/n1/src/lib/storefront-address-adapter.ts  0% smaller
  apps/n1/src/lib/token-utils.ts  0% smaller
  apps/n1/src/services/auth-service.ts  0% smaller
  apps/n1/src/services/cart-service.ts  0% smaller
  apps/n1/src/services/customer-service.ts  0% smaller
  apps/n1/src/services/order-service.ts  0% smaller
  apps/n1/src/services/product-service.ts  0% smaller
  apps/n1/src/tokens/app-components/atoms/_button.css  0% smaller
  apps/n1/src/tokens/app-components/atoms/_checkbox.css  0% smaller
  apps/n1/src/tokens/app-components/index.css  0% smaller
  apps/n1/src/types/cart.ts  0% smaller
  apps/n1/src/utils/address-validation.ts  0% smaller
  pnpm-lock.yaml  0% smaller

@vercel

vercel Bot commented Mar 13, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
new-engine-ui-storybook Ready Ready Preview, Comment Mar 16, 2026 11:36am

@coderabbitai

coderabbitai Bot commented Mar 13, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 033493ec-463f-46e6-86da-fd9e47e9827e

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Walkthrough

This PR integrates the new @techsio/storefront-data library across the application, consolidating previously scattered data-fetching logic, service layers, and custom hooks into a centralised storefront-preset abstraction. Existing services are removed and replaced with delegated storefront hooks throughout the codebase.

Changes

Cohort / File(s) Summary
Configuration & Dependencies
apps/n1/next.config.ts, apps/n1/package.json
Adds @techsio/storefront-data to transpilePackages and dependencies; bumps Medusa packages from ^2.10.3 to ^2.13.1.
Service Layer Removal
apps/n1/src/services/auth-service.ts, apps/n1/src/services/cart-service.ts, apps/n1/src/services/customer-service.ts, apps/n1/src/services/order-service.ts, apps/n1/src/services/product-service.ts, apps/n1/src/lib/token-utils.ts, apps/n1/src/lib/query-keys.ts, apps/n1/src/lib/loggers/cache.ts, apps/n1/src/lib/loggers/fetch.ts
Removes entire service modules and utility functions, delegating functionality to storefront-preset hooks and centralized storefront implementations.
Storefront Integration Setup
apps/n1/src/hooks/storefront-preset.ts, apps/n1/src/lib/medusa-client.ts
Introduces comprehensive storefront-preset configuration with auth, cart, checkout, product, and orders services; updates Medusa SDK instantiation to use factory helper with session-based auth.
Auth & Customer Hooks
apps/n1/src/hooks/use-auth.ts, apps/n1/src/hooks/use-login.ts, apps/n1/src/hooks/use-logout.ts, apps/n1/src/hooks/use-register.ts, apps/n1/src/hooks/use-customer.ts, apps/n1/src/hooks/use-addresses.ts
Refactored to delegate to storefront auth and customer hooks; removes token expiry checking; introduces isFetching state; returns HttpTypes.StoreCustomer instead of custom types.
Cart & Checkout Hooks
apps/n1/src/hooks/use-cart.ts, apps/n1/src/hooks/use-update-cart-address.ts, apps/n1/src/hooks/use-checkout-payment.ts, apps/n1/src/hooks/use-checkout-shipping.ts, apps/n1/src/hooks/use-complete-checkout.ts
Consolidates cart operations via cartFlow; adds initiatePaymentAsync and shippingPrices exposure; removes local mutation scaffolding; delegates to centralised checkout flow.
Orders Hooks
apps/n1/src/hooks/use-orders.ts
Replaces direct order fetching with storefront-driven hooks; adds authentication and parameter validation guards; introduces OrderListInput, OrderDetailInput types; exports createOrdersListPrefetchQuery.
Product Hooks
apps/n1/src/hooks/use-product.ts, apps/n1/src/hooks/use-products.ts, apps/n1/src/hooks/use-prefetch-product.ts, apps/n1/src/hooks/use-prefetch-products.ts, apps/n1/src/hooks/use-prefetch-pages.ts, apps/n1/src/hooks/use-prefetch-root-categories.ts
Delegates data fetching to storefront hooks; removes region/country context; introduces region-based prefetch reset logic; adds PREFETCH_DELAYS integration and runLoggedPrefetch abstraction.
Prefetch Utilities
apps/n1/src/hooks/prefetch-region.ts, apps/n1/src/hooks/prefetch-utils.ts
New modules providing region-aware prefetch guards (shouldResetPrefetchForRegion, shouldRunPrefetchManager, shouldRunRootPrefetch) and logged prefetch wrappers with timing and category label generation.
Region Hook
apps/n1/src/hooks/use-region.ts
Refactored to use storefront region hooks; centralises region selection logic and default currency handling; removes legacy query option builders.
Page & Component Updates
apps/n1/src/app/(dynamic)/kategorie/[handle]/page.tsx, apps/n1/src/app/(dynamic)/produkt/[handle]/page.tsx, apps/n1/src/app/(dynamic)/produkt/[handle]/error.tsx, apps/n1/src/app/orders/[orderId]/page.tsx, apps/n1/src/app/prihlaseni/page.tsx, apps/n1/src/app/ucet/layout.tsx, apps/n1/src/app/ucet/context/account-context.ts, apps/n1/src/app/ucet/objednavky/[id]/_components/order-detail-client.tsx, apps/n1/src/app/ucet/objednavky/[id]/_components/order-detail.tsx, apps/n1/src/app/ucet/profil/_components/order-list.tsx
Updates to use new storefront hooks; removes useSuspenseRegion calls; replaces queryKeys with storefront.queryKeys; introduces useOrder/useSuspensePublicOrder; updates error handling and user-friendly messages.
Checkout Components
apps/n1/src/app/pokladna/_components/address-picker.tsx, apps/n1/src/app/pokladna/_components/cart-item-row.tsx, apps/n1/src/app/pokladna/_components/checkout-review.tsx, apps/n1/src/app/pokladna/_components/order-summary.tsx, apps/n1/src/app/pokladna/_components/payment-form-section.tsx, apps/n1/src/app/pokladna/_components/save-address-panel.tsx, apps/n1/src/app/pokladna/_components/shipping-method-section.tsx, apps/n1/src/app/pokladna/_context/checkout-context.tsx, apps/n1/src/app/pokladna/page.tsx
Switches address types to HttpTypes.StoreCustomerAddress; integrates new pricing view helpers; refactors payment provider selection to context-driven; adds auto-select logic for PPL shipping; enhances error handling with localized messages; introduces shippingPrices prop plumbing.
Product & Header Components
apps/n1/src/components/header/cart-content.tsx, apps/n1/src/components/header/cart-item.tsx, apps/n1/src/components/header/desktop-submenu.tsx, apps/n1/src/components/product-detail/product-info-panel.tsx, apps/n1/src/components/product-detail/product-info-panel/add-to-cart-section.tsx, apps/n1/src/components/product-detail/related-products.tsx
Replaces formatToTaxIncluded with formatCartLineItemUnitPrice; introduces getCartPriceView; adds delayedPrefetch cancellation logic; adds variant pricing display and delivery options link; renames autoCreateCart to autoCreate.
Provider & Manager
apps/n1/src/components/provider.tsx, apps/n1/src/components/prefetch-manager.tsx
Integrates StorefrontDataProvider and StorefrontRegionBridge; replaces direct QueryClientProvider; adds region-aware prefetch reset and shouldRunPrefetchManager guards; migrates from MAGIC_DELAY to PREFETCH_DELAYS.
Product Data Service
apps/n1/src/app/api/feed/products/route.ts
Replaces raw Medusa API calls with createMedusaProductService abstraction; renames MedusaVariant/MedusaProduct to FeedVariant/FeedProduct; removes hard-coded API credentials.
Error Handling & Utilities
apps/n1/src/lib/errors.ts
Introduces toError, isAbortLikeError, toAddressValidationError; removes CartServiceError-related types; centralises error normalisation with UNKNOWN_ERROR_MESSAGE.
Address & Validation Utilities
apps/n1/src/lib/storefront-address-adapter.ts, apps/n1/src/utils/address-helpers.ts, apps/n1/src/utils/address-validation.ts, apps/n1/src/components/address/address-form.tsx, apps/n1/src/components/forms/register-form.tsx, apps/n1/src/app/ucet/profil/_components/address-list.tsx
Introduces comprehensive cartAddressAdapter and customerAddressAdapter; delegates addressToFormData and DEFAULT_ADDRESS to storefront adapter; adds validateAddressPatch for partial updates; updates address types to HttpTypes.StoreCustomerAddress throughout.
Pricing Utilities
apps/n1/src/lib/pricing/cart-pricing.ts, apps/n1/src/utils/format/format-product.ts
New comprehensive pricing module with getCartPriceView, getOrderPriceView, formatCartLineItemUnitPrice, formatShippingOptionDisplayPrice; adds formatCalculatedVariantPrice; removes formatToTaxIncluded.
Product Query & Type Refactoring
apps/n1/src/lib/product-query-params.ts, apps/n1/src/types/cart.ts, apps/n1/src/utils/cart/cart-helpers.ts, apps/n1/src/utils/cart/cart-validation.ts, apps/n1/src/lib/orders/errors.ts, apps/n1/src/lib/prefetch-config.ts
Removes buildPrefetchParams; refactors category ID handling; creates types/cart.ts with Cart, CartLineItem, OptimisticCart, CompleteCartResult, ShippingMethodData; adds OrderNotFoundError; adds CATEGORY_LIST to PREFETCH_DELAYS.
CSS Tokens
apps/n1/src/tokens/app-components/atoms/_button.css, apps/n1/src/tokens/app-components/atoms/_checkbox.css, apps/n1/src/tokens/app-components/index.css
Adds button foreground colour and checkbox spacing CSS tokens.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~75 minutes

Possibly related PRs

  • Feat/storefront data #290: Introduces the @techsio/storefront-data library that this PR fully integrates and delegates to across auth, cart, checkout, orders, products, and customer management hooks.

Suggested reviewers

  • BleedingDev

Poem

📚 From scattered services to one unified flow,
Old hooks now delegate, letting storefront grow,
Auth, carts, and orders dance in preset's embrace,
Centralised wisdom improves every place! ✨

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch migration/n1-sd

@KaiUweCZE

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review pls

@coderabbitai

coderabbitai Bot commented Mar 13, 2026

Copy link
Copy Markdown
Contributor

@KaiUweCZE: Sure! I'll kick off a review of the PR right away. 🐇

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@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: 18

Caution

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

⚠️ Outside diff range comments (3)
apps/n1/src/components/prefetch-manager.tsx (1)

43-54: ⚠️ Potential issue | 🟠 Major

fix(prefetch-manager): only mark prefetch complete after it actually runs

Line 43 flips hasPrefetched before the timeout fires. If the effect cleans up first because of a route change, region change, or unmount, the timer is cancelled but the ref stays true, so later visits will skip root-category prefetch entirely.

Suggested patch
-    hasPrefetched.current = true
-
     const timer = setTimeout(() => {
+      hasPrefetched.current = true
       prefetchLogger.info("Root", `Manager started from ${pathname}`)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/n1/src/components/prefetch-manager.tsx` around lines 43 - 54,
hasPrefetched.current is being set to true immediately instead of after the
scheduled prefetch runs, so cancelled timers still mark prefetch as done; move
the assignment inside the timeout callback (after calling
prefetchRootCategories) so hasPrefetched.current is only flipped when the
prefetch actually starts, and do not set it in the cleanup path; update the
timer callback in the component that uses PREFETCH_DELAYS, prefetchLogger,
hasPrefetched, and prefetchRootCategories accordingly.
apps/n1/src/utils/format/format-product.ts (1)

21-23: ⚠️ Potential issue | 🟠 Major

fix(pricing): stop returning 0 Kč for every zero-value amount

price ? ... and if (!amount) both treat 0 as the fallback branch, and that fallback still hard-codes CURRENCY_SYMBOL. In the new currency-aware flow this makes zero-priced EUR/USD products, shipping, and totals render as 0 Kč. Please switch to a null/finite check and format zero with the supplied currency.

Proposed fix
-import { CURRENCY_SYMBOL, DEFAULT_CURRENCY } from "@/lib/constants"
+import { DEFAULT_CURRENCY } from "@/lib/constants"
@@
   const price = tax
     ? variant?.calculated_price?.calculated_amount_with_tax
     : variant?.calculated_price?.calculated_amount_without_tax
-  const currency = variant?.calculated_price?.currency_code
-  const currencyMap = currency === "czk" ? CURRENCY_SYMBOL : currency
-  return price ? `${price.toFixed(0)} ${currencyMap}` : `0 ${CURRENCY_SYMBOL}`
+  const currency =
+    variant?.calculated_price?.currency_code?.toUpperCase() ?? DEFAULT_CURRENCY
+  return formatAmount(price, true, currency)
 }
@@
 export const formatAmount = (
   amount?: number | null,
   useGrouping = true,
   currency = DEFAULT_CURRENCY
 ) => {
-  if (!amount) {
-    return `0 ${CURRENCY_SYMBOL}`
+  if (typeof amount !== "number" || !Number.isFinite(amount)) {
+    return new Intl.NumberFormat("cs-CZ", {
+      style: "currency",
+      currency,
+      minimumFractionDigits: 0,
+      maximumFractionDigits: 0,
+      useGrouping,
+    }).format(0)
   }
   return new Intl.NumberFormat("cs-CZ", {
     style: "currency",
     currency,

Also applies to: 46-48

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

In `@apps/n1/src/utils/format/format-product.ts` around lines 21 - 23, The current
check treats 0 as falsy and falls back to CURRENCY_SYMBOL, causing zero amounts
to render as "0 Kč"; update the logic in format-product.ts to detect real
numeric values using a finite/null-safe check (e.g. Number.isFinite or price !==
null && isFinite(price)) instead of relying on truthiness, and when price is
zero format it with the resolved currencyMap (derived from
variant?.calculated_price?.currency_code) rather than hard-coding
CURRENCY_SYMBOL; apply the same fix to the other occurrences around the block
referenced (the similar logic at the lines noted, e.g., the other price
formatting branch).
apps/n1/src/app/api/feed/products/route.ts (1)

141-149: 🧹 Nitpick | 🔵 Trivial

Consider differentiating error responses.

The error handler returns an empty XML feed with the same cache headers as a successful response. Whilst this provides graceful degradation, it may mask persistent issues from monitoring systems. Consider either:

  • Returning a different status code (e.g., 503) with no-cache headers
  • Adding a comment/element in the XML indicating an error occurred
  • Logging to an external monitoring service

This is a minor observation; the current approach is acceptable if feed availability is prioritised over error visibility.

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

In `@apps/n1/src/app/api/feed/products/route.ts` around lines 141 - 149, The catch
block currently logs the error and returns an empty XML feed with success cache
headers; change it to make errors distinguishable by either returning a non-200
status and no-cache headers or embedding an error element in the XML: capture
the caught error in the catch for route handler, call generateXmlFeed or a small
helper to produce an error-specific XML (e.g., include an <error> element with a
brief message), and return a NextResponse that sets a 503 status and
conservative Cache-Control (e.g., no-store, no-cache, must-revalidate) or
alternately keep 200 but include the error element; ensure the change is applied
around the catch that currently calls generateXmlFeed([]) and constructs the
NextResponse so monitoring and clients can detect failures.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@apps/n1/package.json`:
- Around line 22-27: The pnpm lockfile is out of sync with apps/n1/package.json:
`@medusajs/js-sdk` is declared as ^2.13.1 but pnpm-lock.yaml still references
^2.10.3 / resolved 2.12.4; fix by running pnpm install or pnpm update in the
apps/n1 workspace to regenerate pnpm-lock.yaml so it resolves `@medusajs/js-sdk`
to ^2.13.1, then commit the updated pnpm-lock.yaml (ensure the dependency entry
for "@medusajs/js-sdk" in pnpm-lock.yaml matches the package.json spec).

In `@apps/n1/src/app/`(dynamic)/kategorie/[handle]/page.tsx:
- Line 108: The currentPage calculation using Number(searchParams.get("page"))
can yield -1, 1.5, Infinity, etc.; normalize it to a positive integer before
passing to useSuspenseProducts by parsing and clamping: read the raw value via
searchParams.get("page"), convert with Number or parseFloat, ensure
Number.isFinite(raw) and raw > 0, then take Math.floor(raw) (or Math.trunc) and
clamp to at least 1; replace the current const currentPage = Number(...) with
this normalized logic so currentPage is always a finite integer >= 1 when used
by useSuspenseProducts.
- Around line 103-106: breadcrumbItems is currently hardcoded to only "Home" and
rootCategory/handle; instead build it from the category's full parent chain so
the current category appears and links are correct. Locate breadcrumbItems and
replace the two-item array with logic that: 1) starts with { label: "Home",
href: "/" }, 2) maps the full parent chain (e.g., rootCategory.parentChain or
category.parents — use whichever holds the ancestry) into { label: parent.name,
href: `/kategorie/${parent.handle}` } items, and 3) appends the current category
as the final item with its label and no href (so it’s not linkable). Ensure you
reference rootCategory and handle (or category.handle) correctly when building
URLs and preserve optional icon handling if present.

In `@apps/n1/src/app/pokladna/_components/payment-form-section.tsx`:
- Around line 21-25: The useEffect currently depends on the array reference
cart?.payment_collection?.payment_sessions which can trigger unnecessary runs;
change the dependency to the actual provider id value by deriving the provider
id (the same expression used to compute currentProvider) and use that provider
id as the dependency so the effect only runs when provider_id changes; update
the useEffect that calls setSelectedProvider accordingly (referencing useEffect,
setSelectedProvider, and the expression
cart?.payment_collection?.payment_sessions?.[0]?.provider_id).

In `@apps/n1/src/app/pokladna/_components/shipping-method-section.tsx`:
- Around line 40-41: The code computes formattedPrice using
formatShippingOptionDisplayPrice(option, shippingPrices) with a default of
"Zdarma", so remove the redundant fallback at the use site (the `|| "Zdarma"`
after formattedPrice) to avoid double-defaulting; keep the initial default in
the formattedPrice declaration and update any JSX or usages to use
formattedPrice directly (referencing the formattedPrice variable and the
formatShippingOptionDisplayPrice call to locate the change).

In `@apps/n1/src/app/ucet/objednavky/`[id]/_components/order-detail.tsx:
- Around line 50-57: The shipping row currently only renders when
order.shipping_methods?.[0] exists, which hides a non-zero shipping amount;
change the conditional to render based on pricing.hasShipping instead and make
the method label optional by reading order.shipping_methods?.[0]?.name (or
falling back to a generic label). Update the JSX around the conditional that
uses order.shipping_methods?.[0] and pricing.hasShipping in the OrderDetail
component so the row shows whenever pricing.hasShipping is true and the method
name is shown only if order.shipping_methods?.[0]?.name is present.

In `@apps/n1/src/components/header/cart-content.tsx`:
- Around line 124-127: Extract the magic number 1500 into a named constant (e.g.
FREE_SHIPPING_THRESHOLD) at the top of the cart-content.tsx file and replace
both usages: the condition that references pricing.itemsSubtotalAmount and the
subtraction passed to formatAmount (currently 1500 -
pricing.itemsSubtotalAmount). Update any related text if you use the constant
for display (e.g. render FREE_SHIPPING_THRESHOLD in the string) so both logic
and UI read from the same symbol; keep the reference to
pricing.itemsSubtotalAmount and formatAmount intact.

In `@apps/n1/src/components/product-detail/related-products.tsx`:
- Around line 10-15: The component currently calls useProducts with enabled:
hasCategories but still renders the heading/wrapper because an empty array is
truthy; update the component right after the hook (referencing hasCategories,
useProducts, and rawProducts) to return null when there is no category context
(hasCategories === false) or when the query returns no related products
(rawProducts is empty/length === 0) so the related-products section is not
rendered for uncategorised PDPs.

In `@apps/n1/src/hooks/prefetch-utils.ts`:
- Around line 37-41: Currently prefetchLogger.complete is called only after
await prefetch(), so if prefetch() rejects the span remains open; wrap the await
in try/finally: call prefetchLogger.start(type, label) and record start =
performance.now() before awaiting prefetch(), then in a finally block compute
duration = performance.now() - start and call prefetchLogger.complete(type,
label, duration) so the span is always closed even on errors (refer to
prefetch(), prefetchLogger.start, prefetchLogger.complete, and
performance.now()).

In `@apps/n1/src/hooks/use-orders.ts`:
- Around line 73-84: The code is using a type assertion "as OrderDetailInput" in
useOrder which hides a real mismatch between UseOrderInput (id?: string | null)
and OrderDetailInput (id?: string); fix by normalizing the id before calling
orderHooks.useOrder: convert null/undefined to undefined and ensure the payload
matches OrderDetailInput shape (e.g., build an explicit object { id: id ??
undefined } or map fields from UseOrderInput to OrderDetailInput), remove the
unsafe cast, and update the UseOrderInput or OrderDetailInput types if necessary
so they align with the actual hook signature (refer to useOrder, UseOrderInput,
OrderDetailInput, and orderHooks.useOrder to locate the code).

In `@apps/n1/src/hooks/use-prefetch-root-categories.ts`:
- Around line 31-34: The code resets both hasPrefetched.current and
prefetchedRegionId.current when shouldResetPrefetchForRegion(...) is true, but
on the success path only hasPrefetched.current is set to true leaving
prefetchedRegionId.current stale; update the success path(s) to also assign
prefetchedRegionId.current = regionId so both hasPrefetched.current and
prefetchedRegionId.current remain consistent (apply the same change in the other
success location that corresponds to lines 48-49); look for usages in the hook
surrounding shouldResetPrefetchForRegion, hasPrefetched.current, and
prefetchedRegionId.current to make the symmetric update.

In `@apps/n1/src/hooks/use-products.ts`:
- Around line 45-48: Normalize pagination inputs in useProducts before building
listParams: clamp page to at least 1 and ensure limit is a positive integer
(fallback to a safe default if <= 0) and then compute offset = (page - 1) *
limit; update the listParams object(s) (the one using category_id, limit, offset
and the other occurrence later in the file) to use these sanitized values so
negative or zero page/limit never produce invalid offsets.

In `@apps/n1/src/lib/errors.ts`:
- Around line 164-177: The code casts issue.field to AddressFieldKey without
runtime validation, risking invalid keys; update the loop inside the
StorefrontAddressValidationError branch to validate issue.field before using it
as a key (e.g., create a runtime guard/isAddressFieldKey or check against a
whitelist/set of valid AddressFieldKey values) and only assign to
mappedErrors[field] when the field is confirmed valid and issue.message exists,
preserving the final creation of AddressValidationError when mappedErrors is
non-empty.

In `@apps/n1/src/lib/medusa-client.ts`:
- Around line 17-21: The auth object in medusa-client.ts incorrectly includes
jwtTokenStorageMethod which is only valid for JWT auth; remove the
jwtTokenStorageMethod property from the auth config in the client setup (leave
type: "session" and keep fetchCredentials: "include" if needed) so the auth
block follows the session-based pattern used elsewhere (e.g., the auth object in
the Medusa SDK initialization).

In `@apps/n1/src/lib/orders/errors.ts`:
- Line 2: The default Czech message in the constructor of the orders error class
is misspelled; update the constructor's default string from "Objednavka
nenalezena" to the correctly accented "Objednávka nenalezena" in the constructor
used in apps/n1/src/lib/orders/errors.ts (the constructor for the NotFound/order
error class) and ensure the file remains UTF-8 encoded so the diacritic is
preserved in UI/log output.

In `@apps/n1/src/lib/pricing/cart-pricing.ts`:
- Around line 102-104: The taxAmount fallback currently uses order.tax_total ??
order.item_tax_total ?? 0 which omits shipping tax; update the taxAmount
calculation to include shipping tax by using order.tax_total ??
(order.item_tax_total ?? 0) + (order.shipping_tax_total ?? 0) so that both item
and shipping tax components are summed when tax_total is missing; adjust the
variable taxAmount in cart-pricing.ts (where shippingAmount and totalAmount are
defined) to use this summed fallback.

In `@apps/n1/src/lib/product-query-params.ts`:
- Around line 17-29: normalizeCategoryId currently returns [""] for an empty
string and passes through [] unchanged, which can create unwanted query params;
update normalizeCategoryId (function name: normalizeCategoryId, param type:
BuilderParams["category_id"]) to filter out falsy/empty-string values and return
undefined when the resulting array is empty (i.e., convert single string to
[string] then filter out "" and if the final array.length === 0 return
undefined), and if this behavior is intentional add a short comment documenting
why empty values should be preserved.

In `@apps/n1/src/lib/storefront-address-adapter.ts`:
- Around line 18-21: Consolidate the duplicate imports by replacing separate
import lines for cleanPhoneNumber and formatPhoneNumber with a single import
from "@/utils/format/format-phone-number" (e.g., import { cleanPhoneNumber,
formatPhoneNumber } ...) and do the same for cleanPostalCode and
formatPostalCode from "@/utils/format/format-postal-code"; remove the redundant
import statements so only one import per module remains and ensure the
referenced symbols (cleanPhoneNumber, formatPhoneNumber, cleanPostalCode,
formatPostalCode) are preserved where used.

---

Outside diff comments:
In `@apps/n1/src/app/api/feed/products/route.ts`:
- Around line 141-149: The catch block currently logs the error and returns an
empty XML feed with success cache headers; change it to make errors
distinguishable by either returning a non-200 status and no-cache headers or
embedding an error element in the XML: capture the caught error in the catch for
route handler, call generateXmlFeed or a small helper to produce an
error-specific XML (e.g., include an <error> element with a brief message), and
return a NextResponse that sets a 503 status and conservative Cache-Control
(e.g., no-store, no-cache, must-revalidate) or alternately keep 200 but include
the error element; ensure the change is applied around the catch that currently
calls generateXmlFeed([]) and constructs the NextResponse so monitoring and
clients can detect failures.

In `@apps/n1/src/components/prefetch-manager.tsx`:
- Around line 43-54: hasPrefetched.current is being set to true immediately
instead of after the scheduled prefetch runs, so cancelled timers still mark
prefetch as done; move the assignment inside the timeout callback (after calling
prefetchRootCategories) so hasPrefetched.current is only flipped when the
prefetch actually starts, and do not set it in the cleanup path; update the
timer callback in the component that uses PREFETCH_DELAYS, prefetchLogger,
hasPrefetched, and prefetchRootCategories accordingly.

In `@apps/n1/src/utils/format/format-product.ts`:
- Around line 21-23: The current check treats 0 as falsy and falls back to
CURRENCY_SYMBOL, causing zero amounts to render as "0 Kč"; update the logic in
format-product.ts to detect real numeric values using a finite/null-safe check
(e.g. Number.isFinite or price !== null && isFinite(price)) instead of relying
on truthiness, and when price is zero format it with the resolved currencyMap
(derived from variant?.calculated_price?.currency_code) rather than hard-coding
CURRENCY_SYMBOL; apply the same fix to the other occurrences around the block
referenced (the similar logic at the lines noted, e.g., the other price
formatting branch).
🪄 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: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 252826b8-5c00-4874-9092-ed735c104bf7

📥 Commits

Reviewing files that changed from the base of the PR and between e9b9026 and ac1098d.

📒 Files selected for processing (82)
  • apps/n1/next.config.ts
  • apps/n1/package.json
  • apps/n1/src/app/(dynamic)/kategorie/[handle]/page.tsx
  • apps/n1/src/app/(dynamic)/produkt/[handle]/error.tsx
  • apps/n1/src/app/(dynamic)/produkt/[handle]/page.tsx
  • apps/n1/src/app/api/feed/products/route.ts
  • apps/n1/src/app/orders/[orderId]/page.tsx
  • apps/n1/src/app/pokladna/_components/address-picker.tsx
  • apps/n1/src/app/pokladna/_components/cart-item-row.tsx
  • apps/n1/src/app/pokladna/_components/checkout-review.tsx
  • apps/n1/src/app/pokladna/_components/order-summary.tsx
  • apps/n1/src/app/pokladna/_components/payment-form-section.tsx
  • apps/n1/src/app/pokladna/_components/save-address-panel.tsx
  • apps/n1/src/app/pokladna/_components/shipping-method-section.tsx
  • apps/n1/src/app/pokladna/_context/checkout-context.tsx
  • apps/n1/src/app/pokladna/page.tsx
  • apps/n1/src/app/prihlaseni/page.tsx
  • apps/n1/src/app/ucet/context/account-context.tsx
  • apps/n1/src/app/ucet/layout.tsx
  • apps/n1/src/app/ucet/objednavky/[id]/_components/order-detail-client.tsx
  • apps/n1/src/app/ucet/objednavky/[id]/_components/order-detail.tsx
  • apps/n1/src/app/ucet/profil/_components/address-list.tsx
  • apps/n1/src/app/ucet/profil/_components/order-list.tsx
  • apps/n1/src/components/address/address-form.tsx
  • apps/n1/src/components/forms/register-form.tsx
  • apps/n1/src/components/header/cart-content.tsx
  • apps/n1/src/components/header/cart-item.tsx
  • apps/n1/src/components/header/desktop-submenu.tsx
  • apps/n1/src/components/molecules/product-grid.tsx
  • apps/n1/src/components/prefetch-manager.tsx
  • apps/n1/src/components/product-detail/product-info-panel.tsx
  • apps/n1/src/components/product-detail/product-info-panel/add-to-cart-section.tsx
  • apps/n1/src/components/product-detail/related-products.tsx
  • apps/n1/src/components/provider.tsx
  • apps/n1/src/data/static/categories.ts
  • apps/n1/src/hooks/prefetch-region.ts
  • apps/n1/src/hooks/prefetch-utils.ts
  • apps/n1/src/hooks/storefront-preset.ts
  • apps/n1/src/hooks/use-addresses.ts
  • apps/n1/src/hooks/use-auth.ts
  • apps/n1/src/hooks/use-cart.ts
  • apps/n1/src/hooks/use-checkout-payment.ts
  • apps/n1/src/hooks/use-checkout-shipping.ts
  • apps/n1/src/hooks/use-complete-checkout.ts
  • apps/n1/src/hooks/use-customer.ts
  • apps/n1/src/hooks/use-login.ts
  • apps/n1/src/hooks/use-logout.ts
  • apps/n1/src/hooks/use-orders.ts
  • apps/n1/src/hooks/use-prefetch-pages.ts
  • apps/n1/src/hooks/use-prefetch-product.ts
  • apps/n1/src/hooks/use-prefetch-products.ts
  • apps/n1/src/hooks/use-prefetch-root-categories.ts
  • apps/n1/src/hooks/use-product.ts
  • apps/n1/src/hooks/use-products.ts
  • apps/n1/src/hooks/use-region.ts
  • apps/n1/src/hooks/use-register.ts
  • apps/n1/src/hooks/use-update-cart-address.ts
  • apps/n1/src/lib/errors.ts
  • apps/n1/src/lib/loggers/cache.ts
  • apps/n1/src/lib/loggers/fetch.ts
  • apps/n1/src/lib/medusa-client.ts
  • apps/n1/src/lib/orders/errors.ts
  • apps/n1/src/lib/prefetch-config.ts
  • apps/n1/src/lib/pricing/cart-pricing.ts
  • apps/n1/src/lib/product-query-params.ts
  • apps/n1/src/lib/query-keys.ts
  • apps/n1/src/lib/storefront-address-adapter.ts
  • apps/n1/src/lib/token-utils.ts
  • apps/n1/src/services/auth-service.ts
  • apps/n1/src/services/cart-service.ts
  • apps/n1/src/services/customer-service.ts
  • apps/n1/src/services/order-service.ts
  • apps/n1/src/services/product-service.ts
  • apps/n1/src/tokens/app-components/atoms/_button.css
  • apps/n1/src/tokens/app-components/atoms/_checkbox.css
  • apps/n1/src/tokens/app-components/index.css
  • apps/n1/src/types/cart.ts
  • apps/n1/src/utils/address-helpers.ts
  • apps/n1/src/utils/address-validation.ts
  • apps/n1/src/utils/cart/cart-helpers.ts
  • apps/n1/src/utils/cart/cart-validation.ts
  • apps/n1/src/utils/format/format-product.ts
💤 Files with no reviewable changes (9)
  • apps/n1/src/lib/loggers/fetch.ts
  • apps/n1/src/services/product-service.ts
  • apps/n1/src/services/auth-service.ts
  • apps/n1/src/services/order-service.ts
  • apps/n1/src/lib/loggers/cache.ts
  • apps/n1/src/lib/token-utils.ts
  • apps/n1/src/services/cart-service.ts
  • apps/n1/src/lib/query-keys.ts
  • apps/n1/src/services/customer-service.ts

Comment thread apps/n1/package.json
Comment thread apps/n1/src/app/(dynamic)/kategorie/[handle]/page.tsx Outdated
Comment thread apps/n1/src/app/(dynamic)/kategorie/[handle]/page.tsx Outdated
Comment thread apps/n1/src/app/pokladna/_components/payment-form-section.tsx Outdated
Comment thread apps/n1/src/app/pokladna/_components/shipping-method-section.tsx
Comment thread apps/n1/src/lib/medusa-client.ts
Comment thread apps/n1/src/lib/orders/errors.ts Outdated
Comment thread apps/n1/src/lib/pricing/cart-pricing.ts
Comment thread apps/n1/src/lib/product-query-params.ts
Comment thread apps/n1/src/lib/storefront-address-adapter.ts Outdated
@BleedingDev

Copy link
Copy Markdown
Collaborator

Superseded by #352, which rebases this work onto #351 without rewriting the existing branch destructively.

This branch was successfully deployed

1 active deployment
Preview — ed6ff8ce Deployed Mar 16, 2026 by vercel[bot]
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