@vtex/faststore-plugin-buyer-portal 1.1.63 → 1.1.65

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/CHANGELOG.md CHANGED
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ### Added
11
+
12
+ - Standardization the sidebar menu throughout the navigation of the Organizational Account, regardless of the context.
13
+
10
14
  ### Fixed
11
15
 
12
16
  - Adjusts in Credit Card's experience
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vtex/faststore-plugin-buyer-portal",
3
- "version": "1.1.63",
3
+ "version": "1.1.65",
4
4
  "description": "A plugin for faststore with buyer portal",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -380,6 +380,10 @@
380
380
  </g>
381
381
  </symbol>
382
382
 
383
+ <svg id="Menu" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 18 12" fill="none">
384
+ <path d="M0 12V10H18V12H0ZM0 7V5H18V7H0ZM0 2V0H18V2H0Z" fill="#1F1F1F"/>
385
+ </svg>
386
+
383
387
  <symbol id="TableEdit" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="none">
384
388
  <path
385
389
  d="M4.16667 10.8333H9.16667V7.5H4.16667V10.8333ZM4.16667 5.83333H15.8333V4.16667H4.16667V5.83333ZM4.16667 17.5C3.70833 17.5 3.31597 17.3368 2.98958 17.0104C2.66319 16.684 2.5 16.2917 2.5 15.8333V4.16667C2.5 3.70833 2.66319 3.31597 2.98958 2.98958C3.31597 2.66319 3.70833 2.5 4.16667 2.5H15.8333C16.2917 2.5 16.684 2.66319 17.0104 2.98958C17.3368 3.31597 17.5 3.70833 17.5 4.16667V9.41667C17.2361 9.30556 16.9618 9.23264 16.6771 9.19792C16.3924 9.1632 16.1111 9.16667 15.8333 9.20833C15.5417 9.26389 15.2604 9.35764 14.9896 9.48958C14.7188 9.62153 14.4722 9.79861 14.25 10.0208L13.4375 10.8333L9.16667 15.0833V17.5H4.16667ZM4.16667 15.8333H9.16667V12.5H4.16667V15.8333ZM10.8333 10.8333H13.4375L14.25 10.0208C14.4722 9.79861 14.7188 9.62153 14.9896 9.48958C15.2604 9.35764 15.5417 9.26389 15.8333 9.20833V7.5H10.8333V10.8333ZM10.8333 18.3333V15.7708L15.4375 11.1875C15.5625 11.0625 15.7014 10.9722 15.8542 10.9167C16.0069 10.8611 16.1597 10.8333 16.3125 10.8333C16.4792 10.8333 16.6389 10.8646 16.7917 10.9271C16.9444 10.9896 17.0833 11.0833 17.2083 11.2083L17.9792 11.9792C18.0903 12.1042 18.1771 12.2431 18.2396 12.3958C18.3021 12.5486 18.3333 12.7014 18.3333 12.8542C18.3333 13.0069 18.3056 13.1632 18.25 13.3229C18.1944 13.4826 18.1042 13.625 17.9792 13.75L13.3958 18.3333H10.8333ZM12.0833 17.0833H12.875L15.3958 14.5417L14.625 13.7708L12.0833 16.2917V17.0833ZM15.0208 14.1458L14.625 13.7708L15.3958 14.5417L15.0208 14.1458Z"
@@ -21,10 +21,10 @@ import {
21
21
  } from "../../../shared/utils";
22
22
  import { buyerPortalRoutes } from "../../../shared/utils/buyerPortalRoutes";
23
23
  import {
24
- OrgUnitsDropdownMenu,
25
24
  AddAllToOrgUnitDropdown,
26
- OrgUnitDetailsNavbar,
27
25
  OrgUnitBreadcrumb,
26
+ OrgUnitDetailsNavbar,
27
+ OrgUnitsDropdownMenu,
28
28
  } from "../../components";
29
29
 
30
30
  import type { ContractData } from "../../../contracts/types";
@@ -6,14 +6,18 @@ import {
6
6
  Dropdown,
7
7
  DropdownButton,
8
8
  DropdownMenu,
9
+ IconButton,
9
10
  Skeleton,
10
11
  } from "@faststore/ui";
11
12
 
