@vtex/faststore-plugin-buyer-portal 1.1.97 → 1.1.98

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vtex/faststore-plugin-buyer-portal",
3
- "version": "1.1.97",
3
+ "version": "1.1.98",
4
4
  "description": "A plugin for faststore with buyer portal",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -11,7 +11,11 @@ export const OrgUnitBreadcrumbDropdown = ({
11
11
  const { push } = useRouter();
12
12
 
13
13
  const dropdownItems = items.map((item) => (
14
- <DropdownItem onClick={() => push(item.item)} key={item.item}>
14
+ <DropdownItem
15
+ onClick={() => push(item.item)}
16
+ key={item.item}
17
+ disabled={!item.enabled}
18
+ >
15
19
  <Icon name="Folder" width={20} height={20} />
16
20
  {item.name}
17
21
  </DropdownItem>
@@ -10,6 +10,7 @@ export const OrgUnitBreadcrumbLink = ({
10
10
  name,
11
11
  item,
12
12
  isLast,
13
+ enabled,
13
14
  }: OrgUnitBreadcrumbItemProps) => {
14
15
  const [truncate, setTruncate] = useState(false);
15
16
  const linkRef = useRef<HTMLParagraphElement | HTMLAnchorElement>(null);
@@ -23,7 +24,7 @@ export const OrgUnitBreadcrumbLink = ({
23
24
  }, []);
24
25
 
25
26
  const linkContent = (
26
- <div data-fs-bp-breadcrumb-link>
27
+ <div data-fs-bp-breadcrumb-link data-fs-breadcrumb-disabled={!enabled}>
27
28
  {isLast ? (
28
29
  <p
29
30
  ref={linkRef as React.RefObject<HTMLParagraphElement>}
@@ -45,6 +45,7 @@ export const OrgUnitBreadcrumbPath = ({
45
45
  <OrgUnitBreadcrumbLink
46
46
  item={item.item}
47
47
  name={item.name}
48
+ enabled={item.enabled}
48
49
  isLast={isLast}
49
50
  />
50
51
  {!isLast && divider}
@@ -47,6 +47,10 @@
47
47
  }
48
48
  }
49
49
 
50
+ [data-fs-breadcrumb-disabled] {
51
+ pointer-events: none;
52
+ }
53
+
50
54
  [data-fs-bp-breadcrumb-divider] {
51
55
  color: #858585;
52
56
  flex: 0 0 auto;
@@ -65,7 +69,7 @@
65
69
  border-radius: var(--fs-border-radius-pill);
66
70
 
67
71
  &:hover {
68
- background-color: #F5F5F5;
72
+ background-color: #f5f5f5;
69
73
  }
70
74
  }
71
75
  }
@@ -27,6 +27,7 @@ import {
27
27
  OrgUnitDetailsNavbar,
28
28
  OrgUnitsDropdownMenu,
29
29
  } from "../../components";
30
+ import { useOrgUnitByUser } from "../../hooks";
30
31
 
31
32
  import {
32
33
  MAX_DESKTOP_BREADCRUMB_ITEMS,
@@ -54,15 +55,22 @@ export const OrgUnitsDetailsLayout = ({
54
55
  const isMobile = useMediaQuery(QUERY_TABLET);
55
56
 
56
57
  const isSingleContract = contracts.length <= 1;
57
- const breadcrumbList = orgUnit.path.ids
58
- .split("/")
59
- .slice(1)
60
- .map((orgUnitId, index) => ({
61
- unitId: orgUnitId,
62
- item: buyerPortalRoutes.orgUnitDetails({ orgUnitId }),
63
- name: orgUnit.path.names.split("/")[index],
64
- position: index + 1,
65
- }));
58
+
59
+ const { orgUnit: userUnit } = useOrgUnitByUser(user?.id ?? "");
60
+
61
+ const orgUnitList = orgUnit?.path.ids.split("/").slice(1) ?? [];
62
+
63
+ const userUnitIndex = orgUnitList.findIndex(
64
+ (unitId) => unitId === userUnit?.id
65
+ );
66
+
67
+ const breadcrumbList = orgUnitList.map((orgUnitId, index) => ({
68
+ unitId: orgUnitId,
69
+ item: buyerPortalRoutes.orgUnitDetails({ orgUnitId }),
70
+ name: orgUnit.path.names.split("/")[index],
71
+ position: index + 1,
72
+ enabled: index >= userUnitIndex,
73
+ }));
66
74
 
67
75
  return (
68
76
  <GlobalLayout>
@@ -5,6 +5,7 @@ export type OrgUnitBreadcrumbItem = {
5
5
  item: string;
6
6
  name: string;
7
7
  position: number;
8
+ enabled: boolean;
8
9
  };
9
10
 
10
11
  export type OrgUnitBreadcrumbProps = {
@@ -11,6 +11,7 @@ import {
11
11
  } from "@faststore/ui";
12
12
 
13
13
  import { OrgUnitBreadcrumb } from "../../../org-units/components";
14
+ import { useOrgUnitByUser } from "../../../org-units/hooks";
14
15
  import { ProfileSummary } from "../../../profile/components";
15
16
  import { Icon } from "../../components/Icon";
16
17
  import { useDrawerProps } from "../../hooks";
@@ -28,6 +29,7 @@ export type NavbarProps = {
28
29
  image?: ReactNode;
29
30
  name: string;
30
31
  role?: string;
32
+ id: string;
31
33
  };
32
34
  loading?: boolean;
33
35
  };
@@ -45,17 +47,23 @@ export const Navbar = ({
45
47
  ...deleteOpenSidebarMenuDrawerProps
46
48
  } = useDrawerProps();
47
49
 
50
+ const { orgUnit: userUnit } = useOrgUnitByUser(person.id);
51
+
52
+ const orgUnitList = orgUnit?.path.ids.split("/").slice(1) ?? [];
53
+
54
+ const userUnitIndex = orgUnitList.findIndex(
55
+ (unitId) => unitId === userUnit?.id
56
+ );
57
+
48
58
  const breadcrumbList = loading
49
59
  ? []
50
- : orgUnit?.path.ids
51
- .split("/")
52
- .slice(1)
53
- .map((orgUnitId, index) => ({
54
- unitId: orgUnitId,
55
- item: buyerPortalRoutes.orgUnitDetails({ orgUnitId }),
56
- name: orgUnit.path.names.split("/")[index],
57
- position: index + 1,
58
- })) ?? [];
60
+ : orgUnitList.map((orgUnitId, index) => ({
61
+ unitId: orgUnitId,
62
+ item: buyerPortalRoutes.orgUnitDetails({ orgUnitId }),
63
+ name: orgUnit?.path.names.split("/")[index] ?? "",
64
+ position: index + 1,
65
+ enabled: index >= userUnitIndex,
66
+ }));
59
67
 
60
68
  return (
61
69
  <>
@@ -45,6 +45,7 @@ export const ContractTabsLayout = ({
45
45
  person={{
46
46
  name: currentUser?.name ?? "",
47
47
  role: currentUser?.role ?? "",
48
+ id: currentUser?.id ?? "",
48
49
  }}
49
50
  loading={loading}
50
51
  />
@@ -30,6 +30,7 @@ export const FinanceTabsLayout = ({
30
30
  person={{
31
31
  name: currentUser?.name ?? "",
32
32
  role: currentUser?.role ?? "",
33
+ id: currentUser?.id ?? "",
33
34
  }}
34
35
  loading={loading}
35
36
  />
@@ -27,6 +27,7 @@ export const OrgUnitTabsLayout = ({
27
27
  person={{
28
28
  name: currentUser?.name ?? "",
29
29
  role: currentUser?.role ?? "",
30
+ id: currentUser?.id ?? "",
30
31
  }}
31
32
  loading={loading}
32
33
  />
@@ -12,7 +12,7 @@
12
12
  // Colors (Branding Core)
13
13
  // --------------------------------------------------------
14
14
  // --fs-color-main-0: blue;
15
- --fs-color-neutral-7: #5C5C5C;
15
+ --fs-color-neutral-7: #5c5c5c;
16
16
  --fs-text-color-secondary: #1f1f1f;
17
17
  --fs-text-color-button: #0068d7;
18
18
  --fs-bkg-color-secondary: #f5f5f5;
@@ -54,6 +54,10 @@
54
54
  width: 12.5rem;
55
55
  [data-fs-dropdown-item] {
56
56
  --fs-dropdown-item-color: black !important;
57
+
58
+ &:disabled {
59
+ pointer-events: none;
60
+ }
57
61
  }
58
62
 
59
63
  [data-fs-dropdown-active-item] {