@vtex/faststore-plugin-buyer-portal 1.0.26 → 1.0.28

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 (222) hide show
  1. package/package.json +1 -1
  2. package/plugin.config.js +16 -14
  3. package/src/apis/new-route.ts +1 -1
  4. package/src/clients/BuyerPortalClient.ts +16 -5
  5. package/src/clients/Client.ts +3 -4
  6. package/src/components/overrides/Navbar.tsx +2 -2
  7. package/src/{components → features/addresses/components}/AddressLine/AddressLine.tsx +3 -4
  8. package/src/{components → features/addresses/components}/AddressesCard/AddressesCard.tsx +18 -10
  9. package/src/features/addresses/components/index.ts +2 -0
  10. package/src/features/addresses/hooks/index.ts +0 -0
  11. package/src/{layouts → features/addresses/layouts}/AddressDetailsLayout/AddressDetailsLayout.tsx +38 -29
  12. package/src/{layouts → features/addresses/layouts}/AddressDetailsLayout/address-details-layout.scss +1 -1
  13. package/src/{layouts → features/addresses/layouts}/AddressesLayout/AddressesLayout.tsx +14 -15
  14. package/src/{layouts → features/addresses/layouts}/AddressesLayout/addresses-layout.scss +8 -5
  15. package/src/features/addresses/layouts/index.ts +8 -0
  16. package/src/{mock → features/addresses/mocks}/addresses-data.ts +1 -1
  17. package/src/features/addresses/mocks/index.ts +1 -0
  18. package/src/features/addresses/services/get-address-details.service.ts +11 -0
  19. package/src/features/addresses/services/get-addresses.service.ts +51 -0
  20. package/src/features/addresses/services/index.ts +5 -0
  21. package/src/features/addresses/types/index.ts +1 -0
  22. package/src/{components → features/contracts/components}/ContractsCard/ContractsCard.tsx +2 -3
  23. package/src/features/contracts/components/index.ts +1 -0
  24. package/src/features/contracts/hooks/index.ts +0 -0
  25. package/src/{layouts → features/contracts/layouts}/ContractsLayout/ContractsLayout.tsx +14 -17
  26. package/src/{layouts → features/contracts/layouts}/ContractsLayout/contracts-layout.scss +5 -5
  27. package/src/features/contracts/layouts/index.ts +4 -0
  28. package/src/{mock → features/contracts/mocks}/contracts-data.ts +1 -1
  29. package/src/features/contracts/mocks/index.ts +1 -0
  30. package/src/{services → features/contracts/services}/get-contracts.service.ts +3 -4
  31. package/src/features/contracts/services/index.ts +4 -0
  32. package/src/{types → features/contracts/types}/ContractData.ts +1 -1
  33. package/src/features/contracts/types/index.ts +1 -0
  34. package/src/{components → features/org-units/components}/CreateOrgUnitDrawer/CreateOrgUnitDrawer.tsx +10 -6
  35. package/src/features/org-units/components/CreateOrgUnitDrawer/create-org-unit-drawer.scss +6 -0
  36. package/src/{components → features/org-units/components}/DeleteOrgUnitDrawer/DeleteOrgUnitDrawer.tsx +13 -8
  37. package/src/{components → features/org-units/components}/DeleteOrgUnitDrawer/delete-org-unit-drawer.scss +6 -5
  38. package/src/{components → features/org-units/components}/OrgUnitsDropdownMenu/OrgUnitsDropdownMenu.tsx +8 -6
  39. package/src/{components → features/org-units/components}/OrgUnitsDropdownMenu/org-units-dropdown-menu.scss +1 -1
  40. package/src/{components → features/org-units/components}/OrgUnitsHierarchyTree/OrgUnitsHierarchyTree.tsx +12 -10
  41. package/src/{components → features/org-units/components}/OrgUnitsHierarchyTree/org-units-hierarchy-tree.scss +1 -1
  42. package/src/{components → features/org-units/components}/OrganizationalUnitsCard/OrganizationalUnitsCard.tsx +4 -6
  43. package/src/{components → features/org-units/components}/UpdateOrgUnitDrawer/UpdateOrgUnitDrawer.tsx +12 -7
  44. package/src/features/org-units/components/UpdateOrgUnitDrawer/update-org-unit-drawer.scss +6 -0
  45. package/src/features/org-units/components/index.ts +21 -0
  46. package/src/features/org-units/hooks/index.ts +6 -0
  47. package/src/{hooks → features/org-units/hooks}/useChildrenOrgUnits.ts +2 -2
  48. package/src/{hooks → features/org-units/hooks}/useCreateNewOrgUnit.ts +4 -4
  49. package/src/{hooks → features/org-units/hooks}/useDeleteOrgUnit.ts +3 -3
  50. package/src/{hooks → features/org-units/hooks}/useOrgUnitStructure.ts +7 -3
  51. package/src/{hooks → features/org-units/hooks}/useRootOrgUnitByCustomer.ts +2 -2
  52. package/src/{hooks → features/org-units/hooks}/useUpdateOrgUnit.ts +3 -3
  53. package/src/features/org-units/layouts/OrgUnitDetailsLayout/OrgUnitDetailsLayout.tsx +42 -0
  54. package/src/features/org-units/layouts/OrgUnitsLayout/OrgUnitsLayout.tsx +51 -0
  55. package/src/{layouts → features/org-units/layouts}/OrgUnitsLayout/org-units-layout.scss +6 -4
  56. package/src/features/org-units/layouts/index.ts +8 -0
  57. package/src/features/org-units/mocks/index.ts +2 -0
  58. package/src/{mock → features/org-units/mocks}/org-units-data.ts +1 -1
  59. package/src/{mock → features/org-units/mocks}/organization-data.ts +4 -4
  60. package/src/{services → features/org-units/services}/create-new-org-unit.service.ts +1 -1
  61. package/src/{services → features/org-units/services}/delete-org-unit.service.ts +1 -1
  62. package/src/{services → features/org-units/services}/get-children-org-units.service.ts +1 -1
  63. package/src/features/org-units/services/get-org-unit-basic-data.service.ts +11 -0
  64. package/src/{services → features/org-units/services}/get-org-unit-by-id.service.ts +4 -3
  65. package/src/{services → features/org-units/services}/get-org-unit-summary.service.ts +1 -1
  66. package/src/{services → features/org-units/services}/get-organization.service.ts +3 -3
  67. package/src/{services → features/org-units/services}/get-root-org-unit-by-customer-id.service.ts +1 -1
  68. package/src/features/org-units/services/index.ts +24 -0
  69. package/src/{services → features/org-units/services}/update-org-unit.service.ts +1 -1
  70. package/src/features/org-units/types/OrgUnitSummaryData.ts +23 -0
  71. package/src/{types → features/org-units/types}/OrgUnitsData.ts +1 -1
  72. package/src/features/org-units/types/OrganizationData.ts +13 -0
  73. package/src/features/org-units/types/index.ts +6 -0
  74. package/src/{components → features/profile/components}/ProfileCard/ProfileCard.tsx +8 -2
  75. package/src/{components → features/profile/components}/ProfileSummary/ProfileSummary.tsx +3 -3
  76. package/src/features/profile/components/index.ts +5 -0
  77. package/src/features/profile/hooks/index.ts +0 -0
  78. package/src/{layouts → features/profile/layouts}/ProfileLayout/ProfileLayout.tsx +6 -7
  79. package/src/{layouts → features/profile/layouts}/ProfileLayout/profile-layout.scss +3 -1
  80. package/src/features/profile/layouts/index.ts +4 -0
  81. package/src/features/profile/mocks/index.ts +1 -0
  82. package/src/{mock → features/profile/mocks}/profile-data.ts +2 -2
  83. package/src/features/profile/services/index.ts +0 -0
  84. package/src/features/profile/types/index.ts +1 -0
  85. package/src/{components → features/shared/components}/AutocompleteDropdown/AutocompleteDropdown.tsx +3 -3
  86. package/src/{components → features/shared/components}/BasicCard/BasicCard.tsx +2 -2
  87. package/src/{components → features/shared/components}/BasicDrawer/basic-drawer.scss +2 -2
  88. package/src/{components → features/shared/components}/BuyerPortalProvider/BuyerPortalProvider.tsx +2 -2
  89. package/src/features/shared/components/Card/Card.tsx +17 -0
  90. package/src/{components → features/shared/components}/CustomerSwitch/CustomerSwitchDrawer.tsx +1 -1
  91. package/src/features/shared/components/CustomerSwitch/index.ts +13 -0
  92. package/src/{components → features/shared/components}/ErrorMessage/error-message.scss +1 -1
  93. package/src/{components → features/shared/components}/InputText/input-text.scss +4 -4
  94. package/src/{components → features/shared/components}/InternalTopbar/InternalTopbar.tsx +9 -10
  95. package/src/{components → features/shared/components}/InternalTopbar/internal-top-bar.scss +1 -0
  96. package/src/features/shared/components/MainLinksDropdownMenu/MainLinksDropdownMenu.tsx +52 -0
  97. package/src/features/shared/components/MainLinksDropdownMenu/main-links-dropdown-menu.scss +37 -0
  98. package/src/{components → features/shared/components}/Navbar/Navbar.tsx +4 -4
  99. package/src/{components → features/shared/components}/SelfManagementDrawer/SelfManagementDrawer.tsx +8 -6
  100. package/src/features/shared/components/SelfManagementDrawer/SelfManagementDrawerBody.tsx +30 -0
  101. package/src/{components → features/shared/components}/SelfManagementDrawer/self-management-drawer.scss +3 -2
  102. package/src/{components → features/shared/components}/SortFilter/SortFilter.tsx +1 -1
  103. package/src/{components → features/shared/components}/Toast/Toast.tsx +4 -5
  104. package/src/features/shared/components/index.ts +55 -0
  105. package/src/features/shared/hooks/index.ts +5 -0
  106. package/src/{hooks → features/shared/hooks}/useBuyerPortal.ts +1 -1
  107. package/src/{hooks → features/shared/hooks}/useMutation.ts +5 -5
  108. package/src/{hooks → features/shared/hooks}/useQuery.ts +3 -2
  109. package/src/{layouts → features/shared/layouts}/HomeLayout/HomeLayout.tsx +6 -6
  110. package/src/{layouts → features/shared/layouts}/HomeLayout/home-layout.scss +1 -1
  111. package/src/features/shared/layouts/index.ts +5 -0
  112. package/src/features/shared/types/index.ts +2 -0
  113. package/src/features/shared/utils/getClientContext.ts +41 -0
  114. package/src/features/shared/utils/index.ts +23 -0
  115. package/src/{components → features/users/components}/UsersCard/UsersCard.tsx +4 -6
  116. package/src/features/users/components/index.ts +1 -0
  117. package/src/features/users/hooks/index.ts +1 -0
  118. package/src/{hooks → features/users/hooks}/useUsersByOrgUnit.ts +2 -2
  119. package/src/{layouts → features/users/layouts}/UserDetailsLayout/UserDetailsLayout.tsx +13 -15
  120. package/src/{layouts → features/users/layouts}/UserDetailsLayout/user-details-layout.scss +2 -2
  121. package/src/{layouts → features/users/layouts}/UsersLayout/UsersLayout.tsx +18 -23
  122. package/src/{layouts → features/users/layouts}/UsersLayout/users-layout.scss +6 -4
  123. package/src/features/users/layouts/index.ts +5 -0
  124. package/src/features/users/mocks/index.ts +1 -0
  125. package/src/{mock → features/users/mocks}/users-data.ts +1 -1
  126. package/src/features/users/services/get-user-details.service.ts +6 -0
  127. package/src/{services → features/users/services}/get-users-by-org-unit-id.service.ts +2 -2
  128. package/src/{services → features/users/services}/get-users.service.ts +3 -4
  129. package/src/features/users/services/index.ts +6 -0
  130. package/src/features/users/types/index.ts +1 -0
  131. package/src/pages/address-details.tsx +8 -8
  132. package/src/pages/addresses.tsx +19 -11
  133. package/src/pages/contracts.tsx +13 -15
  134. package/src/pages/home.tsx +7 -7
  135. package/src/pages/org-unit-details.tsx +7 -10
  136. package/src/pages/org-units.tsx +13 -13
  137. package/src/pages/profile.tsx +21 -12
  138. package/src/pages/user-details.tsx +11 -9
  139. package/src/pages/users.tsx +15 -11
  140. package/src/themes/index.scss +2 -2
  141. package/src/themes/layouts.scss +22 -0
  142. package/src/components/Card/Card.tsx +0 -16
  143. package/src/components/CreateOrgUnitDrawer/create-org-unit-drawer.scss +0 -6
  144. package/src/components/MainLinksDropdownMenu/MainLinksDropdownMenu.tsx +0 -19
  145. package/src/components/SelfManagementDrawer/SelfManagementDrawerBody.tsx +0 -23
  146. package/src/components/UpdateOrgUnitDrawer/update-org-unit-drawer.scss +0 -6
  147. package/src/components/index.ts +0 -8
  148. package/src/layouts/OrgUnitDetailsLayout/OrgUnitDetailsLayout.tsx +0 -34
  149. package/src/layouts/OrgUnitsLayout/OrgUnitsLayout.tsx +0 -60
  150. package/src/layouts/index.scss +0 -9
  151. package/src/services/get-address-details.service.ts +0 -12
  152. package/src/services/get-addresses.service.ts +0 -56
  153. package/src/services/get-user-details.service.ts +0 -6
  154. package/src/types/OrgUnitSummaryData.ts +0 -10
  155. package/src/types/OrganizationData.ts +0 -13
  156. package/src/utils/getClientContext.ts +0 -22
  157. /package/src/{components → features/addresses/components}/AddressLine/address-line.scss +0 -0
  158. /package/src/{types → features/addresses/types}/AddressData.ts +0 -0
  159. /package/src/{components → features/profile/components}/ProfileSummary/profile-summary.scss +0 -0
  160. /package/src/{types → features/profile/types}/ProfileData.ts +0 -0
  161. /package/src/{components → features/shared/components}/AutocompleteDropdown/AutocompleteDropdownItem.tsx +0 -0
  162. /package/src/{components → features/shared/components}/AutocompleteDropdown/autocomplete-dropdown.scss +0 -0
  163. /package/src/{components → features/shared/components}/AutocompleteDropdown/useAutocompletePosition.ts +0 -0
  164. /package/src/{components → features/shared/components}/BasicDrawer/BasicDrawer.tsx +0 -0
  165. /package/src/{components → features/shared/components}/BasicDrawer/BasicDrawerBody.tsx +0 -0
  166. /package/src/{components → features/shared/components}/BasicDrawer/BasicDrawerButton.tsx +0 -0
  167. /package/src/{components → features/shared/components}/BasicDrawer/BasicDrawerFooter.tsx +0 -0
  168. /package/src/{components → features/shared/components}/BasicDrawer/BasicDrawerHeading.tsx +0 -0
  169. /package/src/{components → features/shared/components}/BasicDropdownMenu/BasicDropdownMenu.tsx +0 -0
  170. /package/src/{components → features/shared/components}/BasicDropdownMenu/basic-dropdown-menu.scss +0 -0
  171. /package/src/{components → features/shared/components}/Card/CardBody.tsx +0 -0
  172. /package/src/{components → features/shared/components}/Card/CardFooter.tsx +0 -0
  173. /package/src/{components → features/shared/components}/Card/CardHeader.tsx +0 -0
  174. /package/src/{components → features/shared/components}/Card/card.scss +0 -0
  175. /package/src/{components → features/shared/components}/Card/index.ts +0 -0
  176. /package/src/{components → features/shared/components}/CustomerSwitch/CustomerSwitchOption.tsx +0 -0
  177. /package/src/{components → features/shared/components}/CustomerSwitch/CustomerSwitchOptionsList.tsx +0 -0
  178. /package/src/{components → features/shared/components}/CustomerSwitch/CustomerSwitchSearch.tsx +0 -0
  179. /package/src/{components → features/shared/components}/CustomerSwitch/customer-switch.scss +0 -0
  180. /package/src/{components → features/shared/components}/DropdownFilter/DropdownFilter.tsx +0 -0
  181. /package/src/{components → features/shared/components}/DropdownFilter/dropdown-filter.scss +0 -0
  182. /package/src/{components → features/shared/components}/ErrorMessage/ErrorMessage.tsx +0 -0
  183. /package/src/{components → features/shared/components}/HierarchyTree/HierarchyTree.tsx +0 -0
  184. /package/src/{components → features/shared/components}/HierarchyTree/hierarchy-tree.scss +0 -0
  185. /package/src/{components → features/shared/components}/Icon/Icon.tsx +0 -0
  186. /package/src/{components → features/shared/components}/Icon/index.ts +0 -0
  187. /package/src/{components → features/shared/components}/InputText/InputText.tsx +0 -0
  188. /package/src/{components → features/shared/components}/InternalSearch/InternalSearch.tsx +0 -0
  189. /package/src/{components → features/shared/components}/InternalSearch/internal-search.scss +0 -0
  190. /package/src/{components → features/shared/components}/Logo/Logo.tsx +0 -0
  191. /package/src/{components → features/shared/components}/Navbar/navbar.scss +0 -0
  192. /package/src/{components → features/shared/components}/SelfManagementDrawer/SelfManagementDrawerHeader.tsx +0 -0
  193. /package/src/{components → features/shared/components}/SelfManagementDrawer/index.ts +0 -0
  194. /package/src/{components → features/shared/components}/SelfManagementSignInButton/SelfManagementSignInButton.tsx +0 -0
  195. /package/src/{components → features/shared/components}/SelfManagementSignInButton/index.ts +0 -0
  196. /package/src/{components → features/shared/components}/SortFilter/sort-filter.scss +0 -0
  197. /package/src/{components → features/shared/components}/Tab/Tab.tsx +0 -0
  198. /package/src/{components → features/shared/components}/Tab/TabBar.tsx +0 -0
  199. /package/src/{components → features/shared/components}/Tab/TabContent.tsx +0 -0
  200. /package/src/{components → features/shared/components}/Tab/TabOption.tsx +0 -0
  201. /package/src/{components → features/shared/components}/Tab/tab.scss +0 -0
  202. /package/src/{components → features/shared/components}/Tag/Tag.tsx +0 -0
  203. /package/src/{components → features/shared/components}/Tag/tag.scss +0 -0
  204. /package/src/{components → features/shared/components}/Toast/toast.scss +0 -0
  205. /package/src/{hooks → features/shared/hooks}/useDrawerProps.ts +0 -0
  206. /package/src/{hooks → features/shared/hooks}/useQueryParams.ts +0 -0
  207. /package/src/{layouts → features/shared/layouts}/GlobalLayout/GlobalLayout.tsx +0 -0
  208. /package/src/{layouts → features/shared/layouts}/GlobalLayout/global-layout.scss +0 -0
  209. /package/src/{types → features/shared/types}/AwaitedType.d.ts +0 -0
  210. /package/src/{types → features/shared/types}/BreadcrumbData.ts +0 -0
  211. /package/src/{types → features/shared/types}/LoaderData.ts +0 -0
  212. /package/src/{utils → features/shared/utils}/addresLabelToPropMapping.ts +0 -0
  213. /package/src/{utils → features/shared/utils}/api.ts +0 -0
  214. /package/src/{utils → features/shared/utils}/compareItems.ts +0 -0
  215. /package/src/{utils → features/shared/utils}/constants.ts +0 -0
  216. /package/src/{utils → features/shared/utils}/cookie.ts +0 -0
  217. /package/src/{utils → features/shared/utils}/getTreeDepth.ts +0 -0
  218. /package/src/{utils → features/shared/utils}/logout.tsx +0 -0
  219. /package/src/{utils → features/shared/utils}/orders.tsx +0 -0
  220. /package/src/{utils → features/shared/utils}/search.tsx +0 -0
  221. /package/src/{utils → features/shared/utils}/toQueryParams.ts +0 -0
  222. /package/src/{types → features/users/types}/UserData.ts +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vtex/faststore-plugin-buyer-portal",