12
13
  import { ProfileSummary } from "../../../profile/components";
13
14
  import { Icon } from "../../components/Icon";
15
+ import { useDrawerProps } from "../../hooks";
14
16
  import { doLogout } from "../../utils";
15
17
  import { buyerPortalRoutes } from "../../utils/buyerPortalRoutes";
16
18
 
19
+ import { SidebarDrawer } from "./sidebar-drawer/SidebarDrawer";
20
+
17
21
  export type NavbarProps = {
18
22
  orgUnitName: string;
19
23
  orgUnitId: string;
@@ -35,40 +39,68 @@ export const Navbar = ({
35
39
  loading = false,
36
40
  ...otherProps
37
41
  }: NavbarProps) => {
42
+ const {
43
+ open: openSidebarMenu,
44
+ isOpen: isOpenSidebarMenuDrawerOpen,
45
+ ...deleteOpenSidebarMenuDrawerProps
46
+ } = useDrawerProps();
47
+
38
48
  return (
39
- <nav data-fs-bp-nav {...otherProps}>
40
- <Link
41
- data-fs-bp-nav-org-unit-name
42
- href={buyerPortalRoutes.orgUnitDetails({ orgUnitId })}
43
- >
44
- <Icon name="Folder" width={24} height={24} />
49
+ <>
50
+ <nav data-fs-bp-nav {...otherProps}>
51
+ <div data-fs-bp-nav-org-unit-name>
52
+ <IconButton
53
+ data-fs-bp-sidebar-drawer-btn
54
+ icon={<Icon name="Menu" width={18} height={24} />}
55
+ aria-label={"open sidebar menu"}
56
+ onClick={() => {
57
+ openSidebarMenu();
58
+ }}
59
+ />
60
+ <Link
61
+ data-fs-bp-nav-org-unit-name
62
+ href={buyerPortalRoutes.orgUnitDetails({ orgUnitId })}
63
+ >
64
+ <Icon name="Folder" width={24} height={24} />
65
+ {loading ? (
66
+ <Skeleton size={{ width: "22rem", height: "2.5rem" }} />
67
+ ) : (
68
+ orgUnitName
69
+ )}
70
+ </Link>
71
+ </div>
72
+ <span data-fs-bp-nav-page-name>{pageName}</span>
45
73
  {loading ? (
46
- <Skeleton size={{ width: "22rem", height: "2.5rem" }} />
74
+ <Skeleton size={{ width: "2.5rem", height: "2.5rem" }} />
47
75
  ) : (
48
- orgUnitName
49
- )}
50
- </Link>
51
- <span data-fs-bp-nav-page-name>{pageName}</span>
52
- {loading ? (
53
- <Skeleton size={{ width: "2.5rem", height: "2.5rem" }} />
54
- ) : (
55
- <Dropdown>
56
- <DropdownButton asChild>
57
- <button type="button" data-fs-bp-nav-account-menu-trigger>
58
- <Icon name="AccountCircle" width={20} height={20} />
59
- </button>
60
- </DropdownButton>
76
+ <Dropdown>
77
+ <DropdownButton asChild>
78
+ <IconButton
79
+ data-fs-bp-nav-account-menu-trigger
80
+ icon={<Icon name="AccountCircle" width={20} height={20} />}
81
+ aria-label={"open sidebar menu"}
82
+ />
83
+ </DropdownButton>
61
84
 
62
- <DropdownMenu align="right" data-fs-bp-nav-menu>
63
- <ProfileSummary
64
- data-fs-bp-nav-menu-profile-summary
65
- onLogoutClick={doLogout}
66
- orgName={orgUnitName}
67
- person={person}
68
- />
69
- </DropdownMenu>
70
- </Dropdown>
85
+ <DropdownMenu align="right" data-fs-bp-nav-menu>
86
+ <ProfileSummary
87
+ data-fs-bp-nav-menu-profile-summary
88
+ onLogoutClick={doLogout}
89
+ orgName={orgUnitName}
90
+ person={person}
91
+ />
92
+ </DropdownMenu>
93
+ </Dropdown>
94
+ )}
95
+ </nav>
96
+ {isOpenSidebarMenuDrawerOpen && (
97
+ <SidebarDrawer
98
+ orgUnitName={orgUnitName}
99
+ pageName={pageName}
100
+ {...deleteOpenSidebarMenuDrawerProps}
101
+ isOpen={isOpenSidebarMenuDrawerOpen}
102
+ />
71
103
  )}
72
- </nav>
104
+ </>
73
105
  );
74
106
  };
@@ -1,12 +1,17 @@
1
1
  import type { ReactNode } from "react";
2
2
 
3
- import { Skeleton } from "@faststore/ui";
3
+ import { VerticalNav } from "../../components";
4
+ import { useBuyerPortal } from "../../hooks";
5
+ import {
6
+ getContractSettingsLinks,
7
+ getFinanceSettingsLinks,
8
+ getOrganizationSettingsLinks,
9
+ } from "../../utils";
4
10
 
5
- import { LetterHighlight, VerticalNav } from "../../components";
6
11
  export type SidebarMenuProps = {
7
12
  name?: string;
8
13
  dropdownOptions?: ReactNode;
9
- verticalLinks: {
14
+ verticalLinks?: {
10
15
  name: string;
11
16
  link: string;
12
17
  }[];
@@ -14,34 +19,54 @@ export type SidebarMenuProps = {
14
19
  loading?: boolean;
15
20
  };
16
21
 
17
- export const SidebarMenu = ({
18
- name,
19
- verticalLinks,
20
- dropdownOptions,
21
- showLetterHighlight = true,
22
- loading = true,
23
- ...otherProps
24
- }: SidebarMenuProps) => {
22
+ export const SidebarMenu = ({ ...otherProps }: SidebarMenuProps) => {
23
+ const { currentOrgUnit, currentContract } = useBuyerPortal();
24
+
25
+ const idContract =
26
+ (currentContract?.id
27
+ ? currentContract?.id
28
+ : currentOrgUnit?.customerGroup.customerIds[0]) ?? "";
29
+
25
30
  return (
26
31
  <aside data-fs-bp-sidebar-menu {...otherProps}>
27
- {showLetterHighlight &&
28
- name &&
29
- (loading ? (
30
- <Skeleton size={{ width: "3.75rem", height: "3.75rem" }} />
31
- ) : (
32
- <LetterHighlight letter={name} />
33
- ))}
34
- <VerticalNav.Menu
35
- title={name}
36
- dropdownOptions={dropdownOptions}
37
- loading={loading}
38
- >
39
- {verticalLinks.map((option) => (
32
+ <VerticalNav.Menu title="Contract">
33
+ {getContractSettingsLinks({
34
+ orgUnitId: currentOrgUnit?.id ?? "",
35
+ contractId: idContract,
36
+ }).map((option) => (
40
37
  <VerticalNav.Link key={option.name} link={option.link}>
41
38
  {option.name}
42
39
  </VerticalNav.Link>
43
40
  ))}
44
41
  </VerticalNav.Menu>
42
+ <VerticalNav.Menu title="Organization">
43
+ {getOrganizationSettingsLinks(currentOrgUnit?.id ?? "").map(
44
+ (option) => (
45
+ <VerticalNav.Link key={option.name} link={option.link}>
46
+ {option.name}
47
+ </VerticalNav.Link>
48
+ )
49
+ )}
50
+ </VerticalNav.Menu>
51
+ <VerticalNav.Menu title="Finance and Compliance">
52
+ {getFinanceSettingsLinks({
53
+ orgUnitId: currentOrgUnit?.id ?? "",
54
+ contractId: idContract,
55
+ }).map((option) => {
56
+ const parts = option.link.split("/").filter(Boolean);
57
+
58
+ let finalLink = option.link;
59
+
60
+ if (parts.length === 3) {
61
+ finalLink = `${option.link}${idContract}/`;
62
+ }
63
+ return (
64
+ <VerticalNav.Link key={option.name} link={finalLink}>
65
+ {option.name}
66
+ </VerticalNav.Link>
67
+ );
68
+ })}
69
+ </VerticalNav.Menu>
45
70
  </aside>
46
71
  );
47
72
  };
@@ -1,3 +1,5 @@
1
+ @import "./sidebar-drawer/sidebar-drawer.scss";
2
+
1
3
  [data-fs-bp-nav-menu] {
2
4
  --fs-profile-dropdown-menu-width: 22.5rem;
3
5
  width: auto;
@@ -46,6 +48,12 @@
46
48
  margin-right: var(--fs-spacing-1);
47
49
  color: #0366dd;
48
50
  }
51
+
52
+ & > [data-fs-bp-sidebar-drawer-btn] {
53
+ width: 1.125rem;
54
+ height: var(--fs-spacing-4);
55
+ margin-right: var(--fs-spacing-3);
56
+ }
49
57
  }
50
58
 
51
59
  [data-fs-bp-nav-page-name] {
@@ -69,6 +77,29 @@
69
77
  [data-fs-bp-letter-highlight] {
70
78
  margin-left: calc(var(--fs-spacing-3) + var(--fs-spacing-0));
71
79
  }
80
+
81
+ [data-fs-vertical-nav-menu] {
82
+ padding-bottom: var(--fs-spacing-2);
83
+ [data-fs-vertical-nav-menu-list] {
84
+ [data-fs-vertical-nav-menu-link] {
85
+ padding: var(--fs-spacing-2)
86
+ calc(var(--fs-spacing-1) + var(--fs-spacing-0));
87
+ }
88
+ }
89
+ [data-fs-vertical-nav-menu-org-wrapper] {
90
+ [data-fs-vertical-nav-menu-org-name] {
91
+ font-weight: var(--fs-text-weight-medium);
92
+ font-size: var(--fs-text-size-1);
93
+ color: #858585;
94
+ margin-left: calc(var(--fs-spacing-1) + var(--fs-spacing-0));
95
+ }
96
+ }
97
+ [data-fs-vertical-nav-menu-list] {
98
+ margin-top: calc(var(--fs-spacing-1) + var(--fs-spacing-0));
99
+ font-size: var(--fs-text-size-1);
100
+ font-weight: var(--fs-text-weight-medium);
101
+ }
102
+ }
72
103
  }
73
104
 
74
105
  [data-fs-bp-base-tabs-layout-content] {
@@ -78,4 +109,15 @@
78
109
  overflow-y: auto;
79
110
  padding: 0 var(--fs-text-size-7);
80
111
  }
112
+
113
+ @include media("<=notebook") {
114
+ grid-template-areas:
115
+ "navbar"
116
+ "content";
117
+ grid-template-columns: 1fr;
118
+
119
+ [data-fs-bp-sidebar-menu] {
120
+ display: none;
121
+ }
122
+ }
81
123
  }
@@ -0,0 +1,43 @@
1
+ import Link from "next/link";
2
+
3
+ import { BasicDrawer, type BasicDrawerProps } from "../../../components";
4
+ import { SidebarMenu } from "../SidebarMenu";
5
+
6
+ export type SidebarDrawerProps = Omit<BasicDrawerProps, "children"> & {
7
+ orgUnitName: string;
8
+ pageName: string;
9
+ close: () => void;
10
+ };
11
+
12
+ export const SidebarDrawer = ({
13
+ orgUnitName,
14
+ pageName,
15
+ close,
16
+ ...props
17
+ }: SidebarDrawerProps) => {
18
+ return (
19
+ <BasicDrawer
20
+ data-bp-sidebar-menu
21
+ close={close}
22
+ {...props}
23
+ data-fs-slide-over-direction="leftSide"
24
+ >
25
+ <BasicDrawer.Heading
26
+ title={
27
+ <Link href="/" data-fs-bp-org-unit-details-navbar-link>
28
+ Demostore
29
+ </Link>
30
+ }
31
+ onClose={close}
32
+ />
33
+ <BasicDrawer.Body data-bp-sidebar-menu-drawer-body>
34
+ <div data-bp-sidebar-menu-wrapper-info>
35
+ <p data-bp-sidebar-menu-drawer-org-name>{orgUnitName}</p>
36
+ <p data-bp-sidebar-menu-drawer-page-name>{pageName}</p>
37
+ </div>
38
+
39
+ <SidebarMenu />
40
+ </BasicDrawer.Body>
41
+ </BasicDrawer>
42
+ );
43
+ };
@@ -0,0 +1,81 @@
1
+ [data-bp-sidebar-menu] {
2
+ @import "../../../../shared/components/BasicDrawer/basic-drawer.scss";
3
+ @import "../../../components/LetterHighlight/letter-highlight.scss";
4
+ @import "../../../components/VerticalNav/vertical-nav.scss";
5
+
6
+ [data-fs-bp-org-unit-details-navbar-link] {
7
+ font-weight: var(--fs-text-weight-bold);
8
+ font-size: var(--fs-text-size-4);
9
+ line-height: var(--fs-text-size-6);
10
+ color: #0366dd;
11
+ text-decoration: none;
12
+ }
13
+
14
+ & > [data-bp-sidebar-menu-drawer-body] {
15
+ [data-bp-sidebar-menu-wrapper-info] {
16
+ padding: var(--fs-spacing-4)
17
+ calc(var(--fs-spacing-4) + var(--fs-spacing-0)) var(--fs-spacing-4)
18
+ calc(var(--fs-spacing-3) + var(--fs-spacing-0)) !important;
19
+
20
+ [data-bp-sidebar-menu-drawer-org-name] {
21
+ font-weight: var(--fs-text-weight-medium);
22
+ font-size: var(--fs-text-size-0);
23
+ color: #858585;
24
+ }
25
+ [data-bp-sidebar-menu-drawer-page-name] {
26
+ font-weight: var(--fs-text-weight-semibold);
27
+ font-size: var(--fs-text-size-3);
28
+ }
29
+ }
30
+
31
+ & div {
32
+ padding: var(--fs-spacing-1)
33
+ calc(var(--fs-spacing-6) + var(--fs-spacing-0)) 0
34
+ calc(var(--fs-spacing-6) + var(--fs-spacing-0)) !important;
35
+ width: 100%;
36
+ }
37
+ }
38
+
39
+ [data-fs-vertical-nav-menu] {
40
+ padding-bottom: var(--fs-spacing-2);
41
+ [data-fs-vertical-nav-menu-org-wrapper] {
42
+ padding: 0rem !important;
43
+ [data-fs-vertical-nav-menu-org-name] {
44
+ font-weight: var(--fs-text-weight-medium);
45
+ font-size: var(--fs-text-size-1);
46
+ color: #858585;
47
+ }
48
+ }
49
+ [data-fs-vertical-nav-menu-list] {
50
+ margin-top: calc(var(--fs-spacing-1) + var(--fs-spacing-0));
51
+ font-size: var(--fs-text-size-1);
52
+ font-weight: var(--fs-text-weight-medium);
53
+ }
54
+ }
55
+
56
+ @include media(">=tablet") {
57
+ width: 30rem !important;
58
+ min-width: 30rem !important;
59
+ max-width: 30rem !important;
60
+ }
61
+
62
+ @include media("<=tablet") {
63
+ width: 20.9375rem !important;
64
+ min-width: 20.9375rem !important;
65
+ max-width: 20.9375rem !important;
66
+ & > [data-fs-bp-basic-drawer-heading] {
67
+ padding: calc(var(--fs-spacing-3) + var(--fs-spacing-0))
68
+ calc(var(--fs-spacing-3) + var(--fs-spacing-0))
69
+ calc(var(--fs-spacing-3) + var(--fs-spacing-0))
70
+ calc(var(--fs-spacing-5) + var(--fs-spacing-0)) !important;
71
+ }
72
+ & > [data-bp-sidebar-menu-drawer-body] {
73
+ & div {
74
+ padding: var(--fs-spacing-1)
75
+ calc(var(--fs-spacing-3) + var(--fs-spacing-0)) 0
76
+ calc(var(--fs-spacing-3) + var(--fs-spacing-0)) !important;
77
+ width: 100%;
78
+ }
79
+ }
80
+ }
81
+ }
@@ -70,7 +70,13 @@ export async function loader(
70
70
  const { data: buyingPolicies = [], total = 0 } = buyingPoliciesResponse;
71
71
 
72
72
  return {
73
- buyingPolicies,
73
+ buyingPolicies: search
74
+ ? buyingPolicies.filter((buyingPolicy) =>
75
+ buyingPolicy.name
76
+ .toLocaleLowerCase()
77
+ .includes(search.toLocaleLowerCase())
78
+ )
79
+ : buyingPolicies,
74
80
  total,
75
81
  search,
76
82
  page,