@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.
- package/package.json +1 -1
- package/plugin.config.js +16 -14
- package/src/apis/new-route.ts +1 -1
- package/src/clients/BuyerPortalClient.ts +16 -5
- package/src/clients/Client.ts +3 -4
- package/src/components/overrides/Navbar.tsx +2 -2
- package/src/{components → features/addresses/components}/AddressLine/AddressLine.tsx +3 -4
- package/src/{components → features/addresses/components}/AddressesCard/AddressesCard.tsx +18 -10
- package/src/features/addresses/components/index.ts +2 -0
- package/src/features/addresses/hooks/index.ts +0 -0
- package/src/{layouts → features/addresses/layouts}/AddressDetailsLayout/AddressDetailsLayout.tsx +38 -29
- package/src/{layouts → features/addresses/layouts}/AddressDetailsLayout/address-details-layout.scss +1 -1
- package/src/{layouts → features/addresses/layouts}/AddressesLayout/AddressesLayout.tsx +14 -15
- package/src/{layouts → features/addresses/layouts}/AddressesLayout/addresses-layout.scss +8 -5
- package/src/features/addresses/layouts/index.ts +8 -0
- package/src/{mock → features/addresses/mocks}/addresses-data.ts +1 -1
- package/src/features/addresses/mocks/index.ts +1 -0
- package/src/features/addresses/services/get-address-details.service.ts +11 -0
- package/src/features/addresses/services/get-addresses.service.ts +51 -0
- package/src/features/addresses/services/index.ts +5 -0
- package/src/features/addresses/types/index.ts +1 -0
- package/src/{components → features/contracts/components}/ContractsCard/ContractsCard.tsx +2 -3
- package/src/features/contracts/components/index.ts +1 -0
- package/src/features/contracts/hooks/index.ts +0 -0
- package/src/{layouts → features/contracts/layouts}/ContractsLayout/ContractsLayout.tsx +14 -17
- package/src/{layouts → features/contracts/layouts}/ContractsLayout/contracts-layout.scss +5 -5
- package/src/features/contracts/layouts/index.ts +4 -0
- package/src/{mock → features/contracts/mocks}/contracts-data.ts +1 -1
- package/src/features/contracts/mocks/index.ts +1 -0
- package/src/{services → features/contracts/services}/get-contracts.service.ts +3 -4
- package/src/features/contracts/services/index.ts +4 -0
- package/src/{types → features/contracts/types}/ContractData.ts +1 -1
- package/src/features/contracts/types/index.ts +1 -0
- package/src/{components → features/org-units/components}/CreateOrgUnitDrawer/CreateOrgUnitDrawer.tsx +10 -6
- package/src/features/org-units/components/CreateOrgUnitDrawer/create-org-unit-drawer.scss +6 -0
- package/src/{components → features/org-units/components}/DeleteOrgUnitDrawer/DeleteOrgUnitDrawer.tsx +13 -8
- package/src/{components → features/org-units/components}/DeleteOrgUnitDrawer/delete-org-unit-drawer.scss +6 -5
- package/src/{components → features/org-units/components}/OrgUnitsDropdownMenu/OrgUnitsDropdownMenu.tsx +8 -6
- package/src/{components → features/org-units/components}/OrgUnitsDropdownMenu/org-units-dropdown-menu.scss +1 -1
- package/src/{components → features/org-units/components}/OrgUnitsHierarchyTree/OrgUnitsHierarchyTree.tsx +12 -10
- package/src/{components → features/org-units/components}/OrgUnitsHierarchyTree/org-units-hierarchy-tree.scss +1 -1
- package/src/{components → features/org-units/components}/OrganizationalUnitsCard/OrganizationalUnitsCard.tsx +4 -6
- package/src/{components → features/org-units/components}/UpdateOrgUnitDrawer/UpdateOrgUnitDrawer.tsx +12 -7
- package/src/features/org-units/components/UpdateOrgUnitDrawer/update-org-unit-drawer.scss +6 -0
- package/src/features/org-units/components/index.ts +21 -0
- package/src/features/org-units/hooks/index.ts +6 -0
- package/src/{hooks → features/org-units/hooks}/useChildrenOrgUnits.ts +2 -2
- package/src/{hooks → features/org-units/hooks}/useCreateNewOrgUnit.ts +4 -4
- package/src/{hooks → features/org-units/hooks}/useDeleteOrgUnit.ts +3 -3
- package/src/{hooks → features/org-units/hooks}/useOrgUnitStructure.ts +7 -3
- package/src/{hooks → features/org-units/hooks}/useRootOrgUnitByCustomer.ts +2 -2
- package/src/{hooks → features/org-units/hooks}/useUpdateOrgUnit.ts +3 -3
- package/src/features/org-units/layouts/OrgUnitDetailsLayout/OrgUnitDetailsLayout.tsx +42 -0
- package/src/features/org-units/layouts/OrgUnitsLayout/OrgUnitsLayout.tsx +51 -0
- package/src/{layouts → features/org-units/layouts}/OrgUnitsLayout/org-units-layout.scss +6 -4
- package/src/features/org-units/layouts/index.ts +8 -0
- package/src/features/org-units/mocks/index.ts +2 -0
- package/src/{mock → features/org-units/mocks}/org-units-data.ts +1 -1
- package/src/{mock → features/org-units/mocks}/organization-data.ts +4 -4
- package/src/{services → features/org-units/services}/create-new-org-unit.service.ts +1 -1
- package/src/{services → features/org-units/services}/delete-org-unit.service.ts +1 -1
- package/src/{services → features/org-units/services}/get-children-org-units.service.ts +1 -1
- package/src/features/org-units/services/get-org-unit-basic-data.service.ts +11 -0
- package/src/{services → features/org-units/services}/get-org-unit-by-id.service.ts +4 -3
- package/src/{services → features/org-units/services}/get-org-unit-summary.service.ts +1 -1
- package/src/{services → features/org-units/services}/get-organization.service.ts +3 -3
- package/src/{services → features/org-units/services}/get-root-org-unit-by-customer-id.service.ts +1 -1
- package/src/features/org-units/services/index.ts +24 -0
- package/src/{services → features/org-units/services}/update-org-unit.service.ts +1 -1
- package/src/features/org-units/types/OrgUnitSummaryData.ts +23 -0
- package/src/{types → features/org-units/types}/OrgUnitsData.ts +1 -1
- package/src/features/org-units/types/OrganizationData.ts +13 -0
- package/src/features/org-units/types/index.ts +6 -0
- package/src/{components → features/profile/components}/ProfileCard/ProfileCard.tsx +8 -2
- package/src/{components → features/profile/components}/ProfileSummary/ProfileSummary.tsx +3 -3
- package/src/features/profile/components/index.ts +5 -0
- package/src/features/profile/hooks/index.ts +0 -0
- package/src/{layouts → features/profile/layouts}/ProfileLayout/ProfileLayout.tsx +6 -7
- package/src/{layouts → features/profile/layouts}/ProfileLayout/profile-layout.scss +3 -1
- package/src/features/profile/layouts/index.ts +4 -0
- package/src/features/profile/mocks/index.ts +1 -0
- package/src/{mock → features/profile/mocks}/profile-data.ts +2 -2
- package/src/features/profile/services/index.ts +0 -0
- package/src/features/profile/types/index.ts +1 -0
- package/src/{components → features/shared/components}/AutocompleteDropdown/AutocompleteDropdown.tsx +3 -3
- package/src/{components → features/shared/components}/BasicCard/BasicCard.tsx +2 -2
- package/src/{components → features/shared/components}/BasicDrawer/basic-drawer.scss +2 -2
- package/src/{components → features/shared/components}/BuyerPortalProvider/BuyerPortalProvider.tsx +2 -2
- package/src/features/shared/components/Card/Card.tsx +17 -0
- package/src/{components → features/shared/components}/CustomerSwitch/CustomerSwitchDrawer.tsx +1 -1
- package/src/features/shared/components/CustomerSwitch/index.ts +13 -0
- package/src/{components → features/shared/components}/ErrorMessage/error-message.scss +1 -1
- package/src/{components → features/shared/components}/InputText/input-text.scss +4 -4
- package/src/{components → features/shared/components}/InternalTopbar/InternalTopbar.tsx +9 -10
- package/src/{components → features/shared/components}/InternalTopbar/internal-top-bar.scss +1 -0
- package/src/features/shared/components/MainLinksDropdownMenu/MainLinksDropdownMenu.tsx +52 -0
- package/src/features/shared/components/MainLinksDropdownMenu/main-links-dropdown-menu.scss +37 -0
- package/src/{components → features/shared/components}/Navbar/Navbar.tsx +4 -4
- package/src/{components → features/shared/components}/SelfManagementDrawer/SelfManagementDrawer.tsx +8 -6
- package/src/features/shared/components/SelfManagementDrawer/SelfManagementDrawerBody.tsx +30 -0
- package/src/{components → features/shared/components}/SelfManagementDrawer/self-management-drawer.scss +3 -2
- package/src/{components → features/shared/components}/SortFilter/SortFilter.tsx +1 -1
- package/src/{components → features/shared/components}/Toast/Toast.tsx +4 -5
- package/src/features/shared/components/index.ts +55 -0
- package/src/features/shared/hooks/index.ts +5 -0
- package/src/{hooks → features/shared/hooks}/useBuyerPortal.ts +1 -1
- package/src/{hooks → features/shared/hooks}/useMutation.ts +5 -5
- package/src/{hooks → features/shared/hooks}/useQuery.ts +3 -2
- package/src/{layouts → features/shared/layouts}/HomeLayout/HomeLayout.tsx +6 -6
- package/src/{layouts → features/shared/layouts}/HomeLayout/home-layout.scss +1 -1
- package/src/features/shared/layouts/index.ts +5 -0
- package/src/features/shared/types/index.ts +2 -0
- package/src/features/shared/utils/getClientContext.ts +41 -0
- package/src/features/shared/utils/index.ts +23 -0
- package/src/{components → features/users/components}/UsersCard/UsersCard.tsx +4 -6
- package/src/features/users/components/index.ts +1 -0
- package/src/features/users/hooks/index.ts +1 -0
- package/src/{hooks → features/users/hooks}/useUsersByOrgUnit.ts +2 -2
- package/src/{layouts → features/users/layouts}/UserDetailsLayout/UserDetailsLayout.tsx +13 -15
- package/src/{layouts → features/users/layouts}/UserDetailsLayout/user-details-layout.scss +2 -2
- package/src/{layouts → features/users/layouts}/UsersLayout/UsersLayout.tsx +18 -23
- package/src/{layouts → features/users/layouts}/UsersLayout/users-layout.scss +6 -4
- package/src/features/users/layouts/index.ts +5 -0
- package/src/features/users/mocks/index.ts +1 -0
- package/src/{mock → features/users/mocks}/users-data.ts +1 -1
- package/src/features/users/services/get-user-details.service.ts +6 -0
- package/src/{services → features/users/services}/get-users-by-org-unit-id.service.ts +2 -2
- package/src/{services → features/users/services}/get-users.service.ts +3 -4
- package/src/features/users/services/index.ts +6 -0
- package/src/features/users/types/index.ts +1 -0
- package/src/pages/address-details.tsx +8 -8
- package/src/pages/addresses.tsx +19 -11
- package/src/pages/contracts.tsx +13 -15
- package/src/pages/home.tsx +7 -7
- package/src/pages/org-unit-details.tsx +7 -10
- package/src/pages/org-units.tsx +13 -13
- package/src/pages/profile.tsx +21 -12
- package/src/pages/user-details.tsx +11 -9
- package/src/pages/users.tsx +15 -11
- package/src/themes/index.scss +2 -2
- package/src/themes/layouts.scss +22 -0
- package/src/components/Card/Card.tsx +0 -16
- package/src/components/CreateOrgUnitDrawer/create-org-unit-drawer.scss +0 -6
- package/src/components/MainLinksDropdownMenu/MainLinksDropdownMenu.tsx +0 -19
- package/src/components/SelfManagementDrawer/SelfManagementDrawerBody.tsx +0 -23
- package/src/components/UpdateOrgUnitDrawer/update-org-unit-drawer.scss +0 -6
- package/src/components/index.ts +0 -8
- package/src/layouts/OrgUnitDetailsLayout/OrgUnitDetailsLayout.tsx +0 -34
- package/src/layouts/OrgUnitsLayout/OrgUnitsLayout.tsx +0 -60
- package/src/layouts/index.scss +0 -9
- package/src/services/get-address-details.service.ts +0 -12
- package/src/services/get-addresses.service.ts +0 -56
- package/src/services/get-user-details.service.ts +0 -6
- package/src/types/OrgUnitSummaryData.ts +0 -10
- package/src/types/OrganizationData.ts +0 -13
- package/src/utils/getClientContext.ts +0 -22
- /package/src/{components → features/addresses/components}/AddressLine/address-line.scss +0 -0
- /package/src/{types → features/addresses/types}/AddressData.ts +0 -0
- /package/src/{components → features/profile/components}/ProfileSummary/profile-summary.scss +0 -0
- /package/src/{types → features/profile/types}/ProfileData.ts +0 -0
- /package/src/{components → features/shared/components}/AutocompleteDropdown/AutocompleteDropdownItem.tsx +0 -0
- /package/src/{components → features/shared/components}/AutocompleteDropdown/autocomplete-dropdown.scss +0 -0
- /package/src/{components → features/shared/components}/AutocompleteDropdown/useAutocompletePosition.ts +0 -0
- /package/src/{components → features/shared/components}/BasicDrawer/BasicDrawer.tsx +0 -0
- /package/src/{components → features/shared/components}/BasicDrawer/BasicDrawerBody.tsx +0 -0
- /package/src/{components → features/shared/components}/BasicDrawer/BasicDrawerButton.tsx +0 -0
- /package/src/{components → features/shared/components}/BasicDrawer/BasicDrawerFooter.tsx +0 -0
- /package/src/{components → features/shared/components}/BasicDrawer/BasicDrawerHeading.tsx +0 -0
- /package/src/{components → features/shared/components}/BasicDropdownMenu/BasicDropdownMenu.tsx +0 -0
- /package/src/{components → features/shared/components}/BasicDropdownMenu/basic-dropdown-menu.scss +0 -0
- /package/src/{components → features/shared/components}/Card/CardBody.tsx +0 -0
- /package/src/{components → features/shared/components}/Card/CardFooter.tsx +0 -0
- /package/src/{components → features/shared/components}/Card/CardHeader.tsx +0 -0
- /package/src/{components → features/shared/components}/Card/card.scss +0 -0
- /package/src/{components → features/shared/components}/Card/index.ts +0 -0
- /package/src/{components → features/shared/components}/CustomerSwitch/CustomerSwitchOption.tsx +0 -0
- /package/src/{components → features/shared/components}/CustomerSwitch/CustomerSwitchOptionsList.tsx +0 -0
- /package/src/{components → features/shared/components}/CustomerSwitch/CustomerSwitchSearch.tsx +0 -0
- /package/src/{components → features/shared/components}/CustomerSwitch/customer-switch.scss +0 -0
- /package/src/{components → features/shared/components}/DropdownFilter/DropdownFilter.tsx +0 -0
- /package/src/{components → features/shared/components}/DropdownFilter/dropdown-filter.scss +0 -0
- /package/src/{components → features/shared/components}/ErrorMessage/ErrorMessage.tsx +0 -0
- /package/src/{components → features/shared/components}/HierarchyTree/HierarchyTree.tsx +0 -0
- /package/src/{components → features/shared/components}/HierarchyTree/hierarchy-tree.scss +0 -0
- /package/src/{components → features/shared/components}/Icon/Icon.tsx +0 -0
- /package/src/{components → features/shared/components}/Icon/index.ts +0 -0
- /package/src/{components → features/shared/components}/InputText/InputText.tsx +0 -0
- /package/src/{components → features/shared/components}/InternalSearch/InternalSearch.tsx +0 -0
- /package/src/{components → features/shared/components}/InternalSearch/internal-search.scss +0 -0
- /package/src/{components → features/shared/components}/Logo/Logo.tsx +0 -0
- /package/src/{components → features/shared/components}/Navbar/navbar.scss +0 -0
- /package/src/{components → features/shared/components}/SelfManagementDrawer/SelfManagementDrawerHeader.tsx +0 -0
- /package/src/{components → features/shared/components}/SelfManagementDrawer/index.ts +0 -0
- /package/src/{components → features/shared/components}/SelfManagementSignInButton/SelfManagementSignInButton.tsx +0 -0
- /package/src/{components → features/shared/components}/SelfManagementSignInButton/index.ts +0 -0
- /package/src/{components → features/shared/components}/SortFilter/sort-filter.scss +0 -0
- /package/src/{components → features/shared/components}/Tab/Tab.tsx +0 -0
- /package/src/{components → features/shared/components}/Tab/TabBar.tsx +0 -0
- /package/src/{components → features/shared/components}/Tab/TabContent.tsx +0 -0
- /package/src/{components → features/shared/components}/Tab/TabOption.tsx +0 -0
- /package/src/{components → features/shared/components}/Tab/tab.scss +0 -0
- /package/src/{components → features/shared/components}/Tag/Tag.tsx +0 -0
- /package/src/{components → features/shared/components}/Tag/tag.scss +0 -0
- /package/src/{components → features/shared/components}/Toast/toast.scss +0 -0
- /package/src/{hooks → features/shared/hooks}/useDrawerProps.ts +0 -0
- /package/src/{hooks → features/shared/hooks}/useQueryParams.ts +0 -0
- /package/src/{layouts → features/shared/layouts}/GlobalLayout/GlobalLayout.tsx +0 -0
- /package/src/{layouts → features/shared/layouts}/GlobalLayout/global-layout.scss +0 -0
- /package/src/{types → features/shared/types}/AwaitedType.d.ts +0 -0
- /package/src/{types → features/shared/types}/BreadcrumbData.ts +0 -0
- /package/src/{types → features/shared/types}/LoaderData.ts +0 -0
- /package/src/{utils → features/shared/utils}/addresLabelToPropMapping.ts +0 -0
- /package/src/{utils → features/shared/utils}/api.ts +0 -0
- /package/src/{utils → features/shared/utils}/compareItems.ts +0 -0
- /package/src/{utils → features/shared/utils}/constants.ts +0 -0
- /package/src/{utils → features/shared/utils}/cookie.ts +0 -0
- /package/src/{utils → features/shared/utils}/getTreeDepth.ts +0 -0
- /package/src/{utils → features/shared/utils}/logout.tsx +0 -0
- /package/src/{utils → features/shared/utils}/orders.tsx +0 -0
- /package/src/{utils → features/shared/utils}/search.tsx +0 -0
- /package/src/{utils → features/shared/utils}/toQueryParams.ts +0 -0
- /package/src/{types → features/users/types}/UserData.ts +0 -0
package/package.json
CHANGED
package/plugin.config.js
CHANGED
|
@@ -9,32 +9,34 @@ module.exports = {
|
|
|
9
9
|
path: "/org-unit/[orgUnitId]",
|
|
10
10
|
appLayout: false,
|
|
11
11
|
},
|
|
12
|
-
"
|
|
13
|
-
path: "/
|
|
12
|
+
"address-details": {
|
|
13
|
+
path: "/address/[addressId]",
|
|
14
14
|
appLayout: false,
|
|
15
15
|
},
|
|
16
|
-
|
|
17
|
-
path: "/
|
|
16
|
+
"user-details": {
|
|
17
|
+
path: "/user/[userId]",
|
|
18
18
|
appLayout: false,
|
|
19
19
|
},
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
|
|
21
|
+
// Shared pages
|
|
22
|
+
"org-units": {
|
|
23
|
+
path: "/org-units/[[...orgUnitId]]",
|
|
22
24
|
appLayout: false,
|
|
23
25
|
},
|
|
24
|
-
|
|
25
|
-
path: "/
|
|
26
|
+
profile: {
|
|
27
|
+
path: "/profile/[[...orgUnitId]]",
|
|
26
28
|
appLayout: false,
|
|
27
29
|
},
|
|
28
|
-
|
|
29
|
-
path: "/
|
|
30
|
+
contracts: {
|
|
31
|
+
path: "/contracts/[[...orgUnitId]]",
|
|
30
32
|
appLayout: false,
|
|
31
33
|
},
|
|
32
|
-
|
|
33
|
-
path: "/
|
|
34
|
+
addresses: {
|
|
35
|
+
path: "/addresses/[[...orgUnitId]]",
|
|
34
36
|
appLayout: false,
|
|
35
37
|
},
|
|
36
|
-
|
|
37
|
-
path: "/
|
|
38
|
+
users: {
|
|
39
|
+
path: "/users/[[...orgUnitId]]",
|
|
38
40
|
appLayout: false,
|
|
39
41
|
},
|
|
40
42
|
},
|
package/src/apis/new-route.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import type { AddressData } from "../types
|
|
2
|
-
import type { ContractData } from "../types
|
|
3
|
-
import type {
|
|
4
|
-
|
|
5
|
-
|
|
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: {
|
package/src/clients/Client.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { toQueryParams } from "../utils
|
|
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 "
|
|
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 "
|
|
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={
|
|
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 {
|
|
9
|
-
import {
|
|
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
|
|
12
|
+
addresses?: AddressData[];
|
|
13
|
+
orgUnitData?: {
|
|
14
|
+
id: string | null;
|
|
15
|
+
name: string;
|
|
16
|
+
};
|
|
15
17
|
};
|
|
16
18
|
|
|
17
|
-
export default function AddressesCard({
|
|
19
|
+
export default function AddressesCard({
|
|
20
|
+
addresses = [],
|
|
21
|
+
orgUnitData,
|
|
22
|
+
}: AddressesCardProps) {
|
|
18
23
|
return (
|
|
19
24
|
<BasicCard
|
|
20
|
-
footerLink=
|
|
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
|
|
53
|
+
<Toggle
|
|
54
|
+
id="addressActive"
|
|
55
|
+
defaultChecked={address.isActive}
|
|
56
|
+
/>
|
|
49
57
|
|
|
50
58
|
<Dropdown>
|
|
51
59
|
<DropdownButton data-fs-card-row-dropdown-button>
|
|
File without changes
|
package/src/{layouts → features/addresses/layouts}/AddressDetailsLayout/AddressDetailsLayout.tsx
RENAMED
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
import { DropdownItem, DropdownMenu, Toggle } from "@faststore/ui";
|
|
2
|
-
import { useState } from "react";
|
|
3
|
-
import { InternalTopBar } from "
|
|
4
|
-
import {
|
|
5
|
-
import { addressLabelToPropMapping } from "
|
|
6
|
-
import {
|
|
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
|
-
|
|
13
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
109
|
-
|
|
110
|
-
<
|
|
111
|
-
<
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
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>
|
package/src/{layouts → features/addresses/layouts}/AddressDetailsLayout/address-details-layout.scss
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[data-fs-address-details-section] {
|
|
2
2
|
@import "@faststore/ui/src/components/molecules/Toggle/styles.scss";
|
|
3
|
-
@import "
|
|
3
|
+
@import "../../../shared/components/InternalTopbar/internal-top-bar.scss";
|
|
4
4
|
|
|
5
5
|
width: 100%;
|
|
6
6
|
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
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
|
-
|
|
6
|
-
@import "
|
|
7
|
-
@import "
|
|
8
|
-
@import "
|
|
9
|
-
@import "
|
|
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 @@
|
|
|
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 @@
|
|
|
1
|
+
export { AddressData, AddressSummaryData } from "./AddressData";
|
|
@@ -6,9 +6,8 @@ import {
|
|
|
6
6
|
DropdownMenu,
|
|
7
7
|
DropdownButton,
|
|
8
8
|
} from "@faststore/ui";
|
|
9
|
-
import {
|
|
10
|
-
import { BasicCard } from "
|
|
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 {
|
|
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 {
|
|
10
|
-
|
|
11
|
-
|
|
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 "
|
|
5
|
-
@import "
|
|
6
|
-
@import "
|
|
7
|
-
@import "
|
|
8
|
-
@import "
|
|
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 @@
|
|
|
1
|
+
export { contractsData } from "./contracts-data";
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { statusFilters } from "
|
|
3
|
-
import {
|
|
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 @@
|
|
|
1
|
+
export type { ContractData } from "./ContractData";
|