3
- "version": "1.0.26",
3
+ "version": "1.0.28",
4
4
  "description": "A plugin for faststore with buyer portal",
5
5
  "main": "index.js",
6
6
  "dependencies": {
package/plugin.config.js CHANGED
@@ -9,32 +9,34 @@ module.exports = {
9
9
  path: "/org-unit/[orgUnitId]",
10
10
  appLayout: false,
11
11
  },
12
- "org-units": {
13
- path: "/org-units/[[...orgUnitId]]",
12
+ "address-details": {
13
+ path: "/address/[addressId]",
14
14
  appLayout: false,
15
15
  },
16
- contracts: {
17
- path: "/contracts/[[...orgUnitId]]",
16
+ "user-details": {
17
+ path: "/user/[userId]",
18
18
  appLayout: false,
19
19
  },
20
- addresses: {
21
- path: "/addresses",
20
+
21
+ // Shared pages
22
+ "org-units": {
23
+ path: "/org-units/[[...orgUnitId]]",
22
24
  appLayout: false,
23
25
  },
24
- "address-details": {
25
- path: "/address/[addressId]",
26
+ profile: {
27
+ path: "/profile/[[...orgUnitId]]",
26
28
  appLayout: false,
27
29
  },
28
- users: {
29
- path: "/users",
30
+ contracts: {
31
+ path: "/contracts/[[...orgUnitId]]",
30
32
  appLayout: false,
31
33
  },
32
- "user-details": {
33
- path: "/user/[userId]",
34
+ addresses: {
35
+ path: "/addresses/[[...orgUnitId]]",
34
36
  appLayout: false,
35
37
  },
36
- profile: {
37
- path: "/profile",
38
+ users: {
39
+ path: "/users/[[...orgUnitId]]",
38
40
  appLayout: false,
39
41
  },
40
42
  },
@@ -1,4 +1,4 @@
1
- import { NextApiRequest, NextApiResponse } from "next/types";
1
+ import type { NextApiRequest, NextApiResponse } from "next/types";
2
2
 
3
3
  // TODO: Remove when Plugin API feature be merged
4
4
  export default function handle(req: NextApiRequest, res: NextApiResponse) {
@@ -1,8 +1,11 @@
1
- import type { AddressData } from "../types/AddressData";
2
- import type { ContractData } from "../types/ContractData";
3
- import type { OrgUnitData } from "../types/OrgUnitsData";
4
- import type { OrgUnitSummaryData } from "../types/OrgUnitSummaryData";
5
- import { getApiUrl } from "../utils/api";
1
+ import type { AddressData } from "../features/addresses/types";
2
+ import type { ContractData } from "../features/contracts/types";
3
+ import type {
4
+ OrgUnitBasicData,
5
+ OrgUnitSummaryData,
6
+ OrgUnitData,
7
+ } from "../features/org-units/types";
8
+ import { getApiUrl } from "../features/shared/utils";
6
9
  import Client from "./Client";
7
10
 
8
11
  class BuyerPortalClient extends Client {
@@ -58,6 +61,14 @@ class BuyerPortalClient extends Client {
58
61
  // }
59
62
 
60
63
  //Org Units
64
+ getOrgUnitBasicData(id: string, cookie: string) {
65
+ return this.get<OrgUnitBasicData>(`units/${id}`, {
66
+ headers: {
67
+ Cookie: cookie,
68
+ },
69
+ });
70
+ }
71
+
61
72
  getOrgUnitSummary(id: string, cookie: string) {
62
73
  return this.get<OrgUnitSummaryData>(`units/summary/${id}`, {
63
74
  headers: {
@@ -1,4 +1,4 @@
1
- import { toQueryParams } from "../utils/toQueryParams";
1
+ import { toQueryParams } from "../features/shared/utils";
2
2
 
3
3
  interface RequestConfig<T> {
4
4
  url: string;
@@ -46,10 +46,9 @@ class Client {
46
46
  }
47
47
 
48
48
  if (!response.ok) {
49
+ console.error("Request failed:", responseData);
49
50
  throw new Error(
50
- responseData
51
- ? (responseData as unknown as { message: string }).message
52
- : "Request failed"
51
+ responseData ? JSON.stringify(responseData) : "Request failed"
53
52
  );
54
53
  }
55
54
 
@@ -1,6 +1,6 @@
1
- import { SectionOverride } from "@faststore/core";
1
+ import type { SectionOverride } from "@faststore/core";
2
2
  import { useSession_unstable as useSession } from "@faststore/core/experimental";
3
- import { SelfManagementSignInButton } from "../SelfManagementSignInButton";
3
+ import { SelfManagementSignInButton } from "../../features/shared/components";
4
4
 
5
5
  const SECTION: SectionOverride["section"] = "Navbar";
6
6
 
@@ -1,7 +1,6 @@
1
1
  import { Toggle } from "@faststore/ui";
2
2
  import Link from "next/link";
3
- import { Tag } from "../Tag/Tag";
4
- import { Icon } from "../Icon";
3
+ import { Icon, Tag } from "../../../shared/components";
5
4
 
6
5
  export type AddressLineProps = {
7
6
  id: string;
@@ -31,12 +30,12 @@ export const AddressLine = ({
31
30
  </span>
32
31
 
33
32
  {types.map((type, index) => (
34
- <Tag key={index}>{type}</Tag>
33
+ <Tag key={type}>{type}</Tag>
35
34
  ))}
36
35
  </Link>
37
36
 
38
37
  <Toggle id={id} defaultChecked={isActive} />
39
- <button data-fs-addresses-dropdown-trigger>
38
+ <button type="button" data-fs-addresses-dropdown-trigger>
40
39
  <Icon
41
40
  name="MoreVert"
42
41
  width={20}
@@ -5,25 +5,30 @@ import {
5
5
  DropdownMenu,
6
6
  DropdownButton,
7
7
  } from "@faststore/ui";
8
- import { Tag } from "../Tag/Tag";
9
- import { AddressData } from "../../types/AddressData";
10
- import { Icon } from "../Icon";
11
- import { BasicCard } from "../BasicCard/BasicCard";
8
+ import type { AddressData } from "../../types";
9
+ import { BasicCard, Icon, Tag } from "../../../shared/components";
12
10
 
13
11
  type AddressesCardProps = {
14
- addresses: AddressData[];
12
+ addresses?: AddressData[];
13
+ orgUnitData?: {
14
+ id: string | null;
15
+ name: string;
16
+ };
15
17
  };
16
18
 
17
- export default function AddressesCard({ addresses }: AddressesCardProps) {
19
+ export default function AddressesCard({
20
+ addresses = [],
21
+ orgUnitData,
22
+ }: AddressesCardProps) {
18
23
  return (
19
24
  <BasicCard
20
- footerLink="/addresses"
25
+ footerLink={`/addresses${orgUnitData?.id ? `/${orgUnitData.id}` : ""}`}
21
26
  footerMessage="Manage addresses"
22
27
  title="Addresses"
23
28
  subTitle={addresses.length ?? 0}
24
- onPlusIconClick={() => { }}
29
+ onPlusIconClick={() => {}}
25
30
  >
26
- {addresses.length &&
31
+ {Boolean(addresses.length) &&
27
32
  addresses.slice(0, 3).map((address) => {
28
33
  return (
29
34
  <div key={address.id}>
@@ -45,7 +50,10 @@ export default function AddressesCard({ addresses }: AddressesCardProps) {
45
50
  </div>
46
51
  </div>
47
52
  <div data-fs-card-action-row>
48
- <Toggle id="addressActive" defaultChecked={address.isActive} />
53
+ <Toggle
54
+ id="addressActive"
55
+ defaultChecked={address.isActive}
56
+ />
49
57
 
50
58
  <Dropdown>
51
59
  <DropdownButton data-fs-card-row-dropdown-button>
@@ -0,0 +1,2 @@
1
+ export { AddressLine, type AddressLineProps } from "./AddressLine/AddressLine";
2
+ export { default as AddressesCard } from "./AddressesCard/AddressesCard";
File without changes
@@ -1,16 +1,19 @@
1
1
  import { DropdownItem, DropdownMenu, Toggle } from "@faststore/ui";
2
- import { useState } from "react";
3
- import { InternalTopBar } from "../../components/InternalTopbar/InternalTopbar";
4
- import { AddressData } from "../../types/AddressData";
5
- import { addressLabelToPropMapping } from "../../utils/addresLabelToPropMapping";
6
- import { GlobalLayout } from "../GlobalLayout/GlobalLayout";
7
- import { Icon } from "../../components/Icon";
2
+ import { useId, useState } from "react";
3
+ import { Icon, InternalTopBar } from "../../../shared/components";
4
+ import { GlobalLayout } from "../../../shared/layouts";
5
+ import { addressLabelToPropMapping } from "../../../shared/utils";
6
+ import type { AddressData } from "../../types";
8
7
 
9
- export type AddressDetailsLayoutProps = { data: AddressData };
8
+ export type AddressDetailsLayoutProps = { data: AddressData | null };
10
9
 
11
- export const AddressDetailsLayout = ({
12
- data: { id, isActive, ...addressData },
13
- }: AddressDetailsLayoutProps) => {
10
+ export const AddressDetailsLayout = ({ data }: AddressDetailsLayoutProps) => {
11
+ // TODO: Implement the AddressDetailsLayout Fallback component
12
+ if (!data) {
13
+ return null;
14
+ }
15
+
16
+ const { id, isActive, ...addressData } = data;
14
17
  const [checked, setChecked] = useState(isActive);
15
18
 
16
19
  const props = Object.keys(addressLabelToPropMapping) as Array<
@@ -21,7 +24,6 @@ export const AddressDetailsLayout = ({
21
24
  <GlobalLayout>
22
25
  <section data-fs-address-details-section>
23
26
  <InternalTopBar
24
- rootName="Stellar Inc."
25
27
  href="/buyer-portal"
26
28
  showActions
27
29
  titleIcon={
@@ -36,7 +38,7 @@ export const AddressDetailsLayout = ({
36
38
  titleDropDownItems={
37
39
  <DropdownMenu>
38
40
  {["Location 1", "Location 2", "Location 3"].map((item) => (
39
- <DropdownItem>{item}</DropdownItem>
41
+ <DropdownItem key={item}>{item}</DropdownItem>
40
42
  ))}
41
43
  </DropdownMenu>
42
44
  }
@@ -56,13 +58,13 @@ export const AddressDetailsLayout = ({
56
58
  <div data-fs-address-details-info-wrapper>
57
59
  <div data-fs-address-details-section-header>
58
60
  <h1 data-fs-address-details-title>Address Details</h1>
59
- <button data-fs-address-details-button>
61
+ <button type="button" data-fs-address-details-button>
60
62
  <Icon
61
63
  name="Edit"
62
64
  width={20}
63
65
  height={20}
64
66
  data-fs-address-details-icon
65
- ></Icon>
67
+ />
66
68
  Edit
67
69
  </button>
68
70
  </div>
@@ -72,6 +74,7 @@ export const AddressDetailsLayout = ({
72
74
  .map((prop, index) => {
73
75
  return (
74
76
  <div
77
+ key={prop}
75
78
  data-fs-address-details-info-line
76
79
  data-fs-address-details-info-line-first={index === 0}
77
80
  >
@@ -92,31 +95,37 @@ export const AddressDetailsLayout = ({
92
95
  {addressData.locations.length}
93
96
  </span>
94
97
  </h1>
95
- <button data-fs-address-details-button>
98
+ <button type="button" data-fs-address-details-button>
96
99
  <Icon
97
100
  name="Add"
98
101
  width={20}
99
102
  height={20}
100
103
  data-fs-address-details-icon
101
- ></Icon>
104
+ />
102
105
  Add New
103
106
  </button>
104
107
  </div>
105
108
 
106
109
  <div data-fs-address-details-locations>
107
- {addressData.locations.map((location) => (
108
- <div data-fs-address-details-location>
109
- <span data-fs-address-details-location-name>{location}</span>
110
- <span data-fs-address-details-location-actions>
111
- <button data-fs-address-details-location-delete>
112
- <Icon name="Delete" width={24} height={24} />
113
- </button>
114
- <button data-fs-address-details-location-more>
115
- <Icon name="MoreVert" width={24} height={24} />
116
- </button>
117
- </span>
118
- </div>
119
- ))}
110
+ {addressData.locations.map((location) => {
111
+ const id = useId();
112
+ return (
113
+ <div key={`${location}-${id}`} data-fs-address-details-location>
114
+ <span data-fs-address-details-location-name>{location}</span>
115
+ <span data-fs-address-details-location-actions>
116
+ <button
117
+ type="button"
118
+ data-fs-address-details-location-delete
119
+ >
120
+ <Icon name="Delete" width={24} height={24} />
121
+ </button>
122
+ <button type="button" data-fs-address-details-location-more>
123
+ <Icon name="MoreVert" width={24} height={24} />
124
+ </button>
125
+ </span>
126
+ </div>
127
+ );
128
+ })}
120
129
  </div>
121
130
  </div>
122
131
  </section>
@@ -1,6 +1,6 @@
1
1
  [data-fs-address-details-section] {
2
2
  @import "@faststore/ui/src/components/molecules/Toggle/styles.scss";
3
- @import "../../components/InternalTopbar/internal-top-bar.scss";
3
+ @import "../../../shared/components/InternalTopbar/internal-top-bar.scss";
4
4
 
5
5
  width: 100%;
6
6
 
@@ -1,16 +1,16 @@
1
- import { AddressLine } from "../../components/AddressLine/AddressLine";
2
- import DropdownFilter from "../../components/DropdownFilter/DropdownFilter";
3
- import InternalSearch from "../../components/InternalSearch/InternalSearch";
4
- import { InternalTopBar } from "../../components/InternalTopbar/InternalTopbar";
5
- import SortFilter from "../../components/SortFilter/SortFilter";
6
- import { statusFilters } from "../../utils/search";
7
-
8
- import { AddressSummaryData } from "../../types/AddressData";
9
- import { GlobalLayout } from "../GlobalLayout/GlobalLayout";
10
- import { Icon } from "../../components/Icon";
11
- import { useQueryParams } from "../../hooks/useQueryParams";
12
- import { DropdownItem, DropdownMenu } from "@faststore/ui";
13
- import { MainLinksDropdownMenu } from "../../components/MainLinksDropdownMenu/MainLinksDropdownMenu";
1
+ import {
2
+ InternalTopBar,
3
+ MainLinksDropdownMenu,
4
+ InternalSearch,
5
+ DropdownFilter,
6
+ SortFilter,
7
+ Icon,
8
+ } from "../../../shared/components";
9
+ import { useQueryParams } from "../../../shared/hooks";
10
+ import { GlobalLayout } from "../../../shared/layouts";
11
+ import { statusFilters } from "../../../shared/utils";
12
+ import { AddressLine } from "../../components";
13
+ import type { AddressSummaryData } from "../../types";
14
14
 
15
15
  export type AddressLayoutProps = {
16
16
  data: AddressSummaryData[];
@@ -27,14 +27,13 @@ export const AddressLayout = ({ data }: AddressLayoutProps) => {
27
27
  <GlobalLayout>
28
28
  <section data-fs-addresses-section>
29
29
  <InternalTopBar
30
- rootName="Stellar Inc."
31
30
  showActions={false}
32
31
  title="Addresses"
33
32
  subTitle={data.length ?? 0}
34
33
  titleDropDownItems={<MainLinksDropdownMenu />}
35
34
  >
36
35
  <div data-fs-topbar-actions-wrapper>
37
- <button data-fs-topbar-dropdown-add-trigger>
36
+ <button type="button" data-fs-topbar-dropdown-add-trigger>
38
37
  <Icon
39
38
  name="Add"
40
39
  width={20}
@@ -1,12 +1,15 @@
1
+ @import "../../../shared/components/MainLinksDropdownMenu/main-links-dropdown-menu.scss";
2
+
1
3
  [data-fs-addresses-section] {
2
4
  @import "@faststore/ui/src/components/molecules/Toggle/styles.scss";
3
5
 
4
6
  @import "../../components/AddressLine/address-line.scss";
5
- @import "../../components/InternalSearch/internal-search.scss";
6
- @import "../../components/DropdownFilter/dropdown-filter.scss";
7
- @import "../../components/Tag/tag.scss";
8
- @import "../../components/SortFilter/sort-filter.scss";
9
- @import "../../components/InternalTopbar/internal-top-bar.scss";
7
+
8
+ @import "../../../shared/components/InternalSearch/internal-search.scss";
9
+ @import "../../../shared/components/DropdownFilter/dropdown-filter.scss";
10
+ @import "../../../shared/components/Tag/tag.scss";
11
+ @import "../../../shared/components/SortFilter/sort-filter.scss";
12
+ @import "../../../shared/components/InternalTopbar/internal-top-bar.scss";
10
13
 
11
14
  [data-fs-topbar-actions-wrapper] {
12
15
  display: flex;
@@ -0,0 +1,8 @@
1
+ export {
2
+ AddressDetailsLayout,
3
+ type AddressDetailsLayoutProps,
4
+ } from "./AddressDetailsLayout/AddressDetailsLayout";
5
+ export {
6
+ AddressLayout,
7
+ type AddressLayoutProps,
8
+ } from "./AddressesLayout/AddressesLayout";
@@ -1,4 +1,4 @@
1
- import { AddressData } from "../types/AddressData";
1
+ import type { AddressData } from "../types";
2
2
 
3
3
  export const addressesData: AddressData[] = [
4
4
  {
@@ -0,0 +1 @@
1
+ export { addressesData } from "./addresses-data";
@@ -0,0 +1,11 @@
1
+ import { addressesData } from "../mocks";
2
+ import type { AddressData } from "../types/AddressData";
3
+
4
+ export const getAddressDetailsService = async (
5
+ id: string
6
+ ): Promise<AddressData | null> => {
7
+ // TODO: Need to create get of single address on api
8
+ const addressData =
9
+ addressesData.find((address) => String(address.id) === id) ?? null;
10
+ return addressData;
11
+ };
@@ -0,0 +1,51 @@
1
+ import type { AddressSummaryData } from "../types/AddressData";
2
+ import { buyerPortalClient } from "../../../clients/BuyerPortalClient";
3
+ import { compareItems, statusFilters } from "../../shared/utils";
4
+
5
+ export type GetAddressesServiceProps = Partial<{
6
+ search: string;
7
+ customerId: string;
8
+ status: string;
9
+ type: string;
10
+ sort: string;
11
+ }> & {
12
+ cookie: string;
13
+ };
14
+
15
+ export const getAddressesService = async ({
16
+ search = "",
17
+ customerId,
18
+ status,
19
+ type,
20
+ sort,
21
+ cookie,
22
+ }: GetAddressesServiceProps): Promise<AddressSummaryData[]> => {
23
+ if (!customerId) {
24
+ return [];
25
+ }
26
+
27
+ const addressesData: AddressSummaryData[] = [];
28
+
29
+ try {
30
+ const { addresses = [] } = await buyerPortalClient.getAddressesByCustomerId(
31
+ customerId,
32
+ cookie
33
+ );
34
+ addressesData.push(...addresses);
35
+ } catch (err) {
36
+ console.log(">> err", err);
37
+ }
38
+
39
+ return addressesData
40
+ ?.filter((address) => {
41
+ const matchesName = address.name
42
+ .toLowerCase()
43
+ .includes(search.toLowerCase());
44
+ const matchesStatus =
45
+ !status || address.isActive === statusFilters[status];
46
+ const matchesType = !type || address.types.includes(type);
47
+
48
+ return matchesName && matchesStatus && matchesType;
49
+ })
50
+ .sort((a, b) => compareItems(a, b, sort));
51
+ };
@@ -0,0 +1,5 @@
1
+ export { getAddressDetailsService } from "./get-address-details.service";
2
+ export {
3
+ getAddressesService,
4
+ type GetAddressesServiceProps,
5
+ } from "./get-addresses.service";
@@ -0,0 +1 @@
1
+ export { AddressData, AddressSummaryData } from "./AddressData";
@@ -6,9 +6,8 @@ import {
6
6
  DropdownMenu,
7
7
  DropdownButton,
8
8
  } from "@faststore/ui";
9
- import { Icon } from "../Icon";
10
- import { BasicCard } from "../BasicCard/BasicCard";
11
- import { ContractData } from "../../types/ContractData";
9
+ import type { ContractData } from "../../types";
10
+ import { BasicCard, Icon } from "../../../shared/components";
12
11
 
13
12
  type ContractsCardProps = {
14
13
  orgUnitData?: {
@@ -0,0 +1 @@
1
+ export { default as ContractsCard } from "./ContractsCard/ContractsCard";
File without changes
@@ -1,14 +1,17 @@
1
- import { DropdownMenu, DropdownItem, Toggle } from "@faststore/ui";
2
- import DropdownFilter from "../../components/DropdownFilter/DropdownFilter";
3
- import InternalSearch from "../../components/InternalSearch/InternalSearch";
4
- import { InternalTopBar } from "../../components/InternalTopbar/InternalTopbar";
5
- import SortFilter from "../../components/SortFilter/SortFilter";
6
- import { statusFilters } from "../../utils/search";
1
+ import { Toggle } from "@faststore/ui";
7
2
 
8
- import { ContractData } from "../../types/ContractData";
9
- import { GlobalLayout } from "../GlobalLayout/GlobalLayout";
10
- import { Icon } from "../../components/Icon";
11
- import { useQueryParams } from "../../hooks/useQueryParams";
3
+ import type { ContractData } from "../../types/ContractData";
4
+ import {
5
+ InternalTopBar,
6
+ MainLinksDropdownMenu,
7
+ InternalSearch,
8
+ DropdownFilter,
9
+ SortFilter,
10
+ Icon,
11
+ } from "../../../shared/components";
12
+ import { useQueryParams } from "../../../shared/hooks";
13
+ import { GlobalLayout } from "../../../shared/layouts";
14
+ import { statusFilters } from "../../../shared/utils";
12
15
 
13
16
  export type ContractsLayoutProps = {
14
17
  data: ContractData[];
@@ -21,14 +24,8 @@ export const ContractsLayout = ({ data }: ContractsLayoutProps) => {
21
24
  <GlobalLayout>
22
25
  <section data-fs-contracts-section>
23
26
  <InternalTopBar
24
- rootName="Stellar Inc."
25
27
  title="Contracts"
26
- titleDropDownItems={
27
- <DropdownMenu>
28
- <DropdownItem>Empresa 02</DropdownItem>
29
- <DropdownItem>Empresa 03</DropdownItem>
30
- </DropdownMenu>
31
- }
28
+ titleDropDownItems={<MainLinksDropdownMenu />}
32
29
  />
33
30
 
34
31
  <div data-fs-contracts-page>
@@ -1,11 +1,11 @@
1
1
  [data-fs-contracts-section] {
2
2
  @import "@faststore/ui/src/components/molecules/Toggle/styles.scss";
3
3
 
4
- @import "../../components/InternalSearch/internal-search.scss";
5
- @import "../../components/DropdownFilter/dropdown-filter.scss";
6
- @import "../../components/Tag/tag.scss";
7
- @import "../../components/SortFilter/sort-filter.scss";
8
- @import "../../components/InternalTopbar/internal-top-bar.scss";
4
+ @import "../../../shared/components/InternalSearch/internal-search.scss";
5
+ @import "../../../shared/components/DropdownFilter/dropdown-filter.scss";
6
+ @import "../../../shared/components/Tag/tag.scss";
7
+ @import "../../../shared/components/SortFilter/sort-filter.scss";
8
+ @import "../../../shared/components/InternalTopbar/internal-top-bar.scss";
9
9
 
10
10
  [data-fs-contracts-page] {
11
11
  padding: 0 calc(var(--fs-spacing-8) + var(--fs-spacing-0));
@@ -0,0 +1,4 @@
1
+ export {
2
+ ContractsLayout,
3
+ type ContractsLayoutProps,
4
+ } from "./ContractsLayout/ContractsLayout";
@@ -1,4 +1,4 @@
1
- import { ContractData } from "../types/ContractData";
1
+ import type { ContractData } from "../types";
2
2
 
3
3
  export const contractsData: ContractData[] = [
4
4
  // Uncomment to test with a single contract
@@ -0,0 +1 @@
1
+ export { contractsData } from "./contracts-data";
@@ -1,7 +1,6 @@
1
- import { ContractData } from "../types/ContractData";
2
- import { statusFilters } from "../utils/search";
3
- import { buyerPortalClient } from "../clients/BuyerPortalClient";
4
- import { compareItems } from "../utils/compareItems";
1
+ import { buyerPortalClient } from "../../../clients/BuyerPortalClient";
2
+ import { compareItems, statusFilters } from "../../shared/utils";
3
+ import type { ContractData } from "../types";
5
4
 
6
5
  export type GetContractsServiceProps = {
7
6
  search?: string;
@@ -0,0 +1,4 @@
1
+ export {
2
+ getContractsService,
3
+ type GetContractsServiceProps,
4
+ } from "./get-contracts.service";
@@ -6,5 +6,5 @@ export type ContractData = {
6
6
  creationDate: string;
7
7
  salesRepresentative?: string;
8
8
  imageUrl?: string;
9
- assortment?: any[];
9
+ assortment?: unknown[];
10
10
  };
@@ -0,0 +1 @@
1
+ export type { ContractData } from "./ContractData";