@vtex/faststore-plugin-buyer-portal 2.0.48 → 2.0.50

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 (77) hide show
  1. package/package.json +1 -1
  2. package/public/buyer-portal-icons.svg +9 -0
  3. package/src/features/accounting-fields/hooks/useListAccountingFields.ts +2 -1
  4. package/src/features/addresses/components/AddressLine/AddressLine.tsx +3 -6
  5. package/src/features/budgets/layouts/BudgetsDetailsLayout/BudgetsDetailsLayout.tsx +4 -9
  6. package/src/features/budgets/layouts/BudgetsLayout/BudgetsLayout.tsx +2 -9
  7. package/src/features/buying-policies/layouts/BuyingPoliciesLayout/BuyingPoliciesLayout.tsx +14 -31
  8. package/src/features/contracts/components/ContractListItem/ContractListItem.tsx +0 -5
  9. package/src/features/contracts/components/index.ts +0 -2
  10. package/src/features/contracts/hooks/useSwitchContract.ts +13 -5
  11. package/src/features/contracts/layouts/ContractListingLayout/ContractListingLayout.tsx +8 -1
  12. package/src/features/contracts/layouts/ContractListingLayout/ContractSettingsNav.tsx +39 -63
  13. package/src/features/contracts/layouts/ContractListingLayout/__tests__/utils.test.ts +51 -0
  14. package/src/features/contracts/layouts/ContractListingLayout/contract-listing-layout.scss +36 -10
  15. package/src/features/contracts/layouts/ContractListingLayout/utils.ts +53 -0
  16. package/src/features/org-units/components/CreateOrgUnitDrawer/CreateOrgUnitDrawer.tsx +4 -2
  17. package/src/features/org-units/components/DeleteOrgUnitDrawer/DeleteOrgUnitDrawer.tsx +6 -2
  18. package/src/features/org-units/components/OrgUnitBreadcrumb/OrgUnitBreadcrumbLink.tsx +3 -4
  19. package/src/features/org-units/components/OrgUnitDetailsNavbar/OrgUnitDetailsNavbar.tsx +86 -4
  20. package/src/features/org-units/components/OrgUnitHeaderNav/OrgUnitHeaderNav.tsx +13 -2
  21. package/src/features/org-units/components/OrgUnitsHierarchyTree/OrgUnitsHierarchyTree.tsx +18 -10
  22. package/src/features/org-units/components/UpdateOrgUnitDrawer/UpdateOrgUnitDrawer.tsx +4 -2
  23. package/src/features/org-units/hooks/useOrgUnitByUser.ts +2 -0
  24. package/src/features/org-units/layouts/OrgUnitsLayout/OrgUnitsLayout.tsx +2 -9
  25. package/src/features/roles/layout/RolesLayout/RolesLayout.tsx +2 -9
  26. package/src/features/shared/components/BasicCard/BasicCard.tsx +6 -3
  27. package/src/features/shared/components/BasicCard/BasicCardLine.tsx +3 -5
  28. package/src/features/shared/components/BasicDrawer/BasicDrawer.tsx +3 -2
  29. package/src/features/shared/components/BasicDrawer/BasicDrawerHeading.tsx +4 -1
  30. package/src/features/shared/components/BuyerPortalProvider/BuyerPortalProvider.tsx +2 -0
  31. package/src/features/shared/components/HeaderInside/HeaderInside.tsx +2 -5
  32. package/src/features/shared/components/InternalTopbar/InternalTopbar.tsx +3 -4
  33. package/src/features/shared/components/PageLoadingIndicator/PageLoadingIndicator.tsx +129 -0
  34. package/src/features/shared/components/PageLoadingIndicator/page-loading-indicator.scss +49 -0
  35. package/src/features/shared/components/Table/TableRow/TableRow.tsx +2 -5
  36. package/src/features/shared/components/VerticalNav/VerticalNavLink.tsx +11 -10
  37. package/src/features/shared/hooks/index.ts +3 -0
  38. package/src/features/shared/hooks/useDisplayedOrgUnitName.ts +12 -0
  39. package/src/features/shared/hooks/useDrawerProps.ts +17 -4
  40. package/src/features/shared/hooks/usePageItems.ts +7 -1
  41. package/src/features/shared/hooks/usePageLoading.ts +11 -0
  42. package/src/features/shared/hooks/useQuery.ts +62 -20
  43. package/src/features/shared/hooks/useShellScrollReset.ts +27 -0
  44. package/src/features/shared/layouts/ContractTabsLayout/ContractTabsLayout.tsx +26 -65
  45. package/src/features/shared/layouts/FinanceTabsLayout/FinanceTabsLayout.tsx +4 -41
  46. package/src/features/shared/layouts/GlobalLayout/global-layout.scss +1 -0
  47. package/src/features/shared/layouts/LoadingTabsLayout/LoadingTabsLayout.tsx +5 -2
  48. package/src/features/shared/layouts/OrgUnitTabsLayout/OrgUnitTabLayout.tsx +4 -39
  49. package/src/features/shared/layouts/SumaPageLayout/SumaPageLayout.tsx +11 -5
  50. package/src/features/shared/layouts/SumaPageLayout/SumaSidebar.tsx +17 -8
  51. package/src/features/shared/layouts/SumaPageLayout/SumaSidebarDrawer.tsx +44 -2
  52. package/src/features/shared/layouts/SumaPageLayout/suma-sidebar-drawer.scss +147 -5
  53. package/src/features/shared/localization/__tests__/page-loader-entries.test.ts +2 -2
  54. package/src/features/shared/utils/__tests__/getRouteKey.test.ts +29 -0
  55. package/src/features/shared/utils/__tests__/getSumaListingSidebarLinks.test.ts +30 -0
  56. package/src/features/shared/utils/__tests__/routeLayoutMapping.test.ts +21 -1
  57. package/src/features/shared/utils/constants.ts +1 -1
  58. package/src/features/shared/utils/getRouteKey.ts +4 -0
  59. package/src/features/shared/utils/getSumaListingSidebarLinks.ts +8 -1
  60. package/src/features/shared/utils/pageLoading/__tests__/keptSidebarDrawer.test.ts +170 -0
  61. package/src/features/shared/utils/pageLoading/__tests__/navigationLevel.test.ts +107 -0
  62. package/src/features/shared/utils/pageLoading/__tests__/orgUnitNames.test.ts +60 -0
  63. package/src/features/shared/utils/pageLoading/__tests__/pageLoadingStore.test.ts +266 -0
  64. package/src/features/shared/utils/pageLoading/keptSidebarDrawer.ts +133 -0
  65. package/src/features/shared/utils/pageLoading/navigationLevel.ts +89 -0
  66. package/src/features/shared/utils/pageLoading/orgUnitNames.ts +49 -0
  67. package/src/features/shared/utils/pageLoading/pageLoadingStore.ts +277 -0
  68. package/src/features/shared/utils/routeLayoutMapping.ts +17 -4
  69. package/src/features/shared/utils/withProviders.tsx +5 -1
  70. package/src/features/shared/utils/withRouteKey.ts +23 -0
  71. package/src/features/users/layouts/UsersLayout/UsersLayout.tsx +2 -9
  72. package/src/pages/contract-information.tsx +1 -1
  73. package/src/pages/contracts.tsx +30 -45
  74. package/src/pages/home.tsx +17 -25
  75. package/src/pages/org-unit-details.tsx +15 -102
  76. package/src/features/contracts/components/ContractSwitchOverlay/ContractSwitchOverlay.tsx +0 -47
  77. package/src/features/contracts/components/ContractSwitchOverlay/contract-switch-overlay.scss +0 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vtex/faststore-plugin-buyer-portal",
