@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
@@ -9,6 +9,7 @@ export {
9
9
  export { useQuery, type QueryOptions } from "./useQuery";
10
10
  export { useQueryParams } from "./useQueryParams";
11
11
  export { useDebounce } from "./useDebounce";
12
+ export { useDropdownAlign } from "./useDropdownAlign";
12
13
  export { useAddToScope } from "./useAddToScope";
13
14
  export { useRemoveFromScope } from "./useRemoveFromScope";
14
15
  export { usePageItems, type UsePageItemsProps } from "./usePageItems";
@@ -22,3 +23,4 @@ export { useSetScopeConfig } from "./useSetScopeConfig";
22
23
  export { useUrlPaginatedSearch } from "./useUrlPaginatedSearch";
23
24
  export { useReloadOnBfcacheRestore } from "./useReloadOnBfcacheRestore";
24
25
  export { useRefreshPageData } from "./useRefreshPageData";
26
+ export { useShellScrollReset } from "./useShellScrollReset";
@@ -0,0 +1,27 @@
1
+ import { useCallback, useState, type SyntheticEvent } from "react";
2
+
3
+ import {
4
+ getDropdownAlign,
5
+ type DropdownAlign,
6
+ } from "../utils/getDropdownAlign";
7
+
8
+ /**
9
+ * Opens a dropdown menu toward the side of the viewport with more space.
10
+ * Attach `updateAlign` to the trigger's `onPointerDown` and `onKeyDown` (not
11
+ * `onClick`, which `DropdownButton asChild` uses to toggle the menu); both run
12
+ * before the click that opens it.
13
+ */
14
+ export const useDropdownAlign = (initialAlign: DropdownAlign = "left") => {
15
+ const [align, setAlign] = useState<DropdownAlign>(initialAlign);
16
+
17
+ const updateAlign = useCallback((event: SyntheticEvent<HTMLElement>) => {
18
+ setAlign(
19
+ getDropdownAlign(
20
+ event.currentTarget.getBoundingClientRect(),
21
+ document.documentElement.clientWidth
22
+ )
23
+ );
24
+ }, []);
25
+
26
+ return { align, updateAlign };
27
+ };
@@ -0,0 +1,27 @@
1
+ import { useEffect, useRef } from "react";
2
+
3
+ import { useRouter } from "next/router";
4
+
5
+ /**
6
+ * The page shell scrolls its content section, not the window, so Next.js's
7
+ * scroll to the top on navigation doesn't reach it. Resets the section's
8
+ * scroll after every non-shallow route change, as Next.js does for the window.
9
+ *
10
+ * Returns a ref for the `[data-fs-bp-contract-listing-section]` element.
11
+ */
12
+ export function useShellScrollReset<T extends HTMLElement = HTMLElement>() {
13
+ const sectionRef = useRef<T>(null);
14
+ const { events } = useRouter();
15
+
16
+ useEffect(() => {
17
+ const resetScroll = (_url: string, { shallow }: { shallow: boolean }) => {
18
+ if (!shallow) sectionRef.current?.scrollTo({ top: 0 });
19
+ };
20
+
21
+ events.on("routeChangeComplete", resetScroll);
22
+
23
+ return () => events.off("routeChangeComplete", resetScroll);
24
+ }, [events]);
25
+
26
+ return sectionRef;
27
+ }
@@ -1,13 +1,11 @@
1
1
  import type { ReactNode } from "react";
2
2
 
3
- import { DropdownItem } from "@faststore/ui";
4
-
5
3
  import { OrgUnitDetailsNavbar } from "../../../org-units/components";
6
- import { Icon } from "../../components";
7
- import { useBuyerPortal, useReloadOnBfcacheRestore } from "../../hooks";
8
- import { useLocalization } from "../../localization/LocalizationContext";
9
- import { getContractSettingsLinks } from "../../utils";
10
- import { BaseTabsLayout } from "../BaseTabsLayout/BaseTabsLayout";
4
+ import {
5
+ useBuyerPortal,
6
+ useReloadOnBfcacheRestore,
7
+ useShellScrollReset,
8
+ } from "../../hooks";
11
9
  import { SumaSidebar } from "../SumaPageLayout/SumaSidebar";
12
10
 
13
11
  export type ContractTabsLayoutProps = {
@@ -21,15 +19,13 @@ export type ContractTabsLayoutProps = {
21
19
  };
22
20
 
23
21
  export const ContractTabsLayout = ({
24
- pageName,
25
22
  loading = false,
26
23
  children,
27
24
  orgUnitId,
28
25
  contractId,
29
26
  }: ContractTabsLayoutProps) => {
30
- const { currentOrgUnit, currentUser, currentContract, featureFlags } =
31
- useBuyerPortal();
32
- const { t } = useLocalization();
27
+ const { currentOrgUnit, currentUser, currentContract } = useBuyerPortal();
28
+ const sectionRef = useShellScrollReset();
33
29
 
34
30
  useReloadOnBfcacheRestore();
35
31
 
@@ -40,70 +36,35 @@ export const ContractTabsLayout = ({
40
36
  currentOrgUnit?.customerGroup.customerIds[0] ??
41
37
  "";
42
38
 
43
- if (featureFlags?.suma && resolvedOrgUnitId) {
44
- return (
45
- <>
46
- <OrgUnitDetailsNavbar
47
- orgId={resolvedOrgUnitId}
48
- contractId={resolvedContractId}
49
- person={{
50
- name: currentUser?.name ?? "",
51
- email: currentUser?.email ?? "",
52
- }}
53
- loading={loading}
54
- sidebarVariant="contract"
55
- showBackLink
56
- />
57
- <div data-fs-bp-contract-listing-body>
58
- <SumaSidebar
59
- orgUnitId={resolvedOrgUnitId}
60
- contractId={resolvedContractId}
61
- variant="contract"
62
- showBackLink
63
- loading={loading}
64
- />
65
- <section data-fs-bp-contract-listing-section>{children}</section>
66
- </div>
67
- </>
68
- );
39
+ if (!resolvedOrgUnitId) {
40
+ return <>{children}</>;
69
41
  }
70
42
 
71
- const verticalLinks = getContractSettingsLinks(
72
- {
73
- contractId: resolvedContractId,
74
- orgUnitId: resolvedOrgUnitId,
75
- },
76
- t,
77
- featureFlags
78
- );
79
-
80
43
  return (
81
- <BaseTabsLayout data-fs-bp-contract-tabs-layout>
82
- <BaseTabsLayout.Navbar
44
+ <div data-fs-bp-contract-listing-page>
45
+ <OrgUnitDetailsNavbar
46
+ orgId={resolvedOrgUnitId}
83
47
  contractId={resolvedContractId}
84
- orgUnit={currentOrgUnit}
85
- pageName={pageName}
86
48
  person={{
87
49
  name: currentUser?.name ?? "",
88
- roles: currentUser?.roles ?? [],
89
- id: currentUser?.id ?? "",
50
+ email: currentUser?.email ?? "",
90
51
  }}
91
52
  loading={loading}
53
+ sidebarVariant="contract"
54
+ showBackLink
92
55
  />
93
- <BaseTabsLayout.Container>
94
- <BaseTabsLayout.SidebarMenu
56
+ <div data-fs-bp-contract-listing-body>
57
+ <SumaSidebar
58
+ orgUnitId={resolvedOrgUnitId}
59
+ contractId={resolvedContractId}
60
+ variant="contract"
61
+ showBackLink
95
62
  loading={loading}
96
- dropdownOptions={
97
- <DropdownItem>
98
- <Icon name="DoNotDisturbOn" width={20} height={20} />
99
- {t("layouts.actions.removeFromUnit")}
100
- </DropdownItem>
101
- }
102
- verticalLinks={verticalLinks}
103
- name={currentContract?.name ?? ""}
104
63
  />
105
- <BaseTabsLayout.Content>{children}</BaseTabsLayout.Content>
106
- </BaseTabsLayout.Container>
107
- </BaseTabsLayout>
64
+ <section data-fs-bp-contract-listing-section ref={sectionRef}>
65
+ {children}
66
+ </section>
67
+ </div>
68
+ </div>
108
69
  );
109
70
  };
@@ -1,9 +1,6 @@
1
1
  import type { ReactNode } from "react";
2
2
 
3
- import { useBuyerPortal } from "../../hooks";
4
- import { useLocalization } from "../../localization/LocalizationContext";
5
- import { getFinanceSettingsLinks } from "../../utils";
6
- import { BaseTabsLayout } from "../BaseTabsLayout/BaseTabsLayout";
3
+ import { SumaPageLayout } from "../SumaPageLayout/SumaPageLayout";
7
4
 
8
5
  export type FinanceTabsLayoutProps = {
9
6
  pageName: string;
@@ -12,42 +9,8 @@ export type FinanceTabsLayoutProps = {
12
9
  };
13
10
 
14
11
  export const FinanceTabsLayout = ({
15
- pageName,
16
12
  children,
17
13
  loading = false,
18
- }: FinanceTabsLayoutProps) => {
19
- const { t } = useLocalization();
20
- const { currentOrgUnit, currentUser, currentContract } = useBuyerPortal();
21
-
22
- const verticalLinks = getFinanceSettingsLinks(
23
- {
24
- contractId: currentContract?.id ?? "",
25
- orgUnitId: currentOrgUnit?.id ?? "",
26
- },
27
- t
28
- );
29
-
30
- return (
31
- <BaseTabsLayout data-fs-bp-finance-tabs-layout>
32
- <BaseTabsLayout.Navbar
33
- contractId={currentContract?.id ?? ""}
34
- orgUnit={currentOrgUnit}
35
- pageName={pageName}
36
- person={{
37
- name: currentUser?.name ?? "",
38
- roles: currentUser?.roles ?? [],
39
- id: currentUser?.id ?? "",
40
- }}
41
- loading={loading}
42
- />
43
- <BaseTabsLayout.Container>
44
- <BaseTabsLayout.SidebarMenu
45
- verticalLinks={verticalLinks}
46
- showLetterHighlight={false}
47
- loading={loading}
48
- />
49
- <BaseTabsLayout.Content>{children}</BaseTabsLayout.Content>
50
- </BaseTabsLayout.Container>
51
- </BaseTabsLayout>
52
- );
53
- };
14
+ }: FinanceTabsLayoutProps) => (
15
+ <SumaPageLayout loading={loading}>{children}</SumaPageLayout>
16
+ );
@@ -1,9 +1,6 @@
1
1
  import type { ReactNode } from "react";
2
2
 
3
- import { useBuyerPortal } from "../../hooks";
4
- import { useLocalization } from "../../localization/LocalizationContext";
5
- import { getOrganizationSettingsLinks } from "../../utils";
6
- import { BaseTabsLayout } from "../BaseTabsLayout/BaseTabsLayout";
3
+ import { SumaPageLayout } from "../SumaPageLayout/SumaPageLayout";
7
4
 
8
5
  export type OrgUnitTabsLayoutProps = {
9
6
  pageName: string;
@@ -12,40 +9,8 @@ export type OrgUnitTabsLayoutProps = {
12
9
  };
13
10
 
14
11
  export const OrgUnitTabsLayout = ({
15
- pageName,
16
12
  children,
17
13
  loading = false,
18
- }: OrgUnitTabsLayoutProps) => {
19
- const { t } = useLocalization();
20
- const { currentOrgUnit, currentUser, currentContract } = useBuyerPortal();
21
-
22
- const verticalLinks = getOrganizationSettingsLinks({
23
- orgUnitId: currentOrgUnit?.id ?? "",
24
- contractId: currentContract?.id ?? "",
25
- t,
26
- });
27
-
28
- return (
29
- <BaseTabsLayout data-fs-bp-org-unit-tabs-layout>
30
- <BaseTabsLayout.Navbar
31
- contractId={currentContract?.id ?? ""}
32
- orgUnit={currentOrgUnit}
33
- pageName={pageName}
34
- person={{
35
- name: currentUser?.name ?? "",
36
- roles: currentUser?.roles ?? [],
37
- id: currentUser?.id ?? "",
38
- }}
39
- loading={loading}
40
- />
41
- <BaseTabsLayout.Container>
42
- <BaseTabsLayout.SidebarMenu
43
- verticalLinks={verticalLinks}
44
- showLetterHighlight={false}
45
- loading={loading}
46
- />
47
- <BaseTabsLayout.Content>{children}</BaseTabsLayout.Content>
48
- </BaseTabsLayout.Container>
49
- </BaseTabsLayout>
50
- );
51
- };
14
+ }: OrgUnitTabsLayoutProps) => (
15
+ <SumaPageLayout loading={loading}>{children}</SumaPageLayout>
16
+ );
@@ -115,7 +115,6 @@ export const FullSidebarNav = ({
115
115
  ),
116
116
  })),
117
117
  },
