@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.
- package/package.json +1 -1
- package/public/buyer-portal-icons.svg +9 -0
- package/src/features/accounting-fields/components/AccountingFieldDropdown/AccountingFieldDropdown.tsx +5 -2
- package/src/features/budgets/layouts/BudgetsDetailsLayout/BudgetsDetailsLayout.tsx +4 -9
- package/src/features/budgets/layouts/BudgetsLayout/BudgetsLayout.tsx +2 -9
- package/src/features/buying-policies/layouts/BuyingPoliciesLayout/BuyingPoliciesLayout.tsx +14 -31
- package/src/features/contracts/layouts/ContractListingLayout/ContractListingLayout.tsx +123 -108
- package/src/features/contracts/layouts/ContractListingLayout/ContractSettingsNav.tsx +39 -63
- package/src/features/contracts/layouts/ContractListingLayout/__tests__/utils.test.ts +51 -0
- package/src/features/contracts/layouts/ContractListingLayout/contract-listing-layout.scss +106 -61
- package/src/features/contracts/layouts/ContractListingLayout/utils.ts +53 -0
- package/src/features/org-units/components/OrgUnitDetailsNavbar/OrgUnitDetailsNavbar.tsx +4 -1
- package/src/features/org-units/layouts/OrgUnitsLayout/OrgUnitsLayout.tsx +2 -9
- package/src/features/roles/layout/RolesLayout/RolesLayout.tsx +2 -9
- package/src/features/shared/components/BasicDrawer/BasicDrawer.tsx +3 -2
- package/src/features/shared/components/BasicDrawer/BasicDrawerHeading.tsx +4 -1
- package/src/features/shared/components/VerticalNav/VerticalNavLink.tsx +3 -10
- package/src/features/shared/components/VerticalNav/VerticalNavTree.tsx +5 -30
- package/src/features/shared/components/VerticalNav/vertical-nav.scss +42 -29
- package/src/features/shared/hooks/index.ts +2 -0
- package/src/features/shared/hooks/useDropdownAlign.ts +27 -0
- package/src/features/shared/hooks/useShellScrollReset.ts +27 -0
- package/src/features/shared/layouts/ContractTabsLayout/ContractTabsLayout.tsx +26 -65
- package/src/features/shared/layouts/FinanceTabsLayout/FinanceTabsLayout.tsx +4 -41
- package/src/features/shared/layouts/OrgUnitTabsLayout/OrgUnitTabLayout.tsx +4 -39
- package/src/features/shared/layouts/SumaPageLayout/FullSidebarNav.tsx +0 -1
- package/src/features/shared/layouts/SumaPageLayout/SumaPageLayout.tsx +13 -7
- package/src/features/shared/layouts/SumaPageLayout/SumaSidebar.tsx +32 -47
- package/src/features/shared/layouts/SumaPageLayout/SumaSidebarDrawer.tsx +25 -1
- package/src/features/shared/layouts/SumaPageLayout/suma-sidebar-drawer.scss +133 -5
- package/src/features/shared/localization/__tests__/page-loader-entries.test.ts +2 -2
- package/src/features/shared/types/VerticalNav.ts +0 -1
- package/src/features/shared/utils/__tests__/getDropdownAlign.test.ts +17 -0
- package/src/features/shared/utils/__tests__/getSumaListingSidebarLinks.test.ts +30 -0
- package/src/features/shared/utils/__tests__/isNavLinkActive.test.ts +117 -0
- package/src/features/shared/utils/__tests__/routeLayoutMapping.test.ts +21 -1
- package/src/features/shared/utils/constants.ts +1 -1
- package/src/features/shared/utils/getDropdownAlign.ts +11 -0
- package/src/features/shared/utils/getSumaListingSidebarLinks.ts +8 -1
- package/src/features/shared/utils/isNavLinkActive.ts +40 -0
- package/src/features/shared/utils/routeLayoutMapping.ts +17 -4
- package/src/features/users/layouts/UsersLayout/UsersLayout.tsx +2 -9
- package/src/pages/contract-information.tsx +1 -1
- package/src/pages/contracts.tsx +30 -45
- package/src/pages/home.tsx +17 -25
- 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 {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
|
31
|
-
|
|
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 (
|
|
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
|
-
<
|
|
82
|
-
<
|
|
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
|
-
|
|
89
|
-
id: currentUser?.id ?? "",
|
|
50
|
+
email: currentUser?.email ?? "",
|
|
90
51
|
}}
|
|
91
52
|
loading={loading}
|
|
53
|
+
sidebarVariant="contract"
|
|
54
|
+
showBackLink
|
|
92
55
|
/>
|
|
93
|
-
<
|
|
94
|
-
<
|
|
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
|
-
<
|
|
106
|
-
|
|
107
|
-
|
|
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 {
|
|
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
|
-
|
|
20
|
-
|
|
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 {
|
|
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
|
-
|
|
20
|
-
|
|
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
|
+
);
|
|
@@ -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 {
|
|
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 {
|
|
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 (!
|
|
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
|
|
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
|
|
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
|
-
//
|
|
35
|
-
//
|
|
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
|
|
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
|
-
{
|
|
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={
|
|
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>{
|
|
66
|
-
{config.showContractIdentity &&
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
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(
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
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}
|