@vtex/faststore-plugin-buyer-portal 2.0.47 → 2.0.49

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/package.json +1 -1
  2. package/public/buyer-portal-icons.svg +9 -0
  3. package/src/features/accounting-fields/components/AccountingFieldDropdown/AccountingFieldDropdown.tsx +5 -2
  4. package/src/features/budgets/layouts/BudgetsDetailsLayout/BudgetsDetailsLayout.tsx +4 -9
  5. package/src/features/budgets/layouts/BudgetsLayout/BudgetsLayout.tsx +2 -9
  6. package/src/features/buying-policies/layouts/BuyingPoliciesLayout/BuyingPoliciesLayout.tsx +14 -31
  7. package/src/features/contracts/layouts/ContractListingLayout/ContractListingLayout.tsx +123 -108
  8. package/src/features/contracts/layouts/ContractListingLayout/ContractSettingsNav.tsx +39 -63
  9. package/src/features/contracts/layouts/ContractListingLayout/__tests__/utils.test.ts +51 -0
  10. package/src/features/contracts/layouts/ContractListingLayout/contract-listing-layout.scss +106 -61
  11. package/src/features/contracts/layouts/ContractListingLayout/utils.ts +53 -0
  12. package/src/features/org-units/components/OrgUnitDetailsNavbar/OrgUnitDetailsNavbar.tsx +4 -1
  13. package/src/features/org-units/layouts/OrgUnitsLayout/OrgUnitsLayout.tsx +2 -9
  14. package/src/features/roles/layout/RolesLayout/RolesLayout.tsx +2 -9
  15. package/src/features/shared/components/BasicDrawer/BasicDrawer.tsx +3 -2
  16. package/src/features/shared/components/BasicDrawer/BasicDrawerHeading.tsx +4 -1
  17. package/src/features/shared/components/VerticalNav/VerticalNavLink.tsx +3 -10
  18. package/src/features/shared/components/VerticalNav/VerticalNavTree.tsx +5 -30
  19. package/src/features/shared/components/VerticalNav/vertical-nav.scss +42 -29
  20. package/src/features/shared/hooks/index.ts +2 -0
  21. package/src/features/shared/hooks/useDropdownAlign.ts +27 -0
  22. package/src/features/shared/hooks/useShellScrollReset.ts +27 -0
  23. package/src/features/shared/layouts/ContractTabsLayout/ContractTabsLayout.tsx +26 -65
  24. package/src/features/shared/layouts/FinanceTabsLayout/FinanceTabsLayout.tsx +4 -41
  25. package/src/features/shared/layouts/OrgUnitTabsLayout/OrgUnitTabLayout.tsx +4 -39
  26. package/src/features/shared/layouts/SumaPageLayout/FullSidebarNav.tsx +0 -1
  27. package/src/features/shared/layouts/SumaPageLayout/SumaPageLayout.tsx +13 -7
  28. package/src/features/shared/layouts/SumaPageLayout/SumaSidebar.tsx +32 -47
  29. package/src/features/shared/layouts/SumaPageLayout/SumaSidebarDrawer.tsx +25 -1
  30. package/src/features/shared/layouts/SumaPageLayout/suma-sidebar-drawer.scss +133 -5
  31. package/src/features/shared/localization/__tests__/page-loader-entries.test.ts +2 -2
  32. package/src/features/shared/types/VerticalNav.ts +0 -1
  33. package/src/features/shared/utils/__tests__/getDropdownAlign.test.ts +17 -0
  34. package/src/features/shared/utils/__tests__/getSumaListingSidebarLinks.test.ts +30 -0
  35. package/src/features/shared/utils/__tests__/isNavLinkActive.test.ts +117 -0
  36. package/src/features/shared/utils/__tests__/routeLayoutMapping.test.ts +21 -1
  37. package/src/features/shared/utils/constants.ts +1 -1
  38. package/src/features/shared/utils/getDropdownAlign.ts +11 -0
  39. package/src/features/shared/utils/getSumaListingSidebarLinks.ts +8 -1
  40. package/src/features/shared/utils/isNavLinkActive.ts +40 -0
  41. package/src/features/shared/utils/routeLayoutMapping.ts +17 -4
  42. package/src/features/users/layouts/UsersLayout/UsersLayout.tsx +2 -9
  43. package/src/pages/contract-information.tsx +1 -1
  44. package/src/pages/contracts.tsx +30 -45
  45. package/src/pages/home.tsx +17 -25
  46. package/src/pages/org-unit-details.tsx +15 -102
