@vtex/faststore-plugin-buyer-portal 2.0.49 → 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 (49) hide show
  1. package/package.json +1 -1
  2. package/src/features/accounting-fields/hooks/useListAccountingFields.ts +2 -1
  3. package/src/features/addresses/components/AddressLine/AddressLine.tsx +3 -6
  4. package/src/features/contracts/components/ContractListItem/ContractListItem.tsx +0 -5
  5. package/src/features/contracts/components/index.ts +0 -2
  6. package/src/features/contracts/hooks/useSwitchContract.ts +13 -5
  7. package/src/features/contracts/layouts/ContractListingLayout/contract-listing-layout.scss +0 -1
  8. package/src/features/org-units/components/CreateOrgUnitDrawer/CreateOrgUnitDrawer.tsx +4 -2
  9. package/src/features/org-units/components/DeleteOrgUnitDrawer/DeleteOrgUnitDrawer.tsx +6 -2
  10. package/src/features/org-units/components/OrgUnitBreadcrumb/OrgUnitBreadcrumbLink.tsx +3 -4
  11. package/src/features/org-units/components/OrgUnitDetailsNavbar/OrgUnitDetailsNavbar.tsx +82 -3
  12. package/src/features/org-units/components/OrgUnitHeaderNav/OrgUnitHeaderNav.tsx +13 -2
  13. package/src/features/org-units/components/OrgUnitsHierarchyTree/OrgUnitsHierarchyTree.tsx +18 -10
  14. package/src/features/org-units/components/UpdateOrgUnitDrawer/UpdateOrgUnitDrawer.tsx +4 -2
  15. package/src/features/org-units/hooks/useOrgUnitByUser.ts +2 -0
  16. package/src/features/shared/components/BasicCard/BasicCard.tsx +6 -3
  17. package/src/features/shared/components/BasicCard/BasicCardLine.tsx +3 -5
  18. package/src/features/shared/components/BuyerPortalProvider/BuyerPortalProvider.tsx +2 -0
  19. package/src/features/shared/components/HeaderInside/HeaderInside.tsx +2 -5
  20. package/src/features/shared/components/InternalTopbar/InternalTopbar.tsx +3 -4
  21. package/src/features/shared/components/PageLoadingIndicator/PageLoadingIndicator.tsx +129 -0
  22. package/src/features/shared/components/PageLoadingIndicator/page-loading-indicator.scss +49 -0
  23. package/src/features/shared/components/Table/TableRow/TableRow.tsx +2 -5
  24. package/src/features/shared/components/VerticalNav/VerticalNavLink.tsx +11 -10
  25. package/src/features/shared/hooks/index.ts +2 -0
  26. package/src/features/shared/hooks/useDisplayedOrgUnitName.ts +12 -0
  27. package/src/features/shared/hooks/useDrawerProps.ts +17 -4
  28. package/src/features/shared/hooks/usePageItems.ts +7 -1
  29. package/src/features/shared/hooks/usePageLoading.ts +11 -0
  30. package/src/features/shared/hooks/useQuery.ts +62 -20
  31. package/src/features/shared/layouts/GlobalLayout/global-layout.scss +1 -0
  32. package/src/features/shared/layouts/LoadingTabsLayout/LoadingTabsLayout.tsx +5 -2
  33. package/src/features/shared/layouts/SumaPageLayout/SumaSidebarDrawer.tsx +20 -2
  34. package/src/features/shared/layouts/SumaPageLayout/suma-sidebar-drawer.scss +14 -0
  35. package/src/features/shared/utils/__tests__/getRouteKey.test.ts +29 -0
  36. package/src/features/shared/utils/constants.ts +1 -1
  37. package/src/features/shared/utils/getRouteKey.ts +4 -0
  38. package/src/features/shared/utils/pageLoading/__tests__/keptSidebarDrawer.test.ts +170 -0
  39. package/src/features/shared/utils/pageLoading/__tests__/navigationLevel.test.ts +107 -0
  40. package/src/features/shared/utils/pageLoading/__tests__/orgUnitNames.test.ts +60 -0
  41. package/src/features/shared/utils/pageLoading/__tests__/pageLoadingStore.test.ts +266 -0
  42. package/src/features/shared/utils/pageLoading/keptSidebarDrawer.ts +133 -0
  43. package/src/features/shared/utils/pageLoading/navigationLevel.ts +89 -0
  44. package/src/features/shared/utils/pageLoading/orgUnitNames.ts +49 -0
  45. package/src/features/shared/utils/pageLoading/pageLoadingStore.ts +277 -0
  46. package/src/features/shared/utils/withProviders.tsx +5 -1
  47. package/src/features/shared/utils/withRouteKey.ts +23 -0
  48. package/src/features/contracts/components/ContractSwitchOverlay/ContractSwitchOverlay.tsx +0 -47
  49. 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.49",
