/**
 * Cart UI constants. Single source for path and breakpoint.
 * See docs/cart-ui-implementation-plan.md.
 */

/** Path for the full cart page. Use for nav links and "View full cart". */
export const CART_PAGE_PATH = "/cart";

/** Tailwind breakpoint for side drawer (desktop). Below this, use bottom sheet. */
export const CART_DRAWER_BREAKPOINT = "lg";

/** Path for checkout (primary CTA from cart). */
export const CHECKOUT_PAGE_PATH = "/checkout";

/**
 * PDP URL for a cart line item when backend returns slug and category slugs.
 * Returns /shop when any segment is missing (fallback).
 */
export function getCartItemProductUrl(item: {
  productSlug?: string;
  parentCategorySlug?: string;
  childCategorySlug?: string;
}): string {
  const { productSlug, parentCategorySlug, childCategorySlug } = item;
  if (productSlug && parentCategorySlug && childCategorySlug) {
    return `/shop/${parentCategorySlug}/${childCategorySlug}/${productSlug}`;
  }
  return "/shop";
}