@@ -1,17 +1,81 @@
1
1
  @use "~@faststore/ui/src/styles/base/utilities" as u;
2
+
3
+ // Google Docs' side menu curve, with its 250ms made 30% longer for this wider
4
+ // drawer, as Material does for tablets. There are no motion tokens for it
5
+ // (`--fs-transition-timing` is 0.2s).
6
+ $suma-sidebar-drawer-duration: 325ms;
7
+ $suma-sidebar-drawer-easing: cubic-bezier(0.4, 0, 0.2, 1);
8
+
9
+ @keyframes suma-sidebar-drawer-in {
10
+ from {
11
+ transform: translateX(-100%);
12
+ }
13
+ }
14
+
15
+ // The overlay's color fades with the drawer instead of popping in and out.
16
+ // The theme sets that color with `!important` inside this layer, so these
17
+ // rules join it with a higher specificity; transitions still run over
18
+ // `!important` values.
19
+ @layer theme {
20
+ [data-fs-overlay]:has([data-fs-bp-suma-sidebar-drawer][data-fs-slide-over]) {
21
+ transition: background-color $suma-sidebar-drawer-duration
22
+ $suma-sidebar-drawer-easing;
23
+
24
+ @starting-style {
25
+ background-color: transparent !important;
26
+ }
27
+
28
+ &:has([data-fs-slide-over-state="out"]) {
29
+ background-color: transparent !important;
30
+ }
31
+
32
+ @media (prefers-reduced-motion: reduce) {
33
+ transition: none;
34
+ }
35
+ }
36
+ }
37
+
2
38
  [data-fs-bp-suma-sidebar-drawer] {
3
39
  @import "../../components/BasicDrawer/basic-drawer.scss";
4
40
 
41
+ // Same height as the header that opens it; the padding stays at phone size
42
+ // because the drawer keeps its width at every breakpoint.
43
+ &[data-fs-bp-basic-drawer] [data-fs-bp-basic-drawer-heading] {
44
+ gap: var(--fs-bp-gap-1);
45
+ min-height: var(--fs-bp-spacing-12);
46
+ padding: var(--fs-bp-padding-0) var(--fs-bp-padding-5);
47
+ border-bottom-color: var(--fs-bp-color-neutral-2);
48
+
49
+ [data-fs-bp-basic-drawer-heading-title] {
50
+ &,
51
+ &:first-child {
52
+ padding-left: var(--fs-bp-padding-0);
53
+ }
54
+ }
55
+
56
+ // Same box and states as the header's menu button.
57
+ [data-fs-bp-basic-drawer-heading-close-button] {
58
+ --fs-button-height: var(--fs-bp-spacing-9);
59
+ --fs-button-border-radius: var(--fs-bp-border-radius-full);
60
+ --fs-button-tertiary-text-color: var(--fs-bp-color-neutral-8);
61
+ --fs-button-tertiary-text-color-active: var(--fs-bp-color-neutral-8);
62
+ --fs-button-tertiary-bkg-color-hover: var(--fs-bp-color-transparent-0);
63
+ --fs-button-tertiary-bkg-color-active: var(--fs-bp-color-transparent-1);
64
+
65
+ svg {
66
+ color: var(--fs-bp-color-neutral-8);
67
+ }
68
+ }
69
+ }
70
+
5
71
  [data-fs-bp-org-unit-details-navbar-link] {
6
- @include text-style('display-5');
72
+ @include text-style('display-6');
7
73
  font-weight: var(--fs-bp-weight-bold);
74
+ letter-spacing: var(--fs-bp-letter-spacing-3);
8
75
  color: var(--fs-bp-color-brand);
9
76
  text-decoration: none;
77
+ // Lines the logo up with the menu items' text
10
78
  margin-left: var(--fs-bp-margin-5);
11
-
12
- @include u.media(">=tablet") {
13
- margin: var(--fs-bp-margin-0);
14
- }
15
79
  }
16
80
 
17
81
  &[data-fs-bp-basic-drawer][data-fs-slide-over-size] {
@@ -27,6 +91,70 @@
27
91
  }
28
92
  }