3
+ "version": "2.0.50",
4
4
  "description": "A plugin for faststore with buyer portal",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -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}
@@ -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
  }
@@ -8,7 +8,6 @@
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";
@@ -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
  })
@@ -35,7 +35,7 @@ export const DeleteOrgUnitDrawer = ({
35
35
  ...props
36
36
  }: DeleteOrgUnitDrawerProps) => {
37
37
  const router = useRouter();
38
- const { currentOrgUnit, currentContract } = useBuyerPortal();
38
+ const { currentOrgUnit, currentContract, featureFlags } = useBuyerPortal();
39
39
  const contractId = resolveContractId({
40
40
  queryContractId: router.query.contractId,
41
41
  currentContract,
@@ -87,7 +87,11 @@ export const DeleteOrgUnitDrawer = ({
87
87
 
88
88
  if (ids.length >= 2) {
89
89
  const parentId = ids[ids.length - 2];
90
- const redirectUrl = buyerPortalRoutes.orgUnitDetails({
90
+ const redirectUrl = (
91
+ featureFlags?.suma
92
+ ? buyerPortalRoutes.contracts
93
+ : buyerPortalRoutes.orgUnitDetails
94
+ )({
91
95
  orgUnitId: parentId,
92
96
  contractId,
93
97
  });
@@ -1,7 +1,7 @@
1
1
  import { useEffect, useRef, useState } from "react";
2
2
 
3
- import { useLink_unstable as useLink } from "@faststore/core/experimental";
4
- import { Link, Tooltip } from "@faststore/ui";
3
+ import { Link_unstable as Link } from "@faststore/core/experimental";
4
+ import { Tooltip } from "@faststore/ui";
5
5
 
6
6
  import { OrgUnitBreadcrumbItemProps } from "../../types";
7
7
 
@@ -11,7 +11,6 @@ export const OrgUnitBreadcrumbLink = ({
11
11
  isLast,
12
12
  enabled,
13
13
  }: OrgUnitBreadcrumbItemProps) => {
14
- const { resolveLink } = useLink();
15
14
  const [truncate, setTruncate] = useState(false);
16
15
  const linkRef = useRef<HTMLParagraphElement | HTMLAnchorElement>(null);
17
16
 
@@ -38,7 +37,7 @@ export const OrgUnitBreadcrumbLink = ({
38
37
  <Link
39
38
  ref={linkRef as React.RefObject<HTMLAnchorElement>}
40
39
  data-fs-bp-breadcrumb-text
41
- href={resolveLink(item)}
40
+ href={item}
42
41
  >
43
42
  {name}
44
43
  </Link>
@@ -1,4 +1,4 @@
1
- import { useEffect } from "react";
1
+ import { useEffect, useRef, useState } from "react";
2
2
 
3
3
  import storeConfig from "discovery.config";
4
4
 
@@ -27,6 +27,16 @@ import { SumaSidebarDrawer } from "../../../shared/layouts/SumaPageLayout/SumaSi
27
27
  import { useLocalization } from "../../../shared/localization/LocalizationContext";
28
28
  import { doLogout } from "../../../shared/utils";
29
29
  import { buyerPortalRoutes } from "../../../shared/utils/buyerPortalRoutes";
30
+ import {
31
+ forgetSidebarDrawerKeptAcrossLoad,
32
+ isFullLoadEnd,
33
+ isNavigationStart,
34
+ isSidebarDrawerKept,
35
+ keepSidebarDrawer,
36
+ releaseSidebarDrawer,
37
+ takeSidebarDrawerKeptAcrossLoad,
38
+ } from "../../../shared/utils/pageLoading/keptSidebarDrawer";
39
+ import { pageLoadingStore } from "../../../shared/utils/pageLoading/pageLoadingStore";
30
40
  import { useOrgUnitByUser } from "../../hooks";
31
41
  import { OrgUnitHeaderNav } from "../OrgUnitHeaderNav/OrgUnitHeaderNav";
32
42
 
@@ -86,11 +96,77 @@ export const OrgUnitDetailsNavbar = ({
86
96
  ...aboutMenuDrawerProps
87
97
  } = useDrawerProps();
88
98
 
99
+ const [isSidebarDrawerRestored, setIsSidebarDrawerRestored] = useState(
100
+ () => Boolean(sidebarVariant) && isSidebarDrawerKept()
101
+ );
89
102
  const {
90
- open: openSidebarMenu,
103
+ open: openSidebarDrawer,
91
104
  isOpen: isOpenSidebarMenu,
92
105
  ...sidebarMenuDrawerProps
93
- } = useDrawerProps();
106
+ } = useDrawerProps({ initiallyOpen: isSidebarDrawerRestored });
107
+ const { close: closeSidebarDrawer } = sidebarMenuDrawerProps;
108
+ const openSidebarMenu = () => {
109
+ keepSidebarDrawer(pageLoadingStore.getSnapshot());
110
+ setIsSidebarDrawerRestored(false);
111
+ openSidebarDrawer();
112
+ };
113
+
114
+ // A drawer opened during the full load that opened this page (e.g. a
115
+ // contract) shows open. Read after hydration, as the server renders it closed.
116
+ useEffect(() => {
117
+ if (!sidebarVariant || !takeSidebarDrawerKeptAcrossLoad(router.asPath)) {
118
+ return;
119
+ }
120
+
121
+ keepSidebarDrawer();
122
+ setIsSidebarDrawerRestored(true);
123
+ openSidebarDrawer();
124
+ }, []);
125
+
126
+ // A drawer open when a navigation starts closes; one opened after it
127
+ // started stays open when that page shows.
128
+ useEffect(() => {
129
+ let previous = pageLoadingStore.getSnapshot();
130
+
131
+ const unsubscribe = pageLoadingStore.subscribe(() => {
132
+ const next = pageLoadingStore.getSnapshot();
133
+
134
+ if (isNavigationStart(previous, next)) {
135
+ releaseSidebarDrawer();
136
+ closeSidebarDrawer();
137
+ } else if (isFullLoadEnd(previous, next)) {
138
+ forgetSidebarDrawerKeptAcrossLoad();
139
+ }
140
+ previous = next;
141
+ });
142
+
143
+ // A page restored from the back-forward cache was left by a navigation.
144
+ const closeOnRestore = (event: PageTransitionEvent) => {
145
+ if (!event.persisted) return;
146
+ releaseSidebarDrawer();
147
+ closeSidebarDrawer();
148
+ };
149
+
150
+ window.addEventListener("pageshow", closeOnRestore);
151
+
152
+ return () => {
153
+ unsubscribe();
154
+ window.removeEventListener("pageshow", closeOnRestore);
155
+ };
156
+ }, []);
157
+
158
+ // Only the buyer closing it releases it: a header that mounts without the
159
+ // drawer (e.g. while the page loads) doesn't.
160
+ const isSidebarDrawerShown =
161
+ isOpenSidebarMenu && sidebarMenuDrawerProps.fade === "in";
162
+ const wasSidebarDrawerShown = useRef(isSidebarDrawerShown);
163
+
164
+ useEffect(() => {
165
+ if (wasSidebarDrawerShown.current && !isSidebarDrawerShown) {
166
+ releaseSidebarDrawer();
167
+ }
168
+ wasSidebarDrawerShown.current = isSidebarDrawerShown;
169
+ }, [isSidebarDrawerShown]);
94
170
 
95
171
  // `?about=1` opens the About/version drawer and is stripped from the URL.
96
172
  // The header has no visible trigger (QA-11), so this is the way to read
@@ -184,6 +260,9 @@ export const OrgUnitDetailsNavbar = ({
184
260
  showBackLink={showBackLink}
185
261
  {...sidebarMenuDrawerProps}
186
262
  isOpen={isOpenSidebarMenu}
263
+ data-fs-bp-suma-sidebar-drawer-kept={
264
+ isSidebarDrawerRestored || undefined
265
+ }
187
266
  />
188
267
  )}
189
268
  </header>
@@ -1,3 +1,5 @@
1
+ import { useEffect } from "react";
2
+
1
3
  import { useRouter } from "next/router";
2
4
 
3
5
  import {
@@ -8,8 +10,10 @@ import {
8
10
  } from "@faststore/ui";
9
11
 
10
12
  import { Icon } from "../../../shared/components";
13
+ import { useDisplayedOrgUnitName } from "../../../shared/hooks";
11
14
  import { useLocalization } from "../../../shared/localization/LocalizationContext";
12
15
  import { buyerPortalRoutes } from "../../../shared/utils/buyerPortalRoutes";
16
+ import { rememberOrgUnitPath } from "../../../shared/utils/pageLoading/orgUnitNames";
13
17
 
14
18
  import { getOrgUnitHeaderNavItems } from "./getOrgUnitHeaderNavItems";
15
19
 
@@ -44,6 +48,13 @@ export const OrgUnitHeaderNav = ({
44
48
  buildLink: (orgUnitId) => buyerPortalRoutes.contracts({ orgUnitId }),
45
49
  });
46
50
 
51
+ const orgUnitName = useDisplayedOrgUnitName(orgUnit);
52
+
53
+ // The dropdown and the breadcrumb link to the units of this path.
54
+ useEffect(() => {
55
+ rememberOrgUnitPath(orgUnit.path);
56
+ }, [orgUnit.path]);
57
+
47
58
  return (
48
59
  <div data-fs-bp-org-unit-header-nav>
49
60
  <Dropdown>
@@ -60,7 +71,7 @@ export const OrgUnitHeaderNav = ({
60
71
  height={20}
61
72
  data-fs-bp-org-unit-header-nav-icon
62
73
  />
63
- <span data-fs-bp-org-unit-header-nav-name>{orgUnit.name}</span>
74
+ <span data-fs-bp-org-unit-header-nav-name>{orgUnitName}</span>
64
75
  {canNavigate && (
65
76
  <Icon
66
77
  name="ArrowDropDown"
@@ -96,7 +107,7 @@ export const OrgUnitHeaderNav = ({
96
107
  dismissOnClick
97
108
  >
98
109
  <Icon name="FilledFolder" width={20} height={20} />
99
- <span data-fs-bp-org-unit-header-nav-item-name>{orgUnit.name}</span>
110
+ <span data-fs-bp-org-unit-header-nav-item-name>{orgUnitName}</span>
100
111
  </DropdownItem>
101
112
  </DropdownMenu>
102
113
  </Dropdown>
@@ -1,7 +1,7 @@
1
1
  import { useRouter } from "next/router";
2
2
 
3
- import { useLink_unstable as useLink } from "@faststore/core/experimental";
4
- import { Dropdown, Link } from "@faststore/ui";
3
+ import { Link_unstable as Link } from "@faststore/core/experimental";
4
+ import { Dropdown } from "@faststore/ui";
5
5
 
6
6
  import { OrgUnitsDropdownMenu } from "..";
7
7
  import {
@@ -11,6 +11,7 @@ import {
11
11
  } from "../../../shared/components";
12
12
  import { useBuyerPortal } from "../../../shared/hooks";
13
13
  import { buyerPortalRoutes } from "../../../shared/utils/buyerPortalRoutes";
14
+ import { rememberOrgUnitNames } from "../../../shared/utils/pageLoading/orgUnitNames";
14
15
  import { resolveContractId } from "../../../shared/utils/resolveContractId";
15
16
  import { useChildrenOrgUnits, useOrgUnitStructure } from "../../hooks";
16
17
 
@@ -27,10 +28,9 @@ export const OrgUnitsHierarchyTree = ({
27
28
  readonly,
28
29
  enableChildren = true,
29
30
  }: OrgUnitsHierarchyTreeProps) => {
30
- const { resolveLink } = useLink();
31
31
  const { structure, setNode } = useOrgUnitStructure(orgUnitHierarchyData);
32
32
  const router = useRouter();
33
- const { currentContract, currentOrgUnit } = useBuyerPortal();
33
+ const { currentContract, currentOrgUnit, featureFlags } = useBuyerPortal();
34
34
  const contractId = resolveContractId({
35
35
  queryContractId: router.query.contractId,
36
36
  currentContract,
@@ -59,12 +59,20 @@ export const OrgUnitsHierarchyTree = ({
59
59
  {!readonly && (
60
60
  <Link
61
61
  data-fs-org-unit-item-click-area
62
- href={resolveLink(
63
- buyerPortalRoutes.orgUnitDetails({
64
- orgUnitId: id,
65
- contractId,
66
- })
67
- )}
62
+ onClick={() => rememberOrgUnitNames([{ id, name }])}
63
+ // Under SUMA the unit details route only redirects to the
64
+ // Contracts listing, which made the click load twice.
65
+ href={
66
+ featureFlags?.suma
67
+ ? buyerPortalRoutes.contracts({
68
+ orgUnitId: id,
69
+ contractId,
70
+ })
71
+ : buyerPortalRoutes.orgUnitDetails({
72
+ orgUnitId: id,
73
+ contractId,
74
+ })
75
+ }
68
76
  />
69
77
  )}
70
78
  {enableChildren && (
@@ -34,7 +34,7 @@ export const UpdateOrgUnitDrawer = ({
34
34
  }: UpdateOrgUnitDrawerProps) => {
35
35
  const router = useRouter();
36
36
  const { pushToast } = useUI();
37
- const { currentContract, currentOrgUnit } = useBuyerPortal();
37
+ const { currentContract, currentOrgUnit, featureFlags } = useBuyerPortal();
38
38
  const contractId = resolveContractId({
39
39
  queryContractId: router.query.contractId,
40
40
  currentContract,
@@ -69,7 +69,9 @@ export const UpdateOrgUnitDrawer = ({
69
69
  type="button"
70
70
  onClick={() =>
71
71
  router.push(
72
- buyerPortalRoutes.orgUnitDetails({
72
+ (featureFlags?.suma
73
+ ? buyerPortalRoutes.contracts
74
+ : buyerPortalRoutes.orgUnitDetails)({
73
75
  orgUnitId: id,
74
76
  contractId,
75
77
  })
@@ -9,6 +9,8 @@ export const useOrgUnitByUser = (
9
9
  `api/org-unit-by-user-id/${userId}`,
10
10
  ({ cookie }) => getOrgUnitByUserIdService({ cookie, userId }),
11
11
  {
12
+ // The header shows the user's unit on every page.
13
+ cache: true,
12
14
  ...options,
13
15
  lazy: !userId || options?.lazy,
14
16
  }
@@ -2,8 +2,11 @@ import type { ReactNode } from "react";
2
2
 
3
3
  import { useRouter } from "next/router";
4
4
 
5
- import { useLink_unstable as useLink } from "@faststore/core/experimental";
6
- import { Icon as UIIcon, IconButton, Link } from "@faststore/ui";
5
+ import {
6
+ Link_unstable as Link,
7
+ useLink_unstable as useLink,
8
+ } from "@faststore/core/experimental";
9
+ import { Icon as UIIcon, IconButton } from "@faststore/ui";
7
10
 
8
11
  import { Card, CardBody, CardFooter, CardHeader } from "../Card";
9
12
  import { Icon } from "../Icon";
@@ -60,7 +63,7 @@ export const BasicCard = ({
60
63
  <CardBody>{children}</CardBody>
61
64
  {enableFooter && (
62
65
  <CardFooter>
63
- <Link href={resolvedFooterLink} data-fs-card-footer-link>
66
+ <Link href={footerLink} data-fs-card-footer-link>
64
67
  <span>{footerMessage}</span>
65
68
  </Link>
66
69
  <IconButton
@@ -1,7 +1,7 @@
1
1
  import type { ReactNode } from "react";
2
2
 
3
- import { useLink_unstable as useLink } from "@faststore/core/experimental";
4
- import { Dropdown, Link } from "@faststore/ui";
3
+ import { Link_unstable as Link } from "@faststore/core/experimental";
4
+ import { Dropdown } from "@faststore/ui";
5
5
 
6
6
  import { BasicDropdownMenu } from "../BasicDropdownMenu/BasicDropdownMenu";
7
7
 
@@ -18,11 +18,9 @@ export const BasicCardLine = ({
18
18
  menu,
19
19
  href,
20
20
  }: BasicCardLineProps) => {
21
- const { resolveLink } = useLink();
22
-
23
21
  return (
24
22
  <span data-fs-basic-card-line title={title}>
25
- {href && <Link data-fs-basic-card-line-link href={resolveLink(href)} />}
23
+ {href && <Link data-fs-basic-card-line-link href={href} />}
26
24
  {!!icon && <span data-fs-basic-card-line-icon>{icon}</span>}
27
25
  <span data-fs-basic-card-line-title>{title}</span>
28
26
  {!!menu && (
@@ -2,6 +2,7 @@ import { createContext, type ReactNode } from "react";
2
2
 
3
3
  import { LoadingTabsLayout } from "../../layouts";
4
4
  import { ErrorBoundary } from "../ErrorBoundary/ErrorBoundary";
5
+ import { PageLoadingIndicator } from "../PageLoadingIndicator/PageLoadingIndicator";
5
6
 
6
7
  import type { ContractData } from "../../../contracts/types";
7
8
  import type { OrgUnitBasicData } from "../../../org-units/types";
@@ -50,6 +51,7 @@ export const BuyerPortalProvider = ({
50
51
  }: BuyerPortalProviderProps) => {
51
52
  return (
52
53
  <BuyerPortalContext.Provider value={value}>
54
+ <PageLoadingIndicator />
53
55
  <ErrorBoundary>
54
56
  <LoadingTabsLayout>{children}</LoadingTabsLayout>
55
57
  </ErrorBoundary>
@@ -1,7 +1,6 @@
1
1
  import type { ReactNode } from "react";
2
2
 
3
- import { useLink_unstable as useLink } from "@faststore/core/experimental";
4
- import { Link } from "@faststore/ui";
3
+ import { Link_unstable as Link } from "@faststore/core/experimental";
5
4
 
6
5
  import { Icon } from "../Icon";
7
6
 
@@ -21,12 +20,10 @@ export const HeaderInside = ({
21
20
  info,
22
21
  ...otherProps
23
22
  }: HeaderInsideProps) => {
24
- const { resolveLink } = useLink();
25
-
26
23
  return (
27
24
  <header data-fs-bp-header-inside {...otherProps}>
28
25
  {!!backLink && (
29
- <Link href={resolveLink(backLink)} data-fs-bp-back-link>
26
+ <Link href={backLink} data-fs-bp-back-link>
30
27
  <Icon name="Back" />
31
28
  </Link>
32
29
  )}
@@ -1,8 +1,8 @@
1
1
  import type { ReactNode } from "react";
2
2
  import type { HTMLAttributes } from "react";
3
3
 
4
- import { useLink_unstable as useLink } from "@faststore/core/experimental";
5
- import { IconButton, Dropdown, DropdownButton, Link } from "@faststore/ui";
4
+ import { Link_unstable as Link } from "@faststore/core/experimental";
5
+ import { IconButton, Dropdown, DropdownButton } from "@faststore/ui";
6
6
 
7
7
  import { useBuyerPortal } from "../../hooks/useBuyerPortal";
8
8
  import { useLocalization } from "../../localization/LocalizationContext";
@@ -29,12 +29,11 @@ export const InternalTopBar = ({
29
29
  }: InternapTopBarProps) => {
30
30
  const { currentOrgUnit } = useBuyerPortal();
31
31
  const { t } = useLocalization();
32
- const { resolveLink } = useLink();
33
32
 
34
33
  return (
35
34
  <header data-fs-buyer-portal-topbar>
36
35
  <div data-fs-buyer-portal-topbar-navigation>
37
- <Link href={resolveLink(href)}>
36
+ <Link href={href}>
38
37
  <IconButton
39
38
  size="small"
40
39
  icon={