3
- "version": "2.0.48",
3
+ "version": "2.0.50",
4
4
  "description": "A plugin for faststore with buyer portal",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -261,6 +261,15 @@
261
261
  fill="currentColor" />
262
262
  </symbol>
263
263
 
264
+ <symbol
265
+ id="CloseSymbol"
266
+ xmlns="http://www.w3.org/2000/svg"
267
+ viewBox="0 -960 960 960"
268
+ fill="currentColor">
269
+ <path
270
+ d="m256-200-56-56 224-224-224-224 56-56 224 224 224-224 56 56-224 224 224 224-56 56-224-224-224 224Z" />
271
+ </symbol>
272
+
264
273
  <symbol
265
274
  id="OpenInNew"
266
275
  xmlns="http://www.w3.org/2000/svg"
@@ -14,7 +14,8 @@ export const useListAccountingFields = (
14
14
  orgUnitId,
15
15
  cookie,
16
16
  }),
17
- options
17
+ // The contract sidebar shows the fields on every contract page.
18
+ { cache: true, ...options }
18
19
  );
19
20
 
20
21
  return {
@@ -1,5 +1,5 @@
1
- import { useLink_unstable as useLink } from "@faststore/core/experimental";
2
- import { Dropdown, Link } from "@faststore/ui";
1
+ import { Link_unstable as Link } from "@faststore/core/experimental";
2
+ import { Dropdown } from "@faststore/ui";
3
3
 
4
4
  import { AddressDropdownMenu } from "..";
5
5
  import { BasicDropdownMenu, Icon, Tag } from "../../../shared/components";
@@ -21,12 +21,9 @@ export const AddressLine = ({
21
21
  href,
22
22
  currentAddress,
23
23
  }: AddressLineProps) => {
24
- const { resolveLink } = useLink();
25
- const resolvedHref = resolveLink(href);
26
-
27
24
  return (
28
25
  <li data-fs-addresses-line>
29
- <Link href={resolvedHref} data-fs-addresses-line-link>
26
+ <Link href={href} data-fs-addresses-line-link>
30
27
  <Icon
31
28
  name="LocalPostOffice"
32
29
  width={20}
@@ -12,7 +12,8 @@ import {
12
12
  useDebounce,
13
13
  useDrawerProps,
14
14
  } from "../../../shared/hooks";
15
- import { ContractTabsLayout, GlobalLayout } from "../../../shared/layouts";
15
+ import { GlobalLayout } from "../../../shared/layouts";
16
+ import { SumaPageLayout } from "../../../shared/layouts/SumaPageLayout/SumaPageLayout";
16
17
  import { useLocalization } from "../../../shared/localization/LocalizationContext";
17
18
  import { buyerPortalRoutes } from "../../../shared/utils/buyerPortalRoutes";
18
19
  import { BudgetAllocationsTable } from "../../components/BudgetAllocationsTable/BudgetAllocationsTable";
@@ -141,13 +142,7 @@ export const BudgetsDetailsLayout = ({ budget }: BudgetsDetailsLayoutProps) => {
141
142
 
142
143
  return (
143
144
  <GlobalLayout>
144
- <ContractTabsLayout
145
- orgUnitName={orgUnit?.name ?? ""}
146
- orgUnitId={orgUnit?.id ?? ""}
147
- contractName={contract?.name ?? ""}
148
- contractId={contract?.id ?? ""}
149
- pageName={t("budgets.titles.budgets")}
150
- >
145
+ <SumaPageLayout>
151
146
  <div data-fs-bp-budgets-details-layout>
152
147
  <header data-fs-bp-budgets-details-header-wrapper>
153
148
  <div data-fs-bp-budgets-details-header-arrow>
@@ -268,7 +263,7 @@ export const BudgetsDetailsLayout = ({ budget }: BudgetsDetailsLayoutProps) => {
268
263
  )}
269
264
  </section>
270
265
  </div>
271
- </ContractTabsLayout>
266
+ </SumaPageLayout>
272
267
  </GlobalLayout>
273
268
  );
274
269
  };
@@ -8,7 +8,7 @@ import {
8
8
  useDrawerProps,
9
9
  useQueryParams,
10
10
  } from "../../../shared/hooks";
11
- import { FinanceTabsLayout, GlobalLayout } from "../../../shared/layouts";
11
+ import { GlobalLayout } from "../../../shared/layouts";
12
12
  import { SumaPageLayout } from "../../../shared/layouts/SumaPageLayout/SumaPageLayout";
13
13
  import { useLocalization } from "../../../shared/localization/LocalizationContext";
14
14
  import { BudgetDeleteDrawer } from "../../components/BudgetDeleteDrawer/BudgetDeleteDrawer";
@@ -39,7 +39,6 @@ export const BudgetsLayout = ({ data }: BudgetsLayoutProps) => {
39
39
  clientContext: { cookie },
40
40
  currentOrgUnit: orgUnit,
41
41
  currentContract: contract,
42
- featureFlags,
43
42
  } = useBuyerPortal();
44
43
  const [paginationLoading, setPaginationLoading] = useState<boolean>(false);
45
44
  const [loading, setLoading] = useState<boolean>(false);
@@ -276,13 +275,7 @@ export const BudgetsLayout = ({ data }: BudgetsLayoutProps) => {
276
275
 
277
276
  return (
278
277
  <GlobalLayout>
279
- {featureFlags?.suma ? (
280
- <SumaPageLayout>{budgetsSection}</SumaPageLayout>
281
- ) : (
282
- <FinanceTabsLayout pageName={t("budgets.titles.financeAndCompliance")}>
283
- {budgetsSection}
284
- </FinanceTabsLayout>
285
- )}
278
+ <SumaPageLayout>{budgetsSection}</SumaPageLayout>
286
279
  </GlobalLayout>
287
280
  );
288
281
  };
@@ -15,7 +15,7 @@ import {
15
15
  useBuyerPortal,
16
16
  useDrawerProps,
17
17
  } from "../../../shared/hooks";
18
- import { FinanceTabsLayout, GlobalLayout } from "../../../shared/layouts";
18
+ import { GlobalLayout } from "../../../shared/layouts";
19
19
  import { SumaPageLayout } from "../../../shared/layouts/SumaPageLayout/SumaPageLayout";
20
20
  import { useLocalization } from "../../../shared/localization/LocalizationContext";
21
21
  import { buyerPortalRoutes } from "../../../shared/utils/buyerPortalRoutes";
@@ -37,7 +37,7 @@ export const BuyingPoliciesLayout = ({
37
37
  search,
38
38
  page,
39
39
  }: BuyingPoliciesLayoutProps) => {
40
- const { currentContract, currentOrgUnit, featureFlags } = useBuyerPortal();
40
+ const { currentContract, currentOrgUnit } = useBuyerPortal();
41
41
  const { t } = useLocalization();
42
42
 
43
43
  const router = useRouter();
@@ -183,35 +183,18 @@ export const BuyingPoliciesLayout = ({
183
183
 
184
184
  return (
185
185
  <GlobalLayout>
186
- {featureFlags?.suma ? (
187
- <SumaPageLayout>
188
- {buyingPoliciesSection}
189
- {isAddBuyingPolicyDrawerOpen && (
190
- <AddBuyingPolicyDrawer
191
- orgUnitId={currentOrgUnit?.id ?? ""}
192
- contractId={currentContract?.id ?? ""}
193
- isOpen={isAddBuyingPolicyDrawerOpen}
194
- onCreate={handleRefetchBuyingPolicies}
195
- {...addBuyingPolicyDrawerProps}
196
- />
197
- )}
198
- </SumaPageLayout>
199
- ) : (
200
- <FinanceTabsLayout
201
- pageName={t("buyingPolicies.titles.financeAndCompliance")}
202
- >
203
- {buyingPoliciesSection}
204
- {isAddBuyingPolicyDrawerOpen && (
205
- <AddBuyingPolicyDrawer
206
- orgUnitId={currentOrgUnit?.id ?? ""}
207
- contractId={currentContract?.id ?? ""}
208
- isOpen={isAddBuyingPolicyDrawerOpen}
209
- onCreate={handleRefetchBuyingPolicies}
210
- {...addBuyingPolicyDrawerProps}
211
- />
212
- )}
213
- </FinanceTabsLayout>
214
- )}
186
+ <SumaPageLayout>
187
+ {buyingPoliciesSection}
188
+ {isAddBuyingPolicyDrawerOpen && (
189
+ <AddBuyingPolicyDrawer
190
+ orgUnitId={currentOrgUnit?.id ?? ""}
191
+ contractId={currentContract?.id ?? ""}
192
+ isOpen={isAddBuyingPolicyDrawerOpen}
193
+ onCreate={handleRefetchBuyingPolicies}
194
+ {...addBuyingPolicyDrawerProps}
195
+ />
196
+ )}
197
+ </SumaPageLayout>
215
198
  </GlobalLayout>
216
199
  );
217
200
  };
@@ -4,7 +4,6 @@ import { BasicDropdownMenu, LetterHighlight } from "../../../shared/components";
4
4
  import Icon from "../../../shared/components/Icon/Icon";
5
5
  import { useLocalization } from "../../../shared/localization/LocalizationContext";
6
6
  import { useSwitchContract } from "../../hooks";
7
- import { ContractSwitchOverlay } from "../ContractSwitchOverlay/ContractSwitchOverlay";
8
7
 
9
8
  import { getContractMenuState } from "./contractListItemMenu";
10
9
 
@@ -128,10 +127,6 @@ export const ContractListItem = ({
128
127
  </BasicDropdownMenu>
129
128
  </Dropdown>
130
129
  </div>
131
-
132
- {loading && (
133
- <ContractSwitchOverlay orgUnitId={orgUnitId} contractId={contract.id} />
134
- )}
135
130
  </div>
136
131
  );
137
132
  };
@@ -9,8 +9,6 @@ export { ConfirmRemoveDrawer } from "./ConfirmRemoveDrawer/ConfirmRemoveDrawer";
9
9
  export type { ConfirmRemoveDrawerProps } from "./ConfirmRemoveDrawer/ConfirmRemoveDrawer";
10
10
  export { ErrorRemoveDrawer } from "./ErrorRemoveDrawer/ErrorRemoveDrawer";
11
11
  export type { ErrorRemoveDrawerProps } from "./ErrorRemoveDrawer/ErrorRemoveDrawer";
12
- export { ContractSwitchOverlay } from "./ContractSwitchOverlay/ContractSwitchOverlay";
13
- export type { ContractSwitchOverlayProps } from "./ContractSwitchOverlay/ContractSwitchOverlay";
14
12
  export { UnableToRemoveContractsDrawer } from "./UnableToRemoveContractsDrawer/UnableToRemoveContractsDrawer";
15
13
  export type { UnableToRemoveContractsDrawerProps } from "./UnableToRemoveContractsDrawer/UnableToRemoveContractsDrawer";
16
14
  export { AddContractsDrawer } from "./AddContractsDrawer/AddContractsDrawer";
@@ -1,5 +1,6 @@
1
1
  import { useState } from "react";
2
2
 
3
+ import { pageLoadingStore } from "../../shared/utils/pageLoading/pageLoadingStore";
3
4
  import {
4
5
  ContractSwitchError,
5
6
  changeContractToken,
@@ -43,8 +44,17 @@ export function useSwitchContract(): UseSwitchContractReturn {
43
44
  contractId: string,
44
45
  { orgUnitId, redirectTo }: SwitchContractParams
45
46
  ): Promise<boolean> => {
47
+ const redirect = resolveSwitchRedirect({
48
+ orgUnitId,
49
+ contractId,
50
+ redirectTo,
51
+ });
52
+
46
53
  setLoading(true);
47
54
  setError(null);
55
+ // The page loading bar covers the switch and the full page load after it,
56
+ // so the next page shows once, when it's ready.
57
+ pageLoadingStore.startFullLoad(redirect);
48
58
 
49
59
  try {
50
60
  await changeContractToken(contractId);
@@ -53,14 +63,11 @@ export function useSwitchContract(): UseSwitchContractReturn {
53
63
  broadcast({ type: "contract-activated", contractId });
54
64
 
55
65
  if (typeof window !== "undefined") {
56
- window.location.assign(
57
- resolveSwitchRedirect({ orgUnitId, contractId, redirectTo })
58
- );
66
+ window.location.assign(redirect);
59
67
  }
60
68
 
61
69
  // Keep `loading` true: navigation is in flight and the page will be torn
62
- // down. Resetting here would flash the switch overlay off before the new
63
- // contract context loads.
70
+ // down.
64
71
  return true;
65
72
  } catch (err) {
66
73
  const normalized =
@@ -69,6 +76,7 @@ export function useSwitchContract(): UseSwitchContractReturn {
69
76
  : new ContractSwitchError("Failed to switch contract");
70
77
  setError(normalized);
71
78
  setLoading(false);
79
+ pageLoadingStore.fail();
72
80
 
73
81
  return false;
74
82
  }
@@ -19,6 +19,7 @@ import {
19
19
  useBuyerPortal,
20
20
  useRefreshPageData,
21
21
  useReloadOnBfcacheRestore,
22
+ useShellScrollReset,
22
23
  } from "../../../shared/hooks";
23
24
  import { GlobalLayout } from "../../../shared/layouts";
24
25
  import { SumaSidebar } from "../../../shared/layouts/SumaPageLayout/SumaSidebar";
@@ -113,6 +114,7 @@ export const ContractListingLayout = ({
113
114
  } = useDrawerProps();
114
115
 
115
116
  const { featureFlags, clientContext } = useBuyerPortal();
117
+ const sectionRef = useShellScrollReset();
116
118
  const { switchContract } = useSwitchContract();
117
119
 
118
120
  const {
@@ -368,6 +370,7 @@ export const ContractListingLayout = ({
368
370
  }}
369
371
  loading={loading}
370
372
  sidebarVariant="unit"
373
+ sidebarContractId={defaultContractId}
371
374
  />
372
375
  <div data-fs-bp-contract-listing-body>
373
376
  <SumaSidebar
@@ -376,7 +379,11 @@ export const ContractListingLayout = ({
376
379
  variant="unit"
377
380
  />
378
381
 
379
- <section data-fs-bp-contract-listing-section aria-busy={isBusy}>
382
+ <section
383
+ data-fs-bp-contract-listing-section
384
+ aria-busy={isBusy}
385
+ ref={sectionRef}
386
+ >
380
387
  <HeaderInside
381
388
  title={loading ? undefined : t("contracts.titles.contracts")}
382
389
  info={loading ? undefined : headerInfo}
@@ -6,6 +6,8 @@ import { Icon } from "../../../shared/components";
6
6
  import { buyerPortalRoutes } from "../../../shared/utils/buyerPortalRoutes";
7
7
  import { contractScopedLink } from "../../../shared/utils/contractScopedLink";
8
8
 
9
+ import { getContractCardLinks } from "./utils";
10
+
9
11
  import type { AccountingField } from "../../../accounting-fields/types";
10
12
  import type { FeatureFlags } from "../../../shared/components/BuyerPortalProvider/BuyerPortalProvider";
11
13
  import type { LocalizeFn } from "../../../shared/localization/types";
@@ -36,71 +38,45 @@ export const buildContractSettingsNavItems = ({
36
38
  }: BuildContractSettingsNavItemsParams): VerticalNavTreeItemProps[] => {
37
39
  const linkParams = { orgUnitId, contractId };
38
40
 
39
- const items: VerticalNavTreeItemProps[] = [
40
- {
41
- name: t("contracts.nav.basicInformation"),
42
- link: contractScopedLink(buyerPortalRoutes.profileDetails, linkParams),
43
- },
44
- {
45
- name: t("layouts.navigation.addresses"),
46
- link: contractScopedLink(buyerPortalRoutes.addresses, linkParams),
47
- },
48
- ];
49
-
50
- if (featureFlags?.enableRecipientsContractLevel) {
51
- items.push({
52
- name: t("layouts.navigation.recipients"),
53
- link: contractScopedLink(buyerPortalRoutes.recipients, linkParams),
54
- });
55
- }
41
+ const items: VerticalNavTreeItemProps[] = getContractCardLinks(
42
+ linkParams,
43
+ t,
44
+ featureFlags
45
+ );
56
46
 
57
- items.push(
58
- {
59
- name: t("layouts.navigation.paymentMethods"),
60
- link: contractScopedLink(buyerPortalRoutes.paymentMethods, linkParams),
61
- },
62
- {
63
- name: t("layouts.navigation.creditCards"),
64
- link: contractScopedLink(buyerPortalRoutes.creditCards, linkParams),
47
+ items.push({
48
+ name: t("layouts.navigation.accountingFields"),
49
+ loading: accountingFieldsLoading,
50
+ submenu: {
51
+ items: accountingFields.map((field) => ({
52
+ name: field.name,
53
+ link: contractScopedLink(
54
+ (params) =>
55
+ buyerPortalRoutes.accountingFields({
56
+ ...params,
57
+ accountingFieldId: field.id,
58
+ }),
59
+ linkParams
60
+ ),
61
+ hasNotification: checkAccountingFieldIsEmpty(field),
62
+ actions: (
63
+ <AccountingFieldDropdown
64
+ accountingField={field}
65
+ orgUnitId={orgUnitId}
66
+ refreshList={onAccountingFieldChange}
67
+ contractId={contractId}
68
+ />
69
+ ),
70
+ })),
65
71
  },
66
- {
67
- name: t("contracts.nav.assortment"),
68
- link: contractScopedLink(buyerPortalRoutes.productAssortment, linkParams),
69
- },
70
- {
71
- name: t("layouts.navigation.accountingFields"),
72
- loading: accountingFieldsLoading,
73
- submenu: {
74
- items: accountingFields.map((field) => ({
75
- name: field.name,
76
- link: contractScopedLink(
77
- (params) =>
78
- buyerPortalRoutes.accountingFields({
79
- ...params,
80
- accountingFieldId: field.id,
81
- }),
82
- linkParams
83
- ),
84
- hasNotification: checkAccountingFieldIsEmpty(field),
85
- actions: (
86
- <AccountingFieldDropdown
87
- accountingField={field}
88
- orgUnitId={orgUnitId}
89
- refreshList={onAccountingFieldChange}
90
- contractId={contractId}
91
- />
92
- ),
93
- })),
94
- },
95
- actions: (
96
- <IconButton
97
- aria-label="add account field"
98
- icon={<Icon name="Add" width={ICON_SIZE} height={ICON_SIZE} />}
99
- onClick={onAddAccountingField}
100
- />
101
- ),
102
- }
103
- );
72
+ actions: (
73
+ <IconButton
74
+ aria-label="add account field"
75
+ icon={<Icon name="Add" width={ICON_SIZE} height={ICON_SIZE} />}
76
+ onClick={onAddAccountingField}
77
+ />
78
+ ),
79
+ });
104
80
 
105
81
  return items;
106
82
  };
@@ -2,6 +2,7 @@ import { describe, expect, it } from "vitest";
2
2
 
3
3
  import {
4
4
  buildRemovedRedirectUrl,
5
+ getContractCardLinks,
5
6
  getDefaultContractId,
6
7
  parseRemovedCount,
7
8
  pluralSuffixArgs,
@@ -77,3 +78,53 @@ describe("parseRemovedCount", () => {
77
78
  expect(parseRemovedCount("abc")).toBeNull();
78
79
  });
79
80
  });
81
+
82
+ describe("getContractCardLinks", () => {
83
+ const linkParams = { orgUnitId: "unit-1", contractId: "contract-1" };
84
+ const t = (key: string) => key;
85
+
86
+ it("keeps the pre-SUMA labels without SUMA", () => {
87
+ expect(getContractCardLinks(linkParams, t).map(({ name }) => name)).toEqual(
88
+ [
89
+ "layouts.navigation.profile",
90
+ "layouts.navigation.addresses",
91
+ "layouts.navigation.paymentMethods",
92
+ "layouts.navigation.creditCards",
93
+ "layouts.navigation.assortments",
94
+ ]
95
+ );
96
+ });
97
+
98
+ it("uses the SUMA labels under SUMA", () => {
99
+ expect(
100
+ getContractCardLinks(linkParams, t, { suma: true }).map(
101
+ ({ name }) => name
102
+ )
103
+ ).toEqual([
104
+ "contracts.nav.basicInformation",
105
+ "layouts.navigation.addresses",
106
+ "layouts.navigation.paymentMethods",
107
+ "layouts.navigation.creditCards",
108
+ "contracts.nav.assortment",
109
+ ]);
110
+ });
111
+
112
+ it("adds Recipients when enabled at contract level", () => {
113
+ for (const suma of [false, true]) {
114
+ expect(
115
+ getContractCardLinks(linkParams, t, {
116
+ suma,
117
+ enableRecipientsContractLevel: true,
118
+ }).map(({ name }) => name)
119
+ ).toContain("layouts.navigation.recipients");
120
+ }
121
+ });
122
+
123
+ it("links to the same pages with and without SUMA", () => {
124
+ expect(
125
+ getContractCardLinks(linkParams, t, { suma: true }).map(
126
+ ({ link }) => link
127
+ )
128
+ ).toEqual(getContractCardLinks(linkParams, t).map(({ link }) => link));
129
+ });
130
+ });
@@ -8,24 +8,51 @@
8
8
  @import "../../../accounting-fields/components/EditAccountingFieldDrawer/edit-accounting-field-drawer.scss";
9
9
  @import "../../../accounting-fields/components/DeleteAccountingFieldDrawer/delete-accounting-field-drawer.scss";
10
10
  @import "../../../accounting-fields//components/CreateAccountingValueDrawer/create-accounting-value-drawer.scss";
11
- @import "../../components/ContractSwitchOverlay/contract-switch-overlay.scss";
12
11
  @import "../../components/UnableToRemoveContractsDrawer/unable-to-remove-contracts-drawer.scss";
13
12
  @import "../../components/AddContractsDrawer/add-contracts-drawer.scss";
14
13
  @import "../../components/ConfirmRemoveDrawer/confirm-remove-drawer.scss";
15
14
 
16
- // Full viewport height, so the sidebar divider reaches the bottom on short pages
15
+ // App shell: the page fills the viewport and only the content section (and
16
+ // the sidebar, when it is taller than the space left) scrolls. The window
17
+ // never scrolls, so the header, the sidebar and the menus opened from the
18
+ // header stay in place.
19
+ :root:has([data-fs-bp-contract-listing-page]) {
20
+ overflow: hidden;
21
+
22
+ // FastStore places a dropdown menu against the document when it opens, so
23
+ // it can't follow the section's scroll. Keep the content still while a menu
24
+ // opened from it is open; header menus don't need it.
25
+ &:has(
26
+ body
27
+ > [data-fs-dropdown-overlay]
28
+ > [data-fs-dropdown-menu]:not(
29
+ [data-fs-bp-org-unit-details-navbar-menu],
30
+ [data-fs-bp-org-unit-header-nav-menu]
31
+ )
32
+ )
33
+ [data-fs-bp-contract-listing-section] {
34
+ overflow-y: hidden;
35
+ }
36
+ }
37
+
17
38
  [data-fs-bp-contract-listing-page] {
18
39
  display: flex;
19
40
  flex-direction: column;
20
- min-height: 100vh;
21
- min-height: 100dvh;
41
+ height: 100vh;
42
+ height: 100dvh;
43
+
44
+ > [data-fs-bp-org-unit-details-navbar] {
45
+ flex: none;
46
+ }
22
47
  }
23
48
 
24
49
  [data-fs-bp-contract-listing-body] {
25
50
  display: grid;
26
- flex: 1 0 auto;
51
+ flex: 1;
27
52
  grid-template-columns: 1fr;
53
+ grid-template-rows: minmax(0, 1fr);
28
54
  width: 100%;
55
+ min-height: 0;
29
56
 
30
57
  @include u.media(">=notebook") {
31
58
  grid-template-columns: 20rem 1fr;
@@ -33,13 +60,8 @@
33
60
 
34
61
  > [data-fs-bp-contract-listing-sidebar] {
35
62
  @include u.media(">=notebook") {
36
- position: sticky;
37
- top: 0;
38
- align-self: start;
39
63
  width: 20rem;
40
64
  min-width: 20rem;
41
- max-height: 100vh;
42
- max-height: 100dvh;
43
65
  }
44
66
  }
45
67
  }
@@ -181,8 +203,12 @@
181
203
  @import "../../../accounting-fields/components/AccountingFieldEmptyAlert/accounting-field-empty-alert.scss";
182
204
 
183
205
  width: 100%;
206
+ min-width: 0;
184
207
  padding: var(--fs-bp-margin-0) var(--fs-bp-padding-5);
185
208
  padding-bottom: var(--fs-bp-padding-12);
209
+ overflow-y: auto;
210
+ // Hiding the scrollbar while a menu is open doesn't shift the content
211
+ scrollbar-gutter: stable;
186
212
 
187
213
  @include u.media(">=tablet") {
188
214
  padding-left: var(--fs-bp-padding-10);
@@ -1,5 +1,9 @@
1
1
  import { buyerPortalRoutes } from "../../../shared/utils/buyerPortalRoutes";
2
+ import { contractScopedLink } from "../../../shared/utils/contractScopedLink";
3
+ import { getContractSettingsLinks } from "../../../shared/utils/getContractSettingsLinks";
2
4
 
5
+ import type { FeatureFlags } from "../../../shared/components/BuyerPortalProvider/BuyerPortalProvider";
6
+ import type { LocalizeFn } from "../../../shared/localization/types";
3
7
  import type { ContractData } from "../../types";
4
8
 
5
9
  export const getDefaultContractId = (contracts: ContractData[]) =>
@@ -40,3 +44,52 @@ export const parseRemovedCount = (
40
44
  const count = Number(raw);
41
45
  return Number.isInteger(count) && count > 0 ? count : null;
42
46
  };
47
+
48
+ /**
49
+ * Page links of the single-contract card. Without SUMA they keep the labels of
50
+ * the contract sidebar ("Profile", "Assortments"), as on the pre-SUMA unit page.
51
+ */
52
+ export const getContractCardLinks = (
53
+ linkParams: { orgUnitId: string; contractId: string },
54
+ t: LocalizeFn,
55
+ featureFlags?: FeatureFlags
56
+ ) => {
57
+ if (!featureFlags?.suma) {
58
+ return getContractSettingsLinks(linkParams, t, featureFlags);
59
+ }
60
+
61
+ const links = [
62
+ {
63
+ name: t("contracts.nav.basicInformation"),
64
+ link: contractScopedLink(buyerPortalRoutes.profileDetails, linkParams),
65
+ },
66
+ {
67
+ name: t("layouts.navigation.addresses"),
68
+ link: contractScopedLink(buyerPortalRoutes.addresses, linkParams),
69
+ },
70
+ ];
71
+
72
+ if (featureFlags.enableRecipientsContractLevel) {
73
+ links.push({
74
+ name: t("layouts.navigation.recipients"),
75
+ link: contractScopedLink(buyerPortalRoutes.recipients, linkParams),
76
+ });
77
+ }
78
+
79
+ links.push(
80
+ {
81
+ name: t("layouts.navigation.paymentMethods"),
82
+ link: contractScopedLink(buyerPortalRoutes.paymentMethods, linkParams),
83
+ },
84
+ {
85
+ name: t("layouts.navigation.creditCards"),
86
+ link: contractScopedLink(buyerPortalRoutes.creditCards, linkParams),
87
+ },
88
+ {
89
+ name: t("contracts.nav.assortment"),
90
+ link: contractScopedLink(buyerPortalRoutes.productAssortment, linkParams),
91
+ }
92
+ );
93
+
94
+ return links;
95
+ };
@@ -38,7 +38,7 @@ export const CreateOrgUnitDrawer = ({
38
38
  }: CreateOrgUnitDrawerProps) => {
39
39
  const { pushToast } = useUI();
40
40
  const router = useRouter();
41
- const { currentContract, currentOrgUnit } = useBuyerPortal();
41
+ const { currentContract, currentOrgUnit, featureFlags } = useBuyerPortal();
42
42
  const contractId = resolveContractId({
43
43
  queryContractId: router.query.contractId,
44
44
  currentContract,
@@ -78,7 +78,9 @@ export const CreateOrgUnitDrawer = ({
78
78
  type="button"
79
79
  onClick={() =>
80
80
  router.push(
81
- buyerPortalRoutes.orgUnitDetails({
81
+ (featureFlags?.suma
82
+ ? buyerPortalRoutes.contracts
83
+ : buyerPortalRoutes.orgUnitDetails)({
82
84
  orgUnitId: data.id,
83
85
  contractId,
84
86
  })