29
93
 
94
+ // The drawer mounts already "in", so it slides in with an animation and
95
+ // slides out with a transition, both with the same curve. The shadow
96
+ // separates it from the page and goes away as soon as it starts closing.
97
+ &[data-fs-bp-basic-drawer][data-fs-slide-over] {
98
+ --fs-slide-over-transition-timing: #{$suma-sidebar-drawer-duration};
99
+
100
+ box-shadow: 0 0 var(--fs-bp-spacing-4) var(--fs-bp-color-transparent-1);
101
+ animation: suma-sidebar-drawer-in var(--fs-slide-over-transition-timing)
102
+ $suma-sidebar-drawer-easing;
103
+
104
+ &[data-fs-slide-over-state="out"] {
105
+ box-shadow: none;
106
+ animation: none;
107
+ transform: translateX(-100%);
108
+ transition: transform var(--fs-slide-over-transition-timing)
109
+ $suma-sidebar-drawer-easing;
110
+ }
111
+
112
+ // The exit still needs a transition: its end unmounts the drawer.
113
+ @media (prefers-reduced-motion: reduce) {
114
+ --fs-slide-over-transition-timing: 1ms;
115
+
116
+ animation: none;
117
+ }
118
+ }
119
+
120
+ // Same padding as the desktop sidebar at every width, instead of the
121
+ // drawer body's form spacing.
122
+ &[data-fs-bp-basic-drawer]
123
+ [data-fs-bp-suma-sidebar-drawer-body]
124
+ [data-fs-bp-basic-drawer-body-wrapper] {
125
+ padding: var(--fs-bp-padding-5);
126
+ }
127
+
128
+ // Mirrors the header's unit control, which the drawer covers.
129
+ [data-fs-bp-suma-sidebar-drawer-unit] {
130
+ display: flex;
131
+ align-items: center;
132
+ gap: var(--fs-bp-gap-2);
133
+ min-height: var(--fs-bp-spacing-9);
134
+ padding: var(--fs-bp-padding-0) var(--fs-bp-padding-5);
135
+ margin-bottom: var(--fs-bp-margin-5);
136
+
137
+ svg {
138
+ flex-shrink: 0;
139
+ color: var(--fs-bp-color-brand);
140
+ }
141
+ }
142
+
143
+ [data-fs-bp-suma-sidebar-drawer-unit-name] {
144
+ @include text-style('action');
145
+ min-width: 0;
146
+ overflow: hidden;
147
+ font-weight: var(--fs-bp-weight-medium);
148
+ color: var(--fs-bp-color-neutral-8);
149
+ text-overflow: ellipsis;
150
+ white-space: nowrap;
151
+ }
152
+
153
+ // Phones need the vertical space; the contract name alone identifies it.
154
+ [data-fs-bp-suma-sidebar-identity] [data-fs-bp-letter-highlight] {
155
+ display: none;
156
+ }
157
+
30
158
  // The sidebar is hidden below "notebook" so it can be toggled from the
31
159
  // navbar; force it visible here since the drawer is only rendered while open.
