@vtex/faststore-plugin-buyer-portal 1.0.47 → 1.0.49
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 +1 -0
- package/package.json +1 -1
- package/src/features/addresses/clients/AddressesClient.ts +17 -6
- package/src/features/addresses/layouts/AddressesLayout/AddressesLayout.tsx +87 -78
- package/src/features/addresses/layouts/AddressesLayout/addresses-layout.scss +12 -5
- package/src/features/addresses/services/get-addresses-by-unit-id.service.ts +14 -15
- package/src/features/addresses/services/index.ts +0 -4
- package/src/features/buying-policies/components/BasicBuyingPolicyDrawer/BasicBuyingPolicyDrawer.tsx +3 -3
- package/src/features/org-units/layouts/OrgUnitDetailsLayout/OrgUnitDetailsLayout.tsx +5 -5
- package/src/features/shared/components/Table/Table.tsx +2 -0
- package/src/features/shared/components/Table/TableCell/TableCell.tsx +7 -0
- package/src/features/shared/components/Table/TableHead/TableHead.tsx +1 -1
- package/src/features/shared/components/Table/TableHead/table-head.scss +2 -0
- package/src/features/shared/components/Table/TableRow/TableRow.tsx +1 -1
- package/src/features/shared/components/Table/TableRow/table-row.scss +1 -2
- package/src/features/shared/utils/api.ts +5 -4
- package/src/features/users/clients/UsersClient.ts +30 -0
- package/src/features/users/components/CreateUserDrawer/CreateUserDrawer.tsx +50 -38
- package/src/features/users/components/CreateUserDrawer/create-user-drawer.scss +27 -0
- package/src/features/users/components/UpdateUserDrawer/UpdateUserDrawer.tsx +214 -0
- package/src/features/users/components/UpdateUserDrawer/update-user-drawer.scss +40 -0
- package/src/features/users/components/UserDropdownMenu/UserDropdownMenu.tsx +18 -3
- package/src/features/users/components/UserDropdownMenu/user-dropdown-menu.scss +1 -0
- package/src/features/users/components/index.ts +4 -0
- package/src/features/users/hooks/index.ts +2 -0
- package/src/features/users/hooks/useGetUserById.ts +20 -0
- package/src/features/users/hooks/useUpdateUser.ts +23 -0
- package/src/features/users/layouts/UserDetailsLayout/UserDetailsLayout.tsx +25 -4
- package/src/features/users/layouts/UserDetailsLayout/user-details-layout.scss +1 -0
- package/src/features/users/layouts/UsersLayout/UsersLayout.tsx +46 -30
- package/src/features/users/layouts/UsersLayout/users-layout.scss +4 -1
- package/src/features/users/mocks/users-data.ts +2 -2
- package/src/features/users/services/add-user-to-org-unit.service.ts +6 -2
- package/src/features/users/services/get-user-by-id.service.ts +2 -2
- package/src/features/users/services/get-users-by-org-unit-id.service.ts +7 -3
- package/src/features/users/services/index.ts +4 -1
- package/src/features/users/services/update-user.service.ts +27 -0
- package/src/features/users/types/UserData.ts +1 -2
- package/src/features/users/utils/index.ts +1 -0
- package/src/features/users/utils/roles.ts +26 -0
- package/src/pages/addresses.tsx +30 -8
- package/src/pages/users.tsx +2 -3
- package/src/features/addresses/hooks/useDebouncedSearchAddressByUnitId.ts +0 -26
- package/src/features/addresses/hooks/useSearchAddressByUnitId.ts +0 -20
- package/src/features/addresses/services/search-address-by-unit-id.service.ts +0 -30
- package/src/features/users/services/get-user-details.service.ts +0 -6
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -2,8 +2,9 @@ import { Client } from "../../shared/clients/Client";
|
|
|
2
2
|
import { getApiUrl } from "../../shared/utils";
|
|
3
3
|
import type { AddressData, AddressInput } from "../types";
|
|
4
4
|
|
|
5
|
-
type
|
|
5
|
+
type AddressResponse = {
|
|
6
6
|
addresses: AddressData[];
|
|
7
|
+
total: number;
|
|
7
8
|
};
|
|
8
9
|
|
|
9
10
|
export default class AddressesClient extends Client {
|
|
@@ -12,17 +13,27 @@ export default class AddressesClient extends Client {
|
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
getAddressesByCustomerId(customerId: string, cookie: string) {
|
|
15
|
-
return this.get<
|
|
16
|
+
return this.get<AddressResponse>(`addresses/${customerId}`, {
|
|
16
17
|
headers: {
|
|
17
18
|
Cookie: cookie,
|
|
18
19
|
},
|
|
19
20
|
});
|
|
20
21
|
}
|
|
21
22
|
|
|
23
|
+
getAddressesByUnitId(
|
|
24
|
+
orgUnitId: string,
|
|
25
|
+
cookie: string,
|
|
26
|
+
name?: string,
|
|
27
|
+
page = 1
|
|
28
|
+
) {
|
|
29
|
+
const params = new URLSearchParams();
|
|
30
|
+
if (name) params.append("name", name);
|
|
31
|
+
if (page && page > 1) params.append("page", String(page));
|
|
32
|
+
const queryString = params.toString();
|
|
22
33
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return this.get<
|
|
34
|
+
const url = `unit/addresses/${orgUnitId}?${queryString}`;
|
|
35
|
+
|
|
36
|
+
return this.get<AddressResponse>(url, {
|
|
26
37
|
headers: {
|
|
27
38
|
Cookie: cookie,
|
|
28
39
|
},
|
|
@@ -38,7 +49,7 @@ export default class AddressesClient extends Client {
|
|
|
38
49
|
}
|
|
39
50
|
|
|
40
51
|
searchAddressesByName(customerId: string, name: string, cookie: string) {
|
|
41
|
-
return this.get<
|
|
52
|
+
return this.get<AddressResponse>(
|
|
42
53
|
`search/addresses/${customerId}?name=${name}`,
|
|
43
54
|
{
|
|
44
55
|
headers: {
|
|
@@ -1,28 +1,42 @@
|
|
|
1
|
-
import { use, useEffect, useState } from "react";
|
|
2
|
-
import { InternalSearch, HeaderInside } from "../../../shared/components";
|
|
3
1
|
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
} from "../../../shared/
|
|
2
|
+
InternalSearch,
|
|
3
|
+
HeaderInside,
|
|
4
|
+
Paginator,
|
|
5
|
+
} from "../../../shared/components";
|
|
6
|
+
import { useDrawerProps, useBuyerPortal } from "../../../shared/hooks";
|
|
8
7
|
import { ContractTabsLayout, GlobalLayout } from "../../../shared/layouts";
|
|
9
8
|
import { buyerPortalRoutes } from "../../../shared/utils/buyerPortalRoutes";
|
|
10
9
|
import { AddressDropdownMenu, CreateAddressDrawer } from "../../components";
|
|
11
10
|
import type { AddressData } from "../../types";
|
|
12
|
-
import { useDebouncedSearchAddressByUnitId } from "../../hooks/useDebouncedSearchAddressByUnitId";
|
|
13
11
|
import { Table } from "../../../shared/components/Table/Table";
|
|
14
12
|
import { EmptyState } from "../../../shared/components/EmptyState/EmptyState";
|
|
15
13
|
import { getTableColumns } from "../../../shared/components/Table/utils/tableColumns";
|
|
14
|
+
import { usePageItems } from "../../../shared/hooks/usePageItems";
|
|
16
15
|
|
|
17
16
|
export type AddressLayoutProps = {
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
addresses: AddressData[];
|
|
18
|
+
total: number;
|
|
19
|
+
search: string;
|
|
20
|
+
page: number;
|
|
20
21
|
};
|
|
21
22
|
|
|
22
|
-
export const AddressLayout = ({
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
export const AddressLayout = ({
|
|
24
|
+
addresses: initialAddresses,
|
|
25
|
+
search,
|
|
26
|
+
total,
|
|
27
|
+
page,
|
|
28
|
+
}: AddressLayoutProps) => {
|
|
29
|
+
const {
|
|
30
|
+
isLoading,
|
|
31
|
+
items: addresses,
|
|
32
|
+
searchTerm,
|
|
33
|
+
setSearchTerm,
|
|
34
|
+
increasePage,
|
|
35
|
+
} = usePageItems<AddressData>({
|
|
36
|
+
initialItems: initialAddresses,
|
|
37
|
+
search,
|
|
38
|
+
page,
|
|
39
|
+
});
|
|
26
40
|
|
|
27
41
|
const {
|
|
28
42
|
open: openCreateDrawer,
|
|
@@ -36,28 +50,6 @@ export const AddressLayout = ({ data, search }: AddressLayoutProps) => {
|
|
|
36
50
|
currentContract: contract,
|
|
37
51
|
} = useBuyerPortal();
|
|
38
52
|
|
|
39
|
-
const { searchedAddresses, isLoading } = useDebouncedSearchAddressByUnitId(
|
|
40
|
-
querySearch,
|
|
41
|
-
orgUnit?.id ?? ""
|
|
42
|
-
);
|
|
43
|
-
|
|
44
|
-
useEffect(() => {
|
|
45
|
-
if (!isLoading && querySearch.length > 0) {
|
|
46
|
-
setAddressesData(searchedAddresses);
|
|
47
|
-
}
|
|
48
|
-
}, [searchedAddresses, querySearch, isLoading]);
|
|
49
|
-
|
|
50
|
-
const handleSearch = (searchTerm: string) => {
|
|
51
|
-
setQuerySearch(searchTerm);
|
|
52
|
-
|
|
53
|
-
if (searchTerm) {
|
|
54
|
-
setQueryString("search", searchTerm);
|
|
55
|
-
} else {
|
|
56
|
-
removeQueryString("search");
|
|
57
|
-
setAddressesData(data);
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
|
|
61
53
|
return (
|
|
62
54
|
<GlobalLayout>
|
|
63
55
|
<ContractTabsLayout
|
|
@@ -77,16 +69,22 @@ export const AddressLayout = ({ data, search }: AddressLayoutProps) => {
|
|
|
77
69
|
<HeaderInside.Button onClick={openCreateDrawer} />
|
|
78
70
|
</HeaderInside>
|
|
79
71
|
|
|
80
|
-
{
|
|
72
|
+
{addresses.length === 0 && !isLoading && searchTerm.length === 0 ? (
|
|
81
73
|
<EmptyState title="No addresses yet" iconName="LocalPostOffice" />
|
|
82
74
|
) : (
|
|
83
75
|
<>
|
|
84
76
|
<div data-fs-buyer-portal-address-filter>
|
|
85
|
-
<InternalSearch
|
|
77
|
+
<InternalSearch
|
|
78
|
+
defaultValue={searchTerm}
|
|
79
|
+
textSearch={setSearchTerm}
|
|
80
|
+
/>
|
|
81
|
+
|
|
82
|
+
<Paginator.Counter
|
|
83
|
+
total={total}
|
|
84
|
+
itemsLength={addresses.length}
|
|
85
|
+
/>
|
|
86
86
|
</div>
|
|
87
|
-
{!isLoading &&
|
|
88
|
-
addressesData.length === 0 &&
|
|
89
|
-
querySearch.length > 0 ? (
|
|
87
|
+
{!isLoading && addresses.length === 0 && searchTerm.length > 0 ? (
|
|
90
88
|
<EmptyState
|
|
91
89
|
title="No results found"
|
|
92
90
|
description="Try using different terms or filters"
|
|
@@ -95,46 +93,57 @@ export const AddressLayout = ({ data, search }: AddressLayoutProps) => {
|
|
|
95
93
|
<div data-fs-addresses-table>
|
|
96
94
|
<Table>
|
|
97
95
|
<Table.Head columns={getTableColumns({ withType: true })} />
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
}
|
|
132
|
-
/>
|
|
133
|
-
))}
|
|
134
|
-
</Table.Body>
|
|
135
|
-
)}
|
|
96
|
+
|
|
97
|
+
<Table.Body>
|
|
98
|
+
{addresses.map(({ id, ...address }) => (
|
|
99
|
+
<Table.Row
|
|
100
|
+
key={id}
|
|
101
|
+
title={address.name}
|
|
102
|
+
searchTerm={search}
|
|
103
|
+
iconName="LocalPostOffice"
|
|
104
|
+
iconSize={20}
|
|
105
|
+
children={
|
|
106
|
+
Array.isArray(address.types) &&
|
|
107
|
+
address.types.length > 0
|
|
108
|
+
? address.types.map((type) => (
|
|
109
|
+
<span key={type}>{type}</span>
|
|
110
|
+
))
|
|
111
|
+
: null
|
|
112
|
+
}
|
|
113
|
+
href={buyerPortalRoutes.addressDetails({
|
|
114
|
+
orgUnitId: orgUnit?.id ?? "",
|
|
115
|
+
contractId: contract?.id ?? "",
|
|
116
|
+
addressId: id,
|
|
117
|
+
})}
|
|
118
|
+
dropdownMenu={
|
|
119
|
+
<AddressDropdownMenu
|
|
120
|
+
currentAddress={{
|
|
121
|
+
id,
|
|
122
|
+
...address,
|
|
123
|
+
}}
|
|
124
|
+
/>
|
|
125
|
+
}
|
|
126
|
+
/>
|
|
127
|
+
))}
|
|
128
|
+
</Table.Body>
|
|
136
129
|
</Table>
|
|
137
130
|
|
|
131
|
+
<div data-fs-bp-addresses-paginator>
|
|
132
|
+
{total > addresses.length && (
|
|
133
|
+
<Paginator.NextPageButton
|
|
134
|
+
onClick={increasePage}
|
|
135
|
+
disabled={isLoading}
|
|
136
|
+
>
|
|
137
|
+
{isLoading ? "Loading" : "Load More"}
|
|
138
|
+
</Paginator.NextPageButton>
|
|
139
|
+
)}
|
|
140
|
+
|
|
141
|
+
<Paginator.Counter
|
|
142
|
+
total={total}
|
|
143
|
+
itemsLength={addresses.length}
|
|
144
|
+
/>
|
|
145
|
+
</div>
|
|
146
|
+
|
|
138
147
|
{isCreateAddressDrawerOpen && (
|
|
139
148
|
<CreateAddressDrawer
|
|
140
149
|
readonly
|
|
@@ -12,8 +12,9 @@
|
|
|
12
12
|
@import "../../../shared/components/HeaderInside/header-inside.scss";
|
|
13
13
|
@import "../../../shared/components/Table/table.scss";
|
|
14
14
|
@import "../../../shared/components/EmptyState/empty-state.scss";
|
|
15
|
+
@import "../../../shared/components/Paginator/paginator.scss";
|
|
15
16
|
|
|
16
|
-
padding:
|
|
17
|
+
padding: calc(var(--fs-spacing-9) - var(--fs-spacing-0));
|
|
17
18
|
display: flex;
|
|
18
19
|
flex-direction: column;
|
|
19
20
|
height: 100%;
|
|
@@ -62,7 +63,7 @@
|
|
|
62
63
|
[data-fs-buyer-portal-address-filter] {
|
|
63
64
|
display: flex;
|
|
64
65
|
justify-content: space-between;
|
|
65
|
-
padding
|
|
66
|
+
padding: 0 0 var(--fs-spacing-4);
|
|
66
67
|
}
|
|
67
68
|
|
|
68
69
|
[data-fs-buyer-portal-address-filter-search-container] {
|
|
@@ -70,9 +71,15 @@
|
|
|
70
71
|
gap: var(--fs-spacing-1);
|
|
71
72
|
}
|
|
72
73
|
|
|
73
|
-
[data-fs-addresses-
|
|
74
|
-
|
|
74
|
+
[data-fs-addresses-table] {
|
|
75
|
+
padding-bottom: var(--fs-spacing-9);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
[data-fs-bp-addresses-paginator] {
|
|
75
79
|
display: flex;
|
|
76
|
-
|
|
80
|
+
align-items: center;
|
|
81
|
+
justify-content: space-between;
|
|
82
|
+
margin-top: var(--fs-spacing-0);
|
|
83
|
+
padding: var(--fs-spacing-2) 0;
|
|
77
84
|
}
|
|
78
85
|
}
|
|
@@ -8,6 +8,7 @@ export type GetAddressesByUnitIdServiceProps = Partial<{
|
|
|
8
8
|
status: string;
|
|
9
9
|
type: string;
|
|
10
10
|
sort: string;
|
|
11
|
+
page?: number;
|
|
11
12
|
}> & {
|
|
12
13
|
cookie: string;
|
|
13
14
|
};
|
|
@@ -18,24 +19,20 @@ export const getAddressesByUnitIdService = async ({
|
|
|
18
19
|
type,
|
|
19
20
|
sort,
|
|
20
21
|
cookie,
|
|
21
|
-
|
|
22
|
+
search = "",
|
|
23
|
+
page = 1,
|
|
24
|
+
}: GetAddressesByUnitIdServiceProps) => {
|
|
22
25
|
if (!orgUnitId) {
|
|
23
|
-
return [];
|
|
26
|
+
return { data: [], total: 0 };
|
|
24
27
|
}
|
|
28
|
+
const { addresses, total } = await addressesClient.getAddressesByUnitId(
|
|
29
|
+
orgUnitId,
|
|
30
|
+
cookie,
|
|
31
|
+
search,
|
|
32
|
+
page
|
|
33
|
+
);
|
|
25
34
|
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
try {
|
|
29
|
-
const { addresses = [] } = await addressesClient.getAddressesByUnitId(
|
|
30
|
-
orgUnitId,
|
|
31
|
-
cookie
|
|
32
|
-
);
|
|
33
|
-
addressesData.push(...addresses);
|
|
34
|
-
} catch (err) {
|
|
35
|
-
throw new Error(JSON.stringify(err));
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
return addressesData
|
|
35
|
+
const formattedAddress = addresses
|
|
39
36
|
?.filter((address) => {
|
|
40
37
|
const matchesStatus =
|
|
41
38
|
!status || address.isActive === statusFilters[status];
|
|
@@ -44,4 +41,6 @@ export const getAddressesByUnitIdService = async ({
|
|
|
44
41
|
return matchesStatus && matchesType;
|
|
45
42
|
})
|
|
46
43
|
.sort((a, b) => compareItems(a, b, sort));
|
|
44
|
+
|
|
45
|
+
return { data: formattedAddress, total };
|
|
47
46
|
};
|
|
@@ -19,10 +19,6 @@ export {
|
|
|
19
19
|
searchAddressByNameService,
|
|
20
20
|
type SearchAddressByNameProps,
|
|
21
21
|
} from "./search-address-by-name.service";
|
|
22
|
-
export {
|
|
23
|
-
searchAddressByUnitIdService,
|
|
24
|
-
type SearchAddressByUnitIdProps,
|
|
25
|
-
} from "./search-address-by-unit-id.service";
|
|
26
22
|
export {
|
|
27
23
|
editAddressService,
|
|
28
24
|
type EditAddressServiceProps,
|
package/src/features/buying-policies/components/BasicBuyingPolicyDrawer/BasicBuyingPolicyDrawer.tsx
CHANGED
|
@@ -82,7 +82,7 @@ export const BasicBuyingPolicyDrawer = ({
|
|
|
82
82
|
}));
|
|
83
83
|
};
|
|
84
84
|
|
|
85
|
-
const
|
|
85
|
+
const isAllFieldsFilled = Object.keys(form).every((key) => {
|
|
86
86
|
const value = form[key as keyof typeof form];
|
|
87
87
|
|
|
88
88
|
if (key === "action") {
|
|
@@ -110,7 +110,7 @@ export const BasicBuyingPolicyDrawer = ({
|
|
|
110
110
|
const handleConfirmClick = () => {
|
|
111
111
|
setIsTouched(true);
|
|
112
112
|
|
|
113
|
-
if (!
|
|
113
|
+
if (!isAllFieldsFilled) {
|
|
114
114
|
return;
|
|
115
115
|
}
|
|
116
116
|
|
|
@@ -160,7 +160,7 @@ export const BasicBuyingPolicyDrawer = ({
|
|
|
160
160
|
});
|
|
161
161
|
};
|
|
162
162
|
|
|
163
|
-
const isConfirmButtonEnabled =
|
|
163
|
+
const isConfirmButtonEnabled = isAllFieldsFilled && !isLoading;
|
|
164
164
|
|
|
165
165
|
return (
|
|
166
166
|
<BasicDrawer data-fs-bp-basic-buying-policy-drawer close={close} {...props}>
|
|
@@ -40,7 +40,7 @@ export const OrgUnitsDetailsLayout = ({
|
|
|
40
40
|
{/* TODO: Add person here */}
|
|
41
41
|
<OrgUnitDetailsNavbar
|
|
42
42
|
orgName={orgUnit.name}
|
|
43
|
-
person={{ name: user?.name ?? "", role: user?.
|
|
43
|
+
person={{ name: user?.name ?? "", role: user?.roles?.[0] }}
|
|
44
44
|
/>
|
|
45
45
|
<section data-fs-org-units-details-section>
|
|
46
46
|
<HeaderInside title={orgUnit.name}>
|
|
@@ -67,7 +67,7 @@ export const OrgUnitsDetailsLayout = ({
|
|
|
67
67
|
footerMessage="Manage contract settings"
|
|
68
68
|
footerLink={buyerPortalRoutes.profileDetails({
|
|
69
69
|
orgUnitId: orgUnit.id,
|
|
70
|
-
contractId: contracts[0]
|
|
70
|
+
contractId: contracts[0]?.id ?? "",
|
|
71
71
|
})}
|
|
72
72
|
enableFooter
|
|
73
73
|
>
|
|
@@ -75,7 +75,7 @@ export const OrgUnitsDetailsLayout = ({
|
|
|
75
75
|
<VerticalNav.Menu title={orgUnit.name}>
|
|
76
76
|
{getContractSettingsLinks({
|
|
77
77
|
orgUnitId: orgUnit.id,
|
|
78
|
-
contractId: contracts[0]
|
|
78
|
+
contractId: contracts[0]?.id ?? "",
|
|
79
79
|
}).map(({ name, link }) => (
|
|
80
80
|
<VerticalNav.Link key={name} link={link}>
|
|
81
81
|
{name}
|
|
@@ -139,14 +139,14 @@ export const OrgUnitsDetailsLayout = ({
|
|
|
139
139
|
footerMessage="Manage finance and compliance settings"
|
|
140
140
|
footerLink={buyerPortalRoutes.buyingPolicies({
|
|
141
141
|
orgUnitId: orgUnit.id,
|
|
142
|
-
contractId: contracts[0]
|
|
142
|
+
contractId: contracts[0]?.id,
|
|
143
143
|
})}
|
|
144
144
|
enableFooter
|
|
145
145
|
>
|
|
146
146
|
<VerticalNav.Menu title="Finance and Compliance">
|
|
147
147
|
{getFinanceSettingsLinks({
|
|
148
148
|
orgUnitId: orgUnit.id,
|
|
149
|
-
contractId: contracts[0]
|
|
149
|
+
contractId: contracts[0]?.id ?? "",
|
|
150
150
|
}).map((option) => (
|
|
151
151
|
<VerticalNav.Link key={option.name} link={option.link}>
|
|
152
152
|
{option.name}
|
|
@@ -2,6 +2,7 @@ import { TableRow } from "./TableRow/TableRow";
|
|
|
2
2
|
import { TableBody } from "./TableBody/TableBody";
|
|
3
3
|
import TableHead from "./TableHead/TableHead";
|
|
4
4
|
import { TableLoading } from "./TableLoading/TableLoading";
|
|
5
|
+
import { TableCell } from "./TableCell/TableCell";
|
|
5
6
|
|
|
6
7
|
export type TableProps = {
|
|
7
8
|
children: React.ReactNode;
|
|
@@ -15,3 +16,4 @@ Table.Head = TableHead;
|
|
|
15
16
|
Table.Body = TableBody;
|
|
16
17
|
Table.Row = TableRow;
|
|
17
18
|
Table.Loading = TableLoading;
|
|
19
|
+
Table.Cell = TableCell;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { API_URL } from "./constants";
|
|
2
2
|
import storeConfig from "discovery.config";
|
|
3
3
|
|
|
4
|
-
export function getApiUrl(operation
|
|
5
|
-
return `${API_URL(
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
export function getApiUrl(operation = "", customerId = "") {
|
|
5
|
+
return `${API_URL(
|
|
6
|
+
`https://${storeConfig?.api.storeId}.myvtex.com`,
|
|
7
|
+
operation
|
|
8
|
+
)}${customerId ? `/${customerId}` : ""}`;
|
|
8
9
|
}
|
|
9
10
|
|
|
10
11
|
export function getPostalCodeApiUrl() {
|
|
@@ -121,6 +121,36 @@ class UsersClient extends Client {
|
|
|
121
121
|
},
|
|
122
122
|
});
|
|
123
123
|
}
|
|
124
|
+
|
|
125
|
+
updateUser(
|
|
126
|
+
props: {
|
|
127
|
+
orgUnitId: string;
|
|
128
|
+
userId: string;
|
|
129
|
+
name?: string;
|
|
130
|
+
role?: string;
|
|
131
|
+
},
|
|
132
|
+
cookie: string
|
|
133
|
+
) {
|
|
134
|
+
const { orgUnitId, userId, ...data } = props;
|
|
135
|
+
|
|
136
|
+
return this.patch<
|
|
137
|
+
unknown,
|
|
138
|
+
{
|
|
139
|
+
name?: string;
|
|
140
|
+
role?: string;
|
|
141
|
+
}
|
|
142
|
+
>(
|
|
143
|
+
`units/${orgUnitId}/users/${userId}`,
|
|
144
|
+
{
|
|
145
|
+
...data,
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
headers: {
|
|
149
|
+
Cookie: cookie,
|
|
150
|
+
},
|
|
151
|
+
}
|
|
152
|
+
);
|
|
153
|
+
}
|
|
124
154
|
}
|
|
125
155
|
|
|
126
156
|
const usersClient = new UsersClient();
|