All files / src/components/CustomBreadcrumbsPage/hooks useGetRebrandedTableBehaviour.ts

100% Statements 11/11
87.5% Branches 7/8
100% Functions 1/1
100% Lines 11/11

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35      14x 14x   14x 14x     14x             14x   14x         14x       14x   14x   14x    
import { rebrandedPages } from "constants/constants";
import { useDynamicTheme } from "theme/hooks/useDynamicTheme";
 
export const useGetRebrandedTableBehaviour = () => {
  const { isMobileView } = useDynamicTheme();
 
  const pathName = location.pathname;
  const isRebrandedPermission = location.pathname.includes(
    "acquirer/settings/permissions",
  );
  const isRebrandedSettings = location.pathname.includes("settings");
 
  // PayBuilder 032-b: the Event Detail view is rebranded, but `rebrandedPages`
  // holds exact list paths only, so `/merchant/events/:id` never matched and
  // the page kept the legacy 16px padding — a white strip above its banner
  // backdrop. Matched by segment rather than regex to stay clear of the
  // staged-regex pre-commit hook.
  const segments = pathName.split("/").filter(Boolean);
  const isRebrandedEventDetail =
    segments.length === 3 &&
    segments[0] === "merchant" &&
    segments[1] === "events";
 
  const pageRebranded =
    rebrandedPages.includes(pathName) ||
    isRebrandedPermission ||
    isRebrandedEventDetail;
 
  const isDisplayedTableNew = !!pageRebranded;
 
  const showMobileNavBarOverlay = isMobileView && !pageRebranded;
 
  return { isDisplayedTableNew, showMobileNavBarOverlay, isRebrandedSettings };
};