32
160
  [data-fs-bp-contract-listing-sidebar] {
@@ -31,13 +31,13 @@ const getRequestedEntries = (page: string): LocalizationFeature[] => {
31
31
  // Components rendered by a page resolve `t("<feature>.…")` keys from the entries
32
32
  // its loader requests. A shared component whose entry is not requested renders
33
33
  // the raw key (B2BTEAM-4276, B2BTEAM-4277).
34
+ // `/org-unit/[orgUnitId]` only redirects to the contracts listing and renders
35
+ // nothing, so it no longer requests `users`. See specs/sidebar-unification.md.
34
36
  const REQUIRED_ENTRIES: Record<string, LocalizationFeature[]> = {
35
37
  // Sidebar → AccountingFieldDropdown, CreateAccountingFieldDrawer
36
38
  profile: ["accountingFields"],
37
39
  // OrgUnitsDropdownMenu → CreateUserDrawerSelector → CreateUserDrawer*
38
40
  "org-units": ["users"],
39
- // AddAllToOrgUnitDropdown → CreateUserDrawerSelector → CreateUserDrawer*
40
- "org-unit-details": ["users"],
41
41
  };
42
42
 
43
43
  describe("page loaders request the localization entries their components use", () => {
@@ -10,7 +10,6 @@ export type VerticalNavTreeItemProps = {
10
10
  link?: string;
11
11
  submenu?: VerticalNavTreeProps;
12
12
  depth?: number;
13
- collapsible?: boolean;
14
13
  actions?: ReactNode | ReactNode[];
15
14
  hasNotification?: boolean;
16
15
  loading?: boolean;
@@ -0,0 +1,17 @@
1
+ import { describe, expect, it } from "vitest";
2
+
3
+ import { getDropdownAlign } from "../getDropdownAlign";
4
+
5
+ describe("getDropdownAlign", () => {
6
+ it("opens to the right when the trigger is on the left side", () => {
7
+ expect(getDropdownAlign({ left: 260, right: 292 }, 1440)).toBe("left");
8
+ });
9
+
10
+ it("opens to the left when the trigger is on the right side", () => {
11
+ expect(getDropdownAlign({ left: 1380, right: 1412 }, 1440)).toBe("right");
12
+ });
13
+
14
+ it("opens to the right when both sides have the same space", () => {
15
+ expect(getDropdownAlign({ left: 704, right: 736 }, 1440)).toBe("left");
16
+ });
17
+ });
@@ -41,3 +41,33 @@ describe("getSumaListingSidebarLinks (unit view)", () => {
41
41
  ).toBe("/pvt/organization-account/budgets/unit-1/contract-1");
42
42
  });
43
43
  });
44
+
45
+ describe("getSumaListingSidebarLinks (organizationContractId)", () => {
46
+ const links = getSumaListingSidebarLinks(
47
+ {
48
+ orgUnitId: "unit-1",
49
+ contractId: "contract-1",
50
+ organizationContractId: "contract-1",
51
+ },
52
+ t
53
+ );
54
+
55
+ it("adds the contractId to organization links when given", () => {
56
+ expect(links.find((l) => l.name === "layouts.navigation.users")?.link).toBe(
57
+ "/pvt/organization-account/users/unit-1?contractId=contract-1"
58
+ );
59
+ expect(
60
+ links.find((l) => l.name === "layouts.navigation.roles")?.link
61
+ ).toContain("contractId=contract-1");
62
+ expect(
63
+ links.find((l) => l.name === "layouts.navigation.organizationalUnits")
64
+ ?.link
65
+ ).toContain("contractId=contract-1");
66
+ });
67
+
68
+ it("keeps the Contracts link unit-scoped", () => {
69
+ expect(
70
+ links.find((l) => l.name === "layouts.navigation.contracts")?.link
71
+ ).toBe("/pvt/organization-account/contracts/unit-1");
72
+ });
73
+ });
@@ -0,0 +1,117 @@
1
+ import { describe, expect, it } from "vitest";
2
+
3
+ import { buyerPortalRoutes } from "../buyerPortalRoutes";
4
+ import { isNavLinkActive } from "../isNavLinkActive";
5
+
6
+ const orgUnitId = "unit-1";
7
+ const contractId = "contract-1";
8
+
9
+ describe("isNavLinkActive", () => {
10
+ it("is active on the link's own page", () => {
11
+ const link = buyerPortalRoutes.addresses({ orgUnitId, contractId });
12
+
13
+ expect(isNavLinkActive(link, link)).toBe(true);
14
+ });
15
+
16
+ it("keeps Addresses active on an address's details page", () => {
17
+ expect(
18
+ isNavLinkActive(
19
+ buyerPortalRoutes.addressDetails({
20
+ orgUnitId,
21
+ contractId,
22
+ addressId: "address-1",
23
+ }),
24
+ buyerPortalRoutes.addresses({ orgUnitId, contractId })
25
+ )
26
+ ).toBe(true);
27
+ });
28
+
29
+ it("keeps Users active on a user's details page", () => {
30
+ expect(
31
+ isNavLinkActive(
32
+ buyerPortalRoutes.userDetails({ orgUnitId, userId: "user-1" }),
33
+ buyerPortalRoutes.users({ orgUnitId, contractId })
34
+ )
35
+ ).toBe(true);
36
+ });
37
+
38
+ it("keeps Roles active on a role's details page", () => {
39
+ expect(
40
+ isNavLinkActive(
41
+ buyerPortalRoutes.roleDetails({ orgUnitId, roleName: "buyer" }),
42
+ buyerPortalRoutes.roles({ orgUnitId, contractId })
43
+ )
44
+ ).toBe(true);
45
+ });
46
+
47
+ it("keeps Buying policies active on a buying policy's details page", () => {
48
+ expect(
49
+ isNavLinkActive(
50
+ buyerPortalRoutes.buyingPolicyDetails({
51
+ orgUnitId,
52
+ contractId,
53
+ buyingPolicyId: "policy-1",
54
+ }),
55
+ buyerPortalRoutes.buyingPolicies({ orgUnitId, contractId })
56
+ )
57
+ ).toBe(true);
58
+ });
59
+
60
+ it("keeps Budgets active on a budget's details page", () => {
61
+ expect(
62
+ isNavLinkActive(
63
+ buyerPortalRoutes.budgetsDetails({
64
+ orgUnitId,
65
+ contractId,
66
+ budgetId: "budget-1",
67
+ }),
68
+ buyerPortalRoutes.budgets({ orgUnitId, contractId })
69
+ )
70
+ ).toBe(true);
71
+ });
72
+
73
+ it("keeps Contracts active on a contract's information page", () => {
74
+ expect(
75
+ isNavLinkActive(
76
+ buyerPortalRoutes.contractInformation({ orgUnitId, contractId }),
77
+ buyerPortalRoutes.contracts({ orgUnitId })
78
+ )
79
+ ).toBe(true);
80
+ });
81
+
82
+ it("ignores the query string on both sides", () => {
83
+ expect(
84
+ isNavLinkActive(
85
+ `${buyerPortalRoutes.users({ orgUnitId })}?page=2`,
86
+ buyerPortalRoutes.users({ orgUnitId, contractId })
87
+ )
88
+ ).toBe(true);
89
+ });
90
+
91
+ it("does not activate a link from another org unit", () => {
92
+ expect(
93
+ isNavLinkActive(
94
+ buyerPortalRoutes.userDetails({ orgUnitId: "unit-2", userId: "u" }),
95
+ buyerPortalRoutes.users({ orgUnitId })
96
+ )
97
+ ).toBe(false);
98
+ });
99
+
100
+ it("does not activate Organizational units on a unit's home page", () => {
101
+ expect(
102
+ isNavLinkActive(
103
+ buyerPortalRoutes.orgUnitDetails({ orgUnitId }),
104
+ buyerPortalRoutes.orgUnits({ orgUnitId })
105
+ )
106
+ ).toBe(false);
107
+ });
108
+
109
+ it("does not activate a link that only shares a prefix", () => {
110
+ expect(
111
+ isNavLinkActive(
112
+ buyerPortalRoutes.addresses({ orgUnitId, contractId: "contract-10" }),
113
+ buyerPortalRoutes.addresses({ orgUnitId, contractId })
114
+ )
115
+ ).toBe(false);
116
+ });
117
+ });
@@ -6,7 +6,7 @@ import {
6
6
  } from "../routeLayoutMapping";
7
7
 
8
8
  describe("routeLayoutMapping", () => {
9
- it("maps the SUMA contracts listing to its own loading layout", () => {
9
+ it("maps the contracts listing to its own loading layout", () => {
10
10
  const config = getTabsLayoutConfigFromRoute(
11
11
  "/pvt/organization-account/contracts/unit-1?removed=2"
12
12
  );
@@ -17,6 +17,13 @@ describe("routeLayoutMapping", () => {
17
17
  ).toEqual({ orgUnitId: "unit-1" });
18
18
  });
19
19
 
20
+ it("shows the contracts listing skeleton for a unit's home redirect", () => {
21
+ expect(
22
+ getTabsLayoutConfigFromRoute("/pvt/organization-account/org-unit/unit-1")
23
+ ?.layout
24
+ ).toBe("ContractListingLayout");
25
+ });
26
+
20
27
  it("keeps contract pages on the contract tabs layout", () => {
21
28
  expect(
22
29
  getTabsLayoutConfigFromRoute(
@@ -25,6 +32,19 @@ describe("routeLayoutMapping", () => {
25
32
  ).toBe("ContractTabsLayout");
26
33
  });
27
34
 
35
+ it.each([
36
+ ["users/unit-1", "OrgUnitTabsLayout"],
37
+ ["user/unit-1/user-1", "OrgUnitTabsLayout"],
38
+ ["roles/unit-1/role-1", "OrgUnitTabsLayout"],
39
+ ["budgets/unit-1/contract-1", "FinanceTabsLayout"],
40
+ ["budgets/unit-1/contract-1/budget-1", "FinanceTabsLayout"],
41
+ ["buying-policy/unit-1/contract-1/policy-1", "FinanceTabsLayout"],
42
+ ])("keeps the unit page %s on a unit view layout", (path, layout) => {
43
+ expect(
44
+ getTabsLayoutConfigFromRoute(`/pvt/organization-account/${path}`)?.layout
45
+ ).toBe(layout);
46
+ });
47
+
28
48
  it("returns null for unmapped routes", () => {
29
49
  expect(
30
50
  getTabsLayoutConfigFromRoute("/pvt/organization-account/unknown")
@@ -33,4 +33,4 @@ export const STOREFRONT_RESOURCE_NAMES = {
33
33
  export type StorefrontResourceName =
34
34
  (typeof STOREFRONT_RESOURCE_NAMES)[keyof typeof STOREFRONT_RESOURCE_NAMES];
35
35
 
36
- export const CURRENT_VERSION = "2.0.47";
36
+ export const CURRENT_VERSION = "2.0.49";
@@ -0,0 +1,11 @@
1
+ export type DropdownAlign = "left" | "right";
2
+
3
+ /**
4
+ * FastStore's `align="left"` pins the menu's left edge to the trigger, so the
5
+ * menu grows to the right (and `"right"` grows to the left). Picks the side
6
+ * with more room; ties go to the right.
7
+ */
8
+ export const getDropdownAlign = (
9
+ { left, right }: Pick<DOMRect, "left" | "right">,
10
+ viewportWidth: number
11
+ ): DropdownAlign => (viewportWidth - right >= left ? "left" : "right");
@@ -8,9 +8,12 @@ export const getSumaListingSidebarLinks = (
8
8
  {
9
9
  orgUnitId,
10
10
  contractId,
11
+ organizationContractId,
11
12
  }: {
12
13
  orgUnitId: string;
13
14
  contractId: string;
15
+ /** `contractId` for the Organization links; omitted under SUMA. */
16
+ organizationContractId?: string;
14
17
  },
15
18
  t: LocalizeFn
16
19
  ) => [
@@ -18,6 +21,10 @@ export const getSumaListingSidebarLinks = (
18
21
  name: t("layouts.navigation.contracts"),
19
22
  link: buyerPortalRoutes.contracts({ orgUnitId }),
20
23
  },
21
- ...getOrganizationSettingsLinks({ orgUnitId, t }),
24
+ ...getOrganizationSettingsLinks({
25
+ orgUnitId,
26
+ contractId: organizationContractId,
27
+ t,
28
+ }),
22
29
  ...getFinanceSettingsLinks({ orgUnitId, contractId }, t),
23
30
  ];
@@ -0,0 +1,40 @@
1
+ const base = "/pvt/organization-account";
2
+
3
+ /**
4
+ * Detail routes whose first segment differs from their listing's
5
+ * (`/address/...` vs `/addresses/...`). `org-unit` is left out on purpose:
6
+ * `/org-unit/[orgUnitId]` is a unit's home page, not an item of the
7
+ * Organizational units list.
8
+ */
9
+ const DETAIL_TO_LISTING_SEGMENT: Record<string, string> = {
10
+ address: "addresses",
11
+ user: "users",
12
+ "buying-policy": "buying-policies",
13
+ "contract-information": "contracts",
14
+ };
15
+
16
+ const stripQuery = (path: string) => path.split(/[?#]/)[0];
17
+
18
+ const toListingPath = (path: string) => {
19
+ if (!path.startsWith(`${base}/`)) return path;
20
+
21
+ const [segment, ...rest] = path.slice(base.length + 1).split("/");
22
+ const listingSegment = DETAIL_TO_LISTING_SEGMENT[segment];
23
+
24
+ return listingSegment
25
+ ? [`${base}/${listingSegment}`, ...rest].join("/")
26
+ : path;
27
+ };
28
+
29
+ /**
30
+ * A sidebar link stays active on its own page and on every page inside it
31
+ * (e.g. Addresses on an address's details page), whatever the query string.
32
+ */
33
+ export const isNavLinkActive = (asPath: string, link: string) => {
34
+ const normalizedLink = stripQuery(
35
+ link.startsWith("/") ? link : link.slice(0, -1)
36
+ );
37
+ const path = toListingPath(stripQuery(asPath));
38
+
39
+ return path === normalizedLink || path.startsWith(`${normalizedLink}/`);
40
+ };
@@ -49,6 +49,18 @@ export const ROUTE_TABS_LAYOUT_MAPPING: Record<string, RouteTabsLayoutConfig> =
49
49
  pageName: "layouts.tabs.contract",
50
50
  pageTitle: "layouts.titles.accountingField",
51
51
  },
52
+ // Budgets have no own title key in the shared entry, so the skeleton and
53
+ // error states use the sidebar label.
54
+ "/pvt/organization-account/budgets/[orgUnitId]/[contractId]": {
55
+ layout: "FinanceTabsLayout",
56
+ pageName: "layouts.tabs.financeAndCompliance",
57
+ pageTitle: "layouts.navigation.budgets",
58
+ },
59
+ "/pvt/organization-account/budgets/[orgUnitId]/[contractId]/[budgetId]": {
60
+ layout: "FinanceTabsLayout",
61
+ pageName: "layouts.tabs.financeAndCompliance",
62
+ pageTitle: "layouts.navigation.budgets",
63
+ },
52
64
  "/pvt/organization-account/buying-policies/[orgUnitId]/[contractId]": {
53
65
  layout: "FinanceTabsLayout",
54
66
  pageName: "layouts.tabs.financeAndCompliance",
@@ -86,12 +98,13 @@ export const ROUTE_TABS_LAYOUT_MAPPING: Record<string, RouteTabsLayoutConfig> =
86
98
  pageName: "layouts.tabs.organization",
87
99
  pageTitle: "layouts.titles.organizationDetails",
88
100
  },
101
+ // Redirects to the unit's Contracts listing, so it shows that skeleton.
89
102
  "/pvt/organization-account/org-unit/[orgUnitId]": {
90
- layout: "OrgUnitDetailsLayout",
91
- pageName: "layouts.tabs.organization",
92
- pageTitle: "layouts.titles.organizationDetails",
103
+ layout: "ContractListingLayout",
104
+ pageName: "layouts.navigation.contracts",
105
+ pageTitle: "layouts.navigation.contracts",
93
106
  },
94
- // SUMA unit landing page: same skeleton shape as the destination listing,
107
+ // Unit landing page: same skeleton shape as the destination listing,
95
108
  // so going back from a contract page is not a blank frame.
96
109
  "/pvt/organization-account/contracts/[orgUnitId]": {
97
110
  layout: "ContractListingLayout",
@@ -19,7 +19,6 @@ import {
19
19
  usePageItems,
20
20
  } from "../../../shared/hooks";
21
21
  import { GlobalLayout } from "../../../shared/layouts";
22
- import { OrgUnitTabsLayout } from "../../../shared/layouts/OrgUnitTabsLayout/OrgUnitTabLayout";
23
22
  import { SumaPageLayout } from "../../../shared/layouts/SumaPageLayout/SumaPageLayout";
24
23
  import { useLocalization } from "../../../shared/localization/LocalizationContext";
25
24
  import { buyerPortalRoutes } from "../../../shared/utils/buyerPortalRoutes";
@@ -55,7 +54,7 @@ export const UsersLayout = ({
55
54
  page,
56
55
  });
57
56
 
58
- const { currentOrgUnit, featureFlags } = useBuyerPortal();
57
+ const { currentOrgUnit } = useBuyerPortal();
59
58
  const { t } = useLocalization();
60
59
 
61
60
  const {
@@ -246,13 +245,7 @@ export const UsersLayout = ({
246
245
 
247
246
  return (
248
247
  <GlobalLayout>
249
- {featureFlags?.suma ? (
250
- <SumaPageLayout>{usersSection}</SumaPageLayout>
251
- ) : (
252
- <OrgUnitTabsLayout pageName={t("shared.navigation.organization")}>
253
- {usersSection}
254
- </OrgUnitTabsLayout>
255
- )}
248
+ <SumaPageLayout>{usersSection}</SumaPageLayout>
256
249
  </GlobalLayout>
257
250
  );
258
251
  };
@@ -56,7 +56,7 @@ const loaderFunction = async (
56
56
 
57
57
  if (!featureFlags?.suma) {
58
58
  data.res?.writeHead(302, {
59
- Location: buyerPortalRoutes.orgUnitDetails({ orgUnitId }),
59
+ Location: buyerPortalRoutes.contracts({ orgUnitId }),
60
60
  });
61
61
  data.res?.end();
62
62
 
@@ -11,7 +11,6 @@ import {
11
11
  withAuthLoader,
12
12
  withProviders,
13
13
  } from "../features/shared/utils";
14
- import { buyerPortalRoutes } from "../features/shared/utils/buyerPortalRoutes";
15
14
  import { getUserByIdService } from "../features/users/services";
16
15
 
17
16
  import type { ContractData } from "../features/contracts/types";
@@ -51,51 +50,37 @@ const loaderFunction = async (
51
50
  throw new Error(`Missing required query param: orgUnitId=${orgUnitId}`);
52
51
  }
53
52
 
54
- return withAuthLoader(
55
- data,
56
- async ({ cookie, userId, featureFlagsPromise, ...clientContext }) => {
57
- const featureFlags = await featureFlagsPromise;
53
+ return withAuthLoader(data, async ({ cookie, userId, ...clientContext }) => {
54
+ const [orgUnit, contracts, user, localizationLabels] = await Promise.all([
55
+ getOrgUnitBasicDataService({ id: orgUnitId, cookie }),
56
+ listUnitContractsService({ orgUnitId, cookie }),
57
+ getUserByIdService({ orgUnitId, userId, cookie }),
58
+ getLocalizationLabelsService({
59
+ entryIds: [
60
+ LOCALIZATION_ENTRY_IDS.contracts,
61
+ LOCALIZATION_ENTRY_IDS.orgUnits,
62
+ LOCALIZATION_ENTRY_IDS.addresses,
63
+ LOCALIZATION_ENTRY_IDS.accountingFields,
64
+ ],
65
+ locale: data.locale,
66
+ }),
67
+ ]);
58
68
 
59
- if (!featureFlags?.suma) {
60
- data.res?.writeHead(302, {
61
- Location: buyerPortalRoutes.orgUnitDetails({ orgUnitId }),
62
- });
63
- data.res?.end();
64
-
65
- return { redirected: true } as unknown as ContractsPageData;
66
- }
67
-
68
- const [orgUnit, contracts, user, localizationLabels] = await Promise.all([
69
- getOrgUnitBasicDataService({ id: orgUnitId, cookie }),
70
- listUnitContractsService({ orgUnitId, cookie }),
71
- getUserByIdService({ orgUnitId, userId, cookie }),
72
- getLocalizationLabelsService({
73
- entryIds: [
74
- LOCALIZATION_ENTRY_IDS.contracts,
75
- LOCALIZATION_ENTRY_IDS.orgUnits,
76
- LOCALIZATION_ENTRY_IDS.addresses,
77
- LOCALIZATION_ENTRY_IDS.accountingFields,
78
- ],
79
- locale: data.locale,
80
- }),
81
- ]);
82
-
83
- return {
84
- data: {
85
- orgUnit,
86
- contracts: contracts ?? [],
87
- user,
88
- },
89
- context: {
90
- clientContext: { cookie, userId, ...clientContext },
91
- localization: { labels: localizationLabels },
92
- // Feeds the SUMA header unit control and the sidebar identity block.
93
- currentOrgUnit: orgUnit,
94
- currentUser: user,
95
- },
96
- };
97
- }
98
- );
69
+ return {
70
+ data: {
71
+ orgUnit,
72
+ contracts: contracts ?? [],
73
+ user,
74
+ },
75
+ context: {
76
+ clientContext: { cookie, userId, ...clientContext },
77
+ localization: { labels: localizationLabels },
78
+ // Feeds the header unit control and the sidebar identity block.
79
+ currentOrgUnit: orgUnit,
80
+ currentUser: user,
81
+ },
82
+ };
83
+ });
99
84
  };
100
85
 
101
86
  export const loader = withLoaderErrorBoundary(loaderFunction, {