118
- collapsible: true,
119
118
  actions: (
120
119
  <IconButton
121
120
  aria-label="add account field"
@@ -3,7 +3,11 @@ import type { ReactNode } from "react";
3
3
  import { useRouter } from "next/router";
4
4
 
5
5
  import { OrgUnitDetailsNavbar } from "../../../org-units/components";
6
- import { useBuyerPortal, useReloadOnBfcacheRestore } from "../../hooks";
6
+ import {
7
+ useBuyerPortal,
8
+ useReloadOnBfcacheRestore,
9
+ useShellScrollReset,
10
+ } from "../../hooks";
7
11
  import { resolveContractId } from "../../utils";
8
12
 
9
13
  import { SumaSidebar } from "./SumaSidebar";
@@ -23,13 +27,13 @@ export const SumaPageLayout = ({
23
27
  sidebarVariant = "unit",
24
28
  showBackLink = true,
25
29
  }: SumaPageLayoutProps) => {
26
- const { featureFlags, currentOrgUnit, currentUser, currentContract } =
27
- useBuyerPortal();
30
+ const { currentOrgUnit, currentUser, currentContract } = useBuyerPortal();
28
31
  const router = useRouter();
32
+ const sectionRef = useShellScrollReset();
29
33
 
30
34
  useReloadOnBfcacheRestore();
31
35
 
32
- if (!featureFlags?.suma || !currentOrgUnit?.id) {
36
+ if (!currentOrgUnit?.id) {
33
37
  return <>{children}</>;
34
38
  }
35
39
 
@@ -40,7 +44,7 @@ export const SumaPageLayout = ({
40
44
  });
41
45
 
42
46
  return (
43
- <>
47
+ <div data-fs-bp-contract-listing-page>
44
48
  <OrgUnitDetailsNavbar
45
49
  orgId={currentOrgUnit.id}
46
50
  contractId={contractId}
@@ -60,8 +64,10 @@ export const SumaPageLayout = ({
60
64
  showBackLink={showBackLink}
61
65
  loading={loading}
62
66
  />
63
- <section data-fs-bp-contract-listing-section>{children}</section>
67
+ <section data-fs-bp-contract-listing-section ref={sectionRef}>
68
+ {children}
69
+ </section>
64
70
  </div>
65
- </>
71
+ </div>
66
72
  );
67
73
  };
@@ -7,6 +7,7 @@ import { buyerPortalRoutes } from "../../utils/buyerPortalRoutes";
7
7
  import { getSumaListingSidebarLinks } from "../../utils/getSumaListingSidebarLinks";
8
8
 
9
9
  import { FullSidebarNav } from "./FullSidebarNav";
10
+ import { resolveOrgLinkContractId } from "./resolveOrgLinkContractId";
10
11
  import { getSumaSidebarConfig } from "./sumaSidebarConfig";
11
12
 
12
13
  import type { SumaSidebarVariant } from "./sumaSidebarConfig";
@@ -26,28 +27,22 @@ export const SumaSidebar = ({
26
27
  showBackLink = false,
27
28
  loading = false,
28
29
  }: SumaSidebarProps) => {
29
- const { featureFlags, currentContract, currentOrgUnit } = useBuyerPortal();
30
+ const { featureFlags, currentContract } = useBuyerPortal();
30
31
  const { t } = useLocalization();
31
32
  const config = getSumaSidebarConfig(variant, showBackLink);
32
33
  const contractsUrl = buyerPortalRoutes.contracts({ orgUnitId });
33
34
 
34
- // Identify WHERE the user is (the org unit), not just which contract they
35
- // operate under — a child unit sharing its contracts with the root org is
36
- // otherwise indistinguishable from it. The contract becomes a secondary
37
- // line; contract-only identity is kept for pages with no unit context.
35
+ // Inside a contract the sidebar identifies the contract only; the org unit
36
+ // is already shown by the header.
38
37
  const contractName = currentContract?.name ?? currentContract?.email ?? "";
39
- const unitName = currentOrgUnit?.name ?? "";
40
- const identityName = unitName || contractName;
41
- const showIdentity = config.showIdentity && !!identityName;
42
- const showContractLine =
43
- config.showContractIdentity && !!unitName && !!contractName;
38
+ const showIdentity = config.showIdentity && !!contractName;
44
39
 
45
40
  return (
46
41
  <aside
47
42
  data-fs-bp-contract-listing-sidebar
48
43
  data-fs-bp-suma-sidebar-variant={variant}
49
44
  >
50
- {featureFlags?.suma && config.showBackLink && (
45
+ {config.showBackLink && (
51
46
  <Link
52
47
  href={contractsUrl}
53
48
  data-fs-bp-contract-listing-back-link
@@ -60,49 +55,39 @@ export const SumaSidebar = ({
60
55
 
61
56
  {showIdentity && (
62
57
  <div data-fs-bp-suma-sidebar-identity>
63
- <LetterHighlight size="large" letter={identityName} />
58
+ <LetterHighlight size="large" letter={contractName} />
64
59
  <div data-fs-bp-suma-sidebar-identity-row>
65
- <span data-fs-bp-suma-sidebar-identity-name>{identityName}</span>
66
- {config.showContractIdentity &&
67
- !unitName &&
68
- currentContract?.isDefault && (
69
- <Icon
70
- name="Default"
71
- width={20}
72
- height={20}
73
- data-fs-bp-suma-sidebar-identity-default
74
- aria-label="Default contract"
75
- />
76
- )}
60
+ <span data-fs-bp-suma-sidebar-identity-name>{contractName}</span>
61
+ {config.showContractIdentity && currentContract?.isDefault && (
62
+ <Icon
63
+ name="Default"
64
+ width={20}
65
+ height={20}
66
+ data-fs-bp-suma-sidebar-identity-default
67
+ aria-label="Default contract"
68
+ />
69
+ )}
77
70
  </div>
78
- {showContractLine && (
79
- <div data-fs-bp-suma-sidebar-identity-row>
80
- <span data-fs-bp-suma-sidebar-identity-contract>
81
- {contractName}
82
- </span>
83
- {currentContract?.isDefault && (
84
- <Icon
85
- name="Default"
86
- width={16}
87
- height={16}
88
- data-fs-bp-suma-sidebar-identity-default
89
- aria-label="Default contract"
90
- />
91
- )}
92
- </div>
93
- )}
94
71
  </div>
95
72
  )}
96
73
 
97
74
  {config.sections === null ? (
98
75
  <VerticalNav.Menu>
99
- {getSumaListingSidebarLinks({ orgUnitId, contractId }, t).map(
100
- (item) => (
101
- <VerticalNav.Link key={item.link} link={item.link}>
102
- {item.name}
103
- </VerticalNav.Link>
104
- )
105
- )}
76
+ {getSumaListingSidebarLinks(
77
+ {
78
+ orgUnitId,
79
+ contractId,
80
+ organizationContractId: resolveOrgLinkContractId(
81
+ featureFlags?.suma,
82
+ contractId
83
+ ),
84
+ },
85
+ t
86
+ ).map((item) => (
87
+ <VerticalNav.Link key={item.link} link={item.link}>
88
+ {item.name}
89
+ </VerticalNav.Link>
90
+ ))}
106
91
  </VerticalNav.Menu>
107
92
  ) : (
108
93
  <FullSidebarNav
@@ -1,8 +1,11 @@
1
+ import type { TransitionEvent } from "react";
2
+
1
3
  import storeConfig from "discovery.config";
2
4
 
3
5
  import Link from "next/link";
4
6
 
5
- import { BasicDrawer, type BasicDrawerProps } from "../../components";
7
+ import { BasicDrawer, Icon, type BasicDrawerProps } from "../../components";
8
+ import { useBuyerPortal } from "../../hooks";
6
9
 
7
10
  import { SumaSidebar, type SumaSidebarProps } from "./SumaSidebar";
8
11
 
@@ -17,13 +20,25 @@ export const SumaSidebarDrawer = ({
17
20
  variant,
18
21
  showBackLink,
19
22
  close,
23
+ onTransitionEnd,
20
24
  ...props
21
25
  }: SumaSidebarDrawerProps) => {
26
+ const { currentOrgUnit } = useBuyerPortal();
27
+
28
+ // Only the drawer's own slide may unmount it. Transitions inside it, like
29
+ // the close button's hover, end first and would cut the slide short.
30
+ const handleTransitionEnd = (event: TransitionEvent<HTMLDivElement>) => {
31
+ if (event.target === event.currentTarget) {
32
+ onTransitionEnd(event);
33
+ }
34
+ };
35
+
22
36
  return (
23
37
  <BasicDrawer
24
38
  data-fs-bp-suma-sidebar-drawer
25
39
  close={close}
26
40
  {...props}
41
+ onTransitionEnd={handleTransitionEnd}
27
42
  data-fs-slide-over-direction="leftSide"
28
43
  data-fs-slide-over-sidebar
29
44
  >
@@ -34,8 +49,17 @@ export const SumaSidebarDrawer = ({
34
49
  </Link>
35
50
  }
36
51
  onClose={close}
52
+ closeIcon={<Icon name="CloseSymbol" width={20} height={20} />}
37
53
  />
38
54
  <BasicDrawer.Body data-fs-bp-suma-sidebar-drawer-body>
55
+ {currentOrgUnit?.name && (
56
+ <div data-fs-bp-suma-sidebar-drawer-unit>
57
+ <Icon name="FilledFolder" width={20} height={20} />
58
+ <span data-fs-bp-suma-sidebar-drawer-unit-name>
59
+ {currentOrgUnit.name}
60
+ </span>
61
+ </div>
62
+ )}
39
63
  <SumaSidebar
40
64
  orgUnitId={orgUnitId}
41
65
  contractId={contractId}