@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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vtex/faststore-plugin-buyer-portal",
3
- "version": "2.0.47",
3
+ "version": "2.0.49",
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"
@@ -8,7 +8,7 @@ import {
8
8
  } from "@faststore/ui";
9
9
 
10
10
  import { BasicDropdownMenu, Icon } from "../../../shared/components";
11
- import { useDrawerProps } from "../../../shared/hooks";
11
+ import { useDrawerProps, useDropdownAlign } from "../../../shared/hooks";
12
12
  import { useLocalization } from "../../../shared/localization/LocalizationContext";
13
13
  import { buyerPortalRoutes } from "../../../shared/utils/buyerPortalRoutes";
14
14
  import { CreateAccountingValueDrawer } from "../CreateAccountingValueDrawer/CreateAccountingValueDrawer";
@@ -34,6 +34,7 @@ export const AccountingFieldDropdown = ({
34
34
  }: AccountingFieldDropdownProps) => {
35
35
  const { t } = useLocalization();
36
36
  const router = useRouter();
37
+ const { align, updateAlign } = useDropdownAlign();
37
38
  const route = buyerPortalRoutes.accountingFields({
38
39
  orgUnitId,
39
40
  contractId,
@@ -76,10 +77,12 @@ export const AccountingFieldDropdown = ({
76
77
  <DropdownButton asChild>
77
78
  <IconButton
78
79
  aria-label="toggle accounting dropdown"
80
+ onPointerDown={updateAlign}
81
+ onKeyDown={updateAlign}
79
82
  icon={<Icon name="MoreVert" width={ICON_SIZE} height={ICON_SIZE} />}
80
83
  />
81
84
  </DropdownButton>
82
- <BasicDropdownMenu>
85
+ <BasicDropdownMenu align={align}>
83
86
  <DropdownItem onClick={openCreateAccountingValueDrawer}>
84
87
  <Icon name="Add" width={ICON_SIZE} height={ICON_SIZE} />
85
88
  {t("accountingFields.dropdown.addValues")}
@@ -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
  };
@@ -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 {
@@ -358,121 +360,134 @@ export const ContractListingLayout = ({
358
360
 
359
361
  return (
360
362
  <GlobalLayout>
361
- <OrgUnitDetailsNavbar
362
- orgId={orgUnit.id}
363
- contractId=""
364
- person={{
365
- name: user?.name ?? "",
366
- email: user?.email ?? "",
367
- }}
368
- loading={loading}
369
- sidebarVariant="unit"
370
- />
371
- <div data-fs-bp-contract-listing-body>
372
- <SumaSidebar
373
- orgUnitId={orgUnit.id}
374
- contractId={defaultContractId}
375
- variant="unit"
363
+ <div data-fs-bp-contract-listing-page>
364
+ <OrgUnitDetailsNavbar
365
+ orgId={orgUnit.id}
366
+ contractId=""
367
+ person={{
368
+ name: user?.name ?? "",
369
+ email: user?.email ?? "",
370
+ }}
371
+ loading={loading}
372
+ sidebarVariant="unit"
373
+ sidebarContractId={defaultContractId}
376
374
  />
377
-
378
- <section data-fs-bp-contract-listing-section aria-busy={isBusy}>
379
- <HeaderInside
380
- title={loading ? undefined : t("contracts.titles.contracts")}
381
- info={loading ? undefined : headerInfo}
382
- data-fs-bp-contract-listing-header
375
+ <div data-fs-bp-contract-listing-body>
376
+ <SumaSidebar
377
+ orgUnitId={orgUnit.id}
378
+ contractId={defaultContractId}
379
+ variant="unit"
380
+ />
381
+
382
+ <section
383
+ data-fs-bp-contract-listing-section
384
+ aria-busy={isBusy}
385
+ ref={sectionRef}
383
386
  >
384
- {featureFlags?.suma && !loading && (
385
- <HeaderInside.Button
386
- onClick={openAddContractsDrawer}
387
- aria-label="Add contracts"
388
- />
389
- )}
390
- </HeaderInside>
391
-
392
- {loading ? (
393
- // Route-transition skeleton (LoadingTabsLayout): the destination
394
- // is the multi-contract listing, so mirror its rows.
395
- <ContractSelectionListSkeleton />
396
- ) : isSingleContract ? (
397
- <BasicCard
398
- data-fs-bp-contracts-settings-card
399
- footerMessage={t("orgUnitDetails.links.manageContractSettings")}
400
- footerLink={contractScopedLink(buyerPortalRoutes.profileDetails, {
401
- orgUnitId: orgUnit.id,
402
- contractId: defaultContractId,
403
- })}
404
- enableFooter
387
+ <HeaderInside
388
+ title={loading ? undefined : t("contracts.titles.contracts")}
389
+ info={loading ? undefined : headerInfo}
390
+ data-fs-bp-contract-listing-header
405
391
  >
406
- <LetterHighlight letter={displayName} />
407
- <VerticalNav.Menu title={displayName} loading={isBusy}>
408
- {isBusy ? (
409
- [...new Array(8)].map((_, index) => (
410
- <li style={{ padding: "8px 0" }} key={`skeleton-${index}`}>
411
- <Skeleton
412
- size={{
413
- width: "100%",
414
- height: "2.5rem",
415
- }}
416
- />
417
- </li>
418
- ))
392
+ {featureFlags?.suma && !loading && (
393
+ <HeaderInside.Button
394
+ onClick={openAddContractsDrawer}
395
+ aria-label="Add contracts"
396
+ />
397
+ )}
398
+ </HeaderInside>
399
+
400
+ {loading ? (
401
+ // Route-transition skeleton (LoadingTabsLayout): the destination
402
+ // is the multi-contract listing, so mirror its rows.
403
+ <ContractSelectionListSkeleton />
404
+ ) : isSingleContract ? (
405
+ <BasicCard
406
+ data-fs-bp-contracts-settings-card
407
+ footerMessage={t("orgUnitDetails.links.manageContractSettings")}
408
+ footerLink={contractScopedLink(
409
+ buyerPortalRoutes.profileDetails,
410
+ {
411
+ orgUnitId: orgUnit.id,
412
+ contractId: defaultContractId,
413
+ }
414
+ )}
415
+ enableFooter
416
+ >
417
+ <LetterHighlight letter={displayName} />
418
+ <VerticalNav.Menu title={displayName} loading={isBusy}>
419
+ {isBusy ? (
420
+ [...new Array(8)].map((_, index) => (
421
+ <li
422
+ style={{ padding: "8px 0" }}
423
+ key={`skeleton-${index}`}
424
+ >
425
+ <Skeleton
426
+ size={{
427
+ width: "100%",
428
+ height: "2.5rem",
429
+ }}
430
+ />
431
+ </li>
432
+ ))
433
+ ) : (
434
+ <VerticalNav.Tree
435
+ items={buildContractSettingsNavItems({
436
+ orgUnitId: orgUnit.id,
437
+ contractId: defaultContractId,
438
+ accountingFields: listAccountingFieldData ?? [],
439
+ accountingFieldsLoading: listAccountingFieldLoading,
440
+ onAddAccountingField: openAccountingFieldDrawer,
441
+ onAccountingFieldChange: listAccountingFieldRefresh,
442
+ t,
443
+ featureFlags,
444
+ })}
445
+ />
446
+ )}
447
+ </VerticalNav.Menu>
448
+ </BasicCard>
449
+ ) : (
450
+ <>
451
+ <ContractsListHeader
452
+ searchTerm={searchTerm}
453
+ onSearch={setSearch}
454
+ from={from}
455
+ to={to}
456
+ total={total}
457
+ hasPrev={hasPrev}
458
+ hasNext={hasNext}
459
+ onPrev={prevPage}
460
+ onNext={nextPage}
461
+ />
462
+ <ContractSelectAllRow
463
+ total={total}
464
+ selectedCount={selectedInFiltered}
465
+ onToggle={handleToggleSelectAll}
466
+ />
467
+ {isRefreshing ? (
468
+ <ContractSelectionListSkeleton
469
+ rows={Math.max(pageItems.length, 3)}
470
+ />
419
471
  ) : (
420
- <VerticalNav.Tree
421
- items={buildContractSettingsNavItems({
422
- orgUnitId: orgUnit.id,
423
- contractId: defaultContractId,
424
- accountingFields: listAccountingFieldData ?? [],
425
- accountingFieldsLoading: listAccountingFieldLoading,
426
- onAddAccountingField: openAccountingFieldDrawer,
427
- onAccountingFieldChange: listAccountingFieldRefresh,
428
- t,
429
- featureFlags,
430
- })}
472
+ <ContractSelectionList
473
+ contracts={pageItems}
474
+ orgUnitId={orgUnit.id}
475
+ selectedIds={selectedIds}
476
+ onKeyDown={handleKeyDown}
477
+ onSelect={handleSelect}
478
+ onItemRemove={handleItemRemove}
479
+ onSetDefault={handleSetDefault}
431
480
  />
432
481
  )}
433
- </VerticalNav.Menu>
434
- </BasicCard>
435
- ) : (
436
- <>
437
- <ContractsListHeader
438
- searchTerm={searchTerm}
439
- onSearch={setSearch}
440
- from={from}
441
- to={to}
442
- total={total}
443
- hasPrev={hasPrev}
444
- hasNext={hasNext}
445
- onPrev={prevPage}
446
- onNext={nextPage}
447
- />
448
- <ContractSelectAllRow
449
- total={total}
450
- selectedCount={selectedInFiltered}
451
- onToggle={handleToggleSelectAll}
452
- />
453
- {isRefreshing ? (
454
- <ContractSelectionListSkeleton
455
- rows={Math.max(pageItems.length, 3)}
482
+ <ContractSelectionBar
483
+ selectedCount={selectedIds.size}
484
+ onClear={clearSelection}
485
+ onRemove={() => handleRequestRemove()}
456
486
  />
457
- ) : (
458
- <ContractSelectionList
459
- contracts={pageItems}
460
- orgUnitId={orgUnit.id}
461
- selectedIds={selectedIds}
462
- onKeyDown={handleKeyDown}
463
- onSelect={handleSelect}
464
- onItemRemove={handleItemRemove}
465
- onSetDefault={handleSetDefault}
466
- />
467
- )}
468
- <ContractSelectionBar
469
- selectedCount={selectedIds.size}
470
- onClear={clearSelection}
471
- onRemove={() => handleRequestRemove()}
472
- />
473
- </>
474
- )}
475
- </section>
487
+ </>
488
+ )}
489
+ </section>
490
+ </div>
476
491
  </div>
477
492
 
478
493
  {isAccountingFieldDrawerOpen && (
@@ -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
+ });