@vtex/faststore-plugin-buyer-portal 1.0.32 → 1.0.34
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/public/buyer-portal-icons.svg +13 -0
- package/src/features/addresses/types/index.ts +1 -1
- package/src/features/contracts/services/index.ts +1 -1
- package/src/features/org-units/clients/OrgUnitClient.ts +9 -5
- package/src/features/org-units/components/DeleteOrgUnitDrawer/DeleteOrgUnitDrawer.tsx +1 -3
- package/src/features/org-units/components/OrgUnitsDropdownMenu/OrgUnitsDropdownMenu.tsx +56 -21
- package/src/features/org-units/components/UpdateOrgUnitDrawer/UpdateOrgUnitDrawer.tsx +1 -1
- package/src/features/org-units/hooks/index.ts +2 -0
- package/src/features/org-units/hooks/useOrgUnitByUser.ts +19 -0
- package/src/features/org-units/hooks/useSearchOrgUnits.ts +19 -0
- package/src/features/org-units/layouts/OrgUnitsLayout/OrgUnitsLayout.tsx +1 -1
- package/src/features/org-units/services/search-org-units-by-name.service.ts +7 -0
- package/src/features/shared/clients/Client.ts +12 -4
- package/src/features/shared/components/AutocompleteDropdown/AutocompleteDropdown.tsx +60 -34
- package/src/features/shared/components/AutocompleteDropdown/AutocompleteDropdownItem.tsx +1 -0
- package/src/features/shared/components/AutocompleteDropdown/autocomplete-dropdown.scss +3 -0
- package/src/features/shared/components/BasicDrawer/BasicDrawer.tsx +1 -1
- package/src/features/shared/components/BasicDrawer/BasicDrawerHeading.tsx +7 -3
- package/src/features/shared/components/BasicDrawer/basic-drawer.scss +10 -0
- package/src/features/shared/components/BasicDropdownMenu/basic-dropdown-menu.scss +10 -0
- package/src/features/shared/components/BuyerPortalProvider/BuyerPortalProvider.tsx +2 -2
- package/src/features/shared/components/CustomerSwitch/index.ts +2 -2
- package/src/features/shared/components/InputText/InputText.tsx +16 -3
- package/src/features/shared/components/InputText/input-text.scss +1 -1
- package/src/features/shared/components/MainLinksDropdownMenu/MainLinksDropdownMenu.tsx +2 -2
- package/src/features/shared/components/OptionSelected/OptionSelected.tsx +20 -0
- package/src/features/shared/components/OptionSelected/option-selected.scss +41 -0
- package/src/features/shared/components/index.ts +3 -3
- package/src/features/shared/hooks/index.ts +7 -2
- package/src/features/shared/hooks/useDebounce.ts +17 -0
- package/src/features/shared/layouts/HomeLayout/HomeLayout.tsx +2 -1
- package/src/features/shared/utils/index.ts +2 -1
- package/src/features/shared/utils/roles.ts +3 -0
- package/src/features/users/clients/UsersClient.ts +129 -0
- package/src/features/users/components/CreateUserDrawer/CreateUserDrawer.tsx +261 -0
- package/src/features/users/components/CreateUserDrawer/create-user-drawer.scss +13 -0
- package/src/features/users/components/DeleteUserDrawer/DeleteUserDrawer.tsx +100 -0
- package/src/features/users/components/DeleteUserDrawer/delete-user-drawer.scss +5 -0
- package/src/features/users/components/ReassignOrgUnitDrawer/ReassignOrgUnitDrawer.tsx +145 -0
- package/src/features/users/components/ReassignOrgUnitDrawer/reassign-org-unit-drawer.scss +8 -0
- package/src/features/users/components/UserDropdownMenu/UserDropdownMenu.tsx +69 -0
- package/src/features/users/components/UserDropdownMenu/user-dropdown-menu.scss +4 -0
- package/src/features/users/components/UsersCard/UsersCard.tsx +51 -83
- package/src/features/users/components/index.ts +8 -0
- package/src/features/users/hooks/index.ts +4 -0
- package/src/features/users/hooks/useAddUserToOrgUnit.ts +26 -0
- package/src/features/users/hooks/useDebouncedSearchOrgUnit.ts +22 -0
- package/src/features/users/hooks/useReassignUser.ts +26 -0
- package/src/features/users/hooks/useRemoveUserFromOrgUnit.ts +26 -0
- package/src/features/users/hooks/useUsersByOrgUnit.ts +1 -1
- package/src/features/users/layouts/UserDetailsLayout/UserDetailsLayout.tsx +65 -38
- package/src/features/users/layouts/UserDetailsLayout/user-details-layout.scss +68 -5
- package/src/features/users/layouts/UsersLayout/UsersLayout.tsx +45 -116
- package/src/features/users/layouts/UsersLayout/users-layout.scss +26 -3
- package/src/features/users/services/add-user-to-org-unit.service.ts +22 -0
- package/src/features/users/services/get-user-by-id.service.ts +27 -0
- package/src/features/users/services/get-users-by-org-unit-id.service.ts +25 -7
- package/src/features/users/services/index.ts +15 -4
- package/src/features/users/services/reassign-user.service.ts +23 -0
- package/src/features/users/services/remove-user-from-org-unit.service.ts +21 -0
- package/src/features/users/types/UserData.ts +3 -2
- package/src/pages/addresses.tsx +1 -1
- package/src/pages/contracts.tsx +1 -1
- package/src/pages/org-units.tsx +1 -1
- package/src/pages/user-details.tsx +41 -10
- package/src/pages/users.tsx +20 -10
- package/src/features/users/services/get-users.service.ts +0 -33
package/package.json
CHANGED
|
@@ -234,4 +234,17 @@
|
|
|
234
234
|
d="M17.4643 5.99996L15.5245 6.51972C16.2578 8.40957 16.1575 10.6033 15.0625 12.4999C13.1275 15.8514 8.85184 16.9971 5.50032 15.0621C2.1488 13.1271 1.00314 8.85143 2.93814 5.49992C4.03314 3.60332 5.88283 2.41957 7.88249 2.09606L7.36639 0.169961C4.8613 0.628903 2.57609 2.12701 1.20609 4.49992C-1.27891 8.80406 0.196175 14.3091 4.50032 16.7941C8.80447 19.2791 14.3096 17.8041 16.7946 13.4999C18.1646 11.127 18.3193 8.3989 17.4643 5.99996Z"
|
|
235
235
|
fill="currentColor" />
|
|
236
236
|
</symbol>
|
|
237
|
+
|
|
238
|
+
<symbol id="DriveFileMove" xmlns="http://www.w3.org/2000/svg"
|
|
239
|
+
viewBox="0 0 16 12" fill="none">
|
|
240
|
+
<path
|
|
241
|
+
d="M8.125 7.75L6.9375 8.9375L8 10L11 7L8 4L6.9375 5.0625L8.125 6.25H5V7.75H8.125ZM1.5 12C1.09722 12 0.746528 11.8507 0.447917 11.5521C0.149306 11.2535 0 10.9028 0 10.5V1.5C0 1.0875 0.149306 0.734376 0.447917 0.440626C0.746528 0.146876 1.09722 0 1.5 0H6L8 2H14.5C14.9125 2 15.2656 2.14688 15.5594 2.44063C15.8531 2.73438 16 3.0875 16 3.5V10.5C16 10.9028 15.8531 11.2535 15.5594 11.5521C15.2656 11.8507 14.9125 12 14.5 12H1.5ZM1.5 10.5H14.5V3.5H7.375L5.375 1.5H1.5V10.5Z"
|
|
242
|
+
fill="currentColor" />
|
|
243
|
+
</symbol>
|
|
244
|
+
|
|
245
|
+
<symbol id="Trash" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 18" fill="none">
|
|
246
|
+
<path
|
|
247
|
+
d="M3 18C2.45 18 1.97917 17.8042 1.5875 17.4125C1.19583 17.0208 1 16.55 1 16V3H0V1H5V0H11V1H16V3H15V16C15 16.55 14.8042 17.0208 14.4125 17.4125C14.0208 17.8042 13.55 18 13 18H3ZM13 3H3V16H13V3ZM5 14H7V5H5V14ZM9 14H11V5H9V14Z"
|
|
248
|
+
fill="currentColor" />
|
|
249
|
+
</symbol>
|
|
237
250
|
</svg>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { AddressData, AddressSummaryData } from "./AddressData";
|
|
1
|
+
export type { AddressData, AddressSummaryData } from "./AddressData";
|
|
@@ -10,7 +10,7 @@ export {
|
|
|
10
10
|
|
|
11
11
|
export {
|
|
12
12
|
updateContractStatusService,
|
|
13
|
-
UpdateContractStatusServiceProps,
|
|
13
|
+
type UpdateContractStatusServiceProps,
|
|
14
14
|
} from "./update-contract-status.service";
|
|
15
15
|
|
|
16
16
|
export { getContractDetailsService } from "./get-contract-details.service";
|
|
@@ -95,11 +95,15 @@ export class OrgUnitClient extends Client {
|
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
deleteOrgUnit(orgUnitId: string, cookie: string) {
|
|
98
|
-
return this.delete(
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
98
|
+
return this.delete(
|
|
99
|
+
`units/${orgUnitId}`,
|
|
100
|
+
{},
|
|
101
|
+
{
|
|
102
|
+
headers: {
|
|
103
|
+
Cookie: cookie,
|
|
104
|
+
},
|
|
105
|
+
}
|
|
106
|
+
);
|
|
103
107
|
}
|
|
104
108
|
|
|
105
109
|
getOrgUnitChildren(orgUnitId: string, cookie: string) {
|
|
@@ -5,17 +5,15 @@ import { useRouter } from "next/router";
|
|
|
5
5
|
import { useDeleteOrgUnit } from "../../hooks/useDeleteOrgUnit";
|
|
6
6
|
import { OrgUnitsHierarchyTree } from "..";
|
|
7
7
|
import { useChildrenOrgUnits } from "../../hooks";
|
|
8
|
-
import { useUsersByOrgUnit } from "../../../users/hooks";
|
|
9
8
|
import {
|
|
10
9
|
BasicDrawer,
|
|
11
10
|
ErrorMessage,
|
|
12
|
-
Icon,
|
|
13
11
|
InputText,
|
|
14
|
-
Tab,
|
|
15
12
|
type BasicDrawerProps,
|
|
16
13
|
} from "../../../shared/components";
|
|
17
14
|
import { useState } from "react";
|
|
18
15
|
|
|
16
|
+
//TODO: rever aqui quando acabar a integracao e users
|
|
19
17
|
export type DeleteOrgUnitDrawerProps = Omit<BasicDrawerProps, "children"> & {
|
|
20
18
|
id: string;
|
|
21
19
|
name: string;
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
} from "..";
|
|
8
8
|
import { useDrawerProps } from "../../../shared/hooks";
|
|
9
9
|
import { BasicDropdownMenu, Icon } from "../../../shared/components";
|
|
10
|
+
import { CreateUserDrawer } from "../../../users/components";
|
|
10
11
|
|
|
11
12
|
export type OrgUnitsDropdownMenuProps = {
|
|
12
13
|
id: string;
|
|
@@ -23,14 +24,29 @@ export const OrgUnitsDropdownMenu = ({
|
|
|
23
24
|
onCreate,
|
|
24
25
|
isComplete = true,
|
|
25
26
|
}: OrgUnitsDropdownMenuProps) => {
|
|
26
|
-
const {
|
|
27
|
-
|
|
27
|
+
const {
|
|
28
|
+
open: openCreateDrawerProps,
|
|
29
|
+
isOpen: isCreateDrawerOpen,
|
|
30
|
+
...createDrawerProps
|
|
31
|
+
} = useDrawerProps();
|
|
28
32
|
|
|
29
|
-
const {
|
|
30
|
-
|
|
33
|
+
const {
|
|
34
|
+
open: openDeleteDrawerProps,
|
|
35
|
+
isOpen: isDeleteDrawerOpen,
|
|
36
|
+
...deleteDrawerProps
|
|
37
|
+
} = useDrawerProps();
|
|
31
38
|
|
|
32
|
-
const {
|
|
33
|
-
|
|
39
|
+
const {
|
|
40
|
+
open: openUpdateDrawerProps,
|
|
41
|
+
isOpen: isUpdateDrawerOpen,
|
|
42
|
+
...updateDrawerProps
|
|
43
|
+
} = useDrawerProps();
|
|
44
|
+
|
|
45
|
+
const {
|
|
46
|
+
open: openCreateUserDrawerProps,
|
|
47
|
+
isOpen: isCreateUserDrawerOpen,
|
|
48
|
+
...createUserDrawerProps
|
|
49
|
+
} = useDrawerProps();
|
|
34
50
|
|
|
35
51
|
const sizeProps = { width: 20, height: 20 };
|
|
36
52
|
|
|
@@ -44,7 +60,7 @@ export const OrgUnitsDropdownMenu = ({
|
|
|
44
60
|
<BasicDropdownMenu.Separator />
|
|
45
61
|
{isComplete && (
|
|
46
62
|
<>
|
|
47
|
-
<DropdownItem>
|
|
63
|
+
<DropdownItem onClick={openCreateUserDrawerProps}>
|
|
48
64
|
<Icon name="Profile" {...sizeProps} />
|
|
49
65
|
Add User
|
|
50
66
|
</DropdownItem>
|
|
@@ -65,20 +81,39 @@ export const OrgUnitsDropdownMenu = ({
|
|
|
65
81
|
Delete
|
|
66
82
|
</DropdownItem>
|
|
67
83
|
</BasicDropdownMenu>
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
84
|
+
{isCreateDrawerOpen && (
|
|
85
|
+
<CreateOrgUnitDrawer
|
|
86
|
+
readonly
|
|
87
|
+
initialParentOrgUnit={{ id, name }}
|
|
88
|
+
onCreate={onCreate}
|
|
89
|
+
{...createDrawerProps}
|
|
90
|
+
isOpen={isCreateDrawerOpen}
|
|
91
|
+
/>
|
|
92
|
+
)}
|
|
93
|
+
{isDeleteDrawerOpen && (
|
|
94
|
+
<DeleteOrgUnitDrawer
|
|
95
|
+
id={id}
|
|
96
|
+
name={name}
|
|
97
|
+
{...deleteDrawerProps}
|
|
98
|
+
isOpen={isDeleteDrawerOpen}
|
|
99
|
+
/>
|
|
100
|
+
)}
|
|
101
|
+
{isUpdateDrawerOpen && (
|
|
102
|
+
<UpdateOrgUnitDrawer
|
|
103
|
+
readonly
|
|
104
|
+
id={id}
|
|
105
|
+
name={name}
|
|
106
|
+
onSuccess={onUpdate}
|
|
107
|
+
{...updateDrawerProps}
|
|
108
|
+
isOpen={isUpdateDrawerOpen}
|
|
109
|
+
/>
|
|
110
|
+
)}
|
|
111
|
+
{isCreateUserDrawerOpen && (
|
|
112
|
+
<CreateUserDrawer
|
|
113
|
+
{...createUserDrawerProps}
|
|
114
|
+
isOpen={isCreateUserDrawerOpen}
|
|
115
|
+
/>
|
|
116
|
+
)}
|
|
82
117
|
</>
|
|
83
118
|
);
|
|
84
119
|
};
|
|
@@ -4,3 +4,5 @@ export { useOrgUnitStructure } from "./useOrgUnitStructure";
|
|
|
4
4
|
export { useRootOrgUnitByCustomerId } from "./useRootOrgUnitByCustomer";
|
|
5
5
|
export { useUpdateOrgUnit } from "./useUpdateOrgUnit";
|
|
6
6
|
export { useChildrenOrgUnits } from "./useChildrenOrgUnits";
|
|
7
|
+
export { useOrgUnitByUser } from "./useOrgUnitByUser";
|
|
8
|
+
export { useSearchOrgUnits } from "./useSearchOrgUnits";
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type QueryOptions, useQuery } from "../../shared/hooks";
|
|
2
|
+
import { getOrgUnitByUserIdService } from "../services";
|
|
3
|
+
|
|
4
|
+
export const useOrgUnitByUser = (
|
|
5
|
+
userId: string,
|
|
6
|
+
options?: QueryOptions<AwaitedType<typeof getOrgUnitByUserIdService>>
|
|
7
|
+
) => {
|
|
8
|
+
const { data, error, isLoading, refetch } = useQuery(
|
|
9
|
+
`api/org-unit-by-user-id/${userId}`,
|
|
10
|
+
({ cookie }) => getOrgUnitByUserIdService({ cookie, userId }),
|
|
11
|
+
options
|
|
12
|
+
);
|
|
13
|
+
return {
|
|
14
|
+
orgUnit: data,
|
|
15
|
+
hasOrgUnitError: error,
|
|
16
|
+
isOrgUnitLoading: isLoading,
|
|
17
|
+
refetchOrgUnit: refetch,
|
|
18
|
+
};
|
|
19
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type QueryOptions, useQuery } from "../../shared/hooks";
|
|
2
|
+
import { searchOrgUnistByNameService } from "../services";
|
|
3
|
+
|
|
4
|
+
export const useSearchOrgUnits = (
|
|
5
|
+
name: string,
|
|
6
|
+
options?: QueryOptions<AwaitedType<typeof searchOrgUnistByNameService>>
|
|
7
|
+
) => {
|
|
8
|
+
const { data, error, isLoading, refetch } = useQuery(
|
|
9
|
+
`api/serach-org-unit/${name}`,
|
|
10
|
+
({ cookie }) => searchOrgUnistByNameService({ name }, cookie),
|
|
11
|
+
options
|
|
12
|
+
);
|
|
13
|
+
return {
|
|
14
|
+
searchedOrgUnits: data,
|
|
15
|
+
hasSearchedOrgUnitsError: error,
|
|
16
|
+
isSearchedOrgUnitsLoading: isLoading,
|
|
17
|
+
refetchSearchedOrgUnits: refetch,
|
|
18
|
+
};
|
|
19
|
+
};
|
|
@@ -9,6 +9,13 @@ export const searchOrgUnistByNameService = async (
|
|
|
9
9
|
{ name }: SearchOrgUnistByNameServiceProps,
|
|
10
10
|
cookie: string
|
|
11
11
|
): Promise<{ organizationalUnits: OrgUnitData[]; total: number }> => {
|
|
12
|
+
if (!name) {
|
|
13
|
+
return {
|
|
14
|
+
organizationalUnits: [],
|
|
15
|
+
total: 0,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
|
|
12
19
|
const { orgUnits } = await orgUnitClient.searchOrgUnitsByName(name, cookie);
|
|
13
20
|
|
|
14
21
|
return {
|
|
@@ -6,6 +6,7 @@ interface RequestConfig<Input = never> {
|
|
|
6
6
|
data?: Input;
|
|
7
7
|
headers?: Record<string, string>;
|
|
8
8
|
params?: Record<string, string | number | boolean>;
|
|
9
|
+
ignoreContentType?: boolean;
|
|
9
10
|
}
|
|
10
11
|
|
|
11
12
|
class Client {
|
|
@@ -21,11 +22,12 @@ class Client {
|
|
|
21
22
|
data,
|
|
22
23
|
headers = {},
|
|
23
24
|
params = {},
|
|
25
|
+
ignoreContentType = false,
|
|
24
26
|
}: RequestConfig<Input>): Promise<Return> {
|
|
25
27
|
const config: RequestInit = {
|
|
26
28
|
method,
|
|
27
29
|
headers: {
|
|
28
|
-
"Content-Type": "application/json",
|
|
30
|
+
...(ignoreContentType ? {} : { "Content-Type": "application/json" }),
|
|
29
31
|
...headers,
|
|
30
32
|
},
|
|
31
33
|
};
|
|
@@ -100,11 +102,17 @@ class Client {
|
|
|
100
102
|
});
|
|
101
103
|
}
|
|
102
104
|
|
|
103
|
-
delete<Return>(
|
|
105
|
+
delete<Return, Input>(
|
|
104
106
|
url: string,
|
|
105
|
-
|
|
107
|
+
data: Input,
|
|
108
|
+
config: Partial<RequestConfig<Input>> = {}
|
|
106
109
|
): Promise<Return> {
|
|
107
|
-
return this.request<Return>({
|
|
110
|
+
return this.request<Return, Input>({
|
|
111
|
+
url,
|
|
112
|
+
method: "DELETE",
|
|
113
|
+
data,
|
|
114
|
+
...config,
|
|
115
|
+
});
|
|
108
116
|
}
|
|
109
117
|
}
|
|
110
118
|
|
|
@@ -8,11 +8,12 @@ import {
|
|
|
8
8
|
type ReactNode,
|
|
9
9
|
createContext,
|
|
10
10
|
useContext,
|
|
11
|
+
use,
|
|
12
|
+
useCallback,
|
|
11
13
|
} from "react";
|
|
12
|
-
import { createPortal } from "react-dom";
|
|
13
|
-
import { useAutocompletePosition } from "./useAutocompletePosition";
|
|
14
14
|
import { Icon } from "../Icon";
|
|
15
15
|
import { AutocompleteDropdownItem } from "./AutocompleteDropdownItem";
|
|
16
|
+
import { useAutocompletePosition } from "..";
|
|
16
17
|
|
|
17
18
|
export type AutocompleteDropdownContextProps = {
|
|
18
19
|
focusedItemIndex: number;
|
|
@@ -48,10 +49,10 @@ export const AutocompleteDropdown = <T,>({
|
|
|
48
49
|
options = [],
|
|
49
50
|
onChange,
|
|
50
51
|
renderOption,
|
|
51
|
-
onInput,
|
|
52
52
|
disabled,
|
|
53
53
|
onConfirmKeyPress,
|
|
54
54
|
hasError,
|
|
55
|
+
value,
|
|
55
56
|
...props
|
|
56
57
|
}: AutocompleteDropdownProps<T>) => {
|
|
57
58
|
const [isOpened, setIsOpened] = useState(false);
|
|
@@ -60,49 +61,66 @@ export const AutocompleteDropdown = <T,>({
|
|
|
60
61
|
|
|
61
62
|
const autocompleteMenuRef = useRef<HTMLDivElement>(null);
|
|
62
63
|
const wrapperAutocompleteRef = useRef<HTMLDivElement>(null);
|
|
63
|
-
|
|
64
64
|
const positionStyle = useAutocompletePosition(
|
|
65
65
|
"left",
|
|
66
66
|
isOpened,
|
|
67
67
|
wrapperAutocompleteRef
|
|
68
68
|
);
|
|
69
|
-
|
|
70
69
|
const handleClick = () => {
|
|
71
70
|
!disabled && setIsOpened((old) => !old);
|
|
72
71
|
};
|
|
73
72
|
|
|
73
|
+
const scrollToItem = (index: number) => {
|
|
74
|
+
setFocusedItemIndex(index);
|
|
75
|
+
const target = autocompleteMenuRef.current?.querySelector(
|
|
76
|
+
`[data-fs-bp-autocomplete-dropdown-option-index='${index}']`
|
|
77
|
+
) as HTMLElement;
|
|
78
|
+
if (target) {
|
|
79
|
+
target.scrollIntoView({ behavior: "smooth", block: "nearest" });
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
|
|
74
83
|
const handleBackdropKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {
|
|
75
84
|
if (event.defaultPrevented || event.key === " ") {
|
|
76
85
|
return;
|
|
77
86
|
}
|
|
78
87
|
|
|
79
|
-
event.preventDefault();
|
|
80
|
-
|
|
81
88
|
switch (event.key) {
|
|
89
|
+
case "Escape":
|
|
90
|
+
event.preventDefault();
|
|
91
|
+
event.stopPropagation();
|
|
92
|
+
setIsOpened(false);
|
|
93
|
+
break;
|
|
82
94
|
case "Enter":
|
|
95
|
+
event.stopPropagation();
|
|
83
96
|
onConfirmKeyPress?.(options[focusedItemIndex]);
|
|
84
97
|
break;
|
|
85
|
-
case "ArrowDown":
|
|
98
|
+
case "ArrowDown": {
|
|
86
99
|
focusedItemIndex < options.length - 1 &&
|
|
87
|
-
|
|
100
|
+
scrollToItem(focusedItemIndex + 1);
|
|
101
|
+
|
|
88
102
|
break;
|
|
89
|
-
|
|
90
|
-
|
|
103
|
+
}
|
|
104
|
+
case "ArrowUp": {
|
|
105
|
+
focusedItemIndex > 0 && scrollToItem(focusedItemIndex - 1);
|
|
91
106
|
break;
|
|
92
|
-
|
|
93
|
-
|
|
107
|
+
}
|
|
108
|
+
case "Home": {
|
|
109
|
+
scrollToItem(0);
|
|
94
110
|
break;
|
|
95
|
-
|
|
96
|
-
|
|
111
|
+
}
|
|
112
|
+
case "End": {
|
|
113
|
+
scrollToItem(options.length - 1);
|
|
97
114
|
break;
|
|
115
|
+
}
|
|
98
116
|
default:
|
|
99
117
|
break;
|
|
100
118
|
}
|
|
101
119
|
};
|
|
102
120
|
|
|
103
|
-
const close = () => {
|
|
121
|
+
const close = useCallback(() => {
|
|
104
122
|
setIsOpened(false);
|
|
105
|
-
};
|
|
123
|
+
}, []);
|
|
106
124
|
|
|
107
125
|
useEffect(() => {
|
|
108
126
|
const event = (e: MouseEvent) => {
|
|
@@ -125,7 +143,13 @@ export const AutocompleteDropdown = <T,>({
|
|
|
125
143
|
document.removeEventListener("click", event);
|
|
126
144
|
overlayRef.removeEventListener("click", event);
|
|
127
145
|
};
|
|
128
|
-
}, []);
|
|
146
|
+
}, [close]);
|
|
147
|
+
|
|
148
|
+
useEffect(() => {
|
|
149
|
+
if (value) {
|
|
150
|
+
setIsOpened(true);
|
|
151
|
+
}
|
|
152
|
+
}, [value]);
|
|
129
153
|
|
|
130
154
|
return (
|
|
131
155
|
<AutocompleteDropdownContext.Provider
|
|
@@ -140,6 +164,11 @@ export const AutocompleteDropdown = <T,>({
|
|
|
140
164
|
data-fs-bp-autocomplete-dropdown-only-select={!onChange}
|
|
141
165
|
ref={wrapperAutocompleteRef}
|
|
142
166
|
onClick={handleClick}
|
|
167
|
+
onKeyDown={(event) => {
|
|
168
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
169
|
+
handleClick();
|
|
170
|
+
}
|
|
171
|
+
}}
|
|
143
172
|
>
|
|
144
173
|
<InputText
|
|
145
174
|
label={label}
|
|
@@ -148,25 +177,22 @@ export const AutocompleteDropdown = <T,>({
|
|
|
148
177
|
onChange={onChange}
|
|
149
178
|
disabled={disabled}
|
|
150
179
|
hasError={hasError}
|
|
180
|
+
value={value}
|
|
181
|
+
onFocus={() => setIsOpened(true)}
|
|
151
182
|
{...props}
|
|
152
183
|
/>
|
|
153
184
|
|
|
154
|
-
{isOpened
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
</ul>
|
|
166
|
-
</div>,
|
|
167
|
-
document.body
|
|
168
|
-
)
|
|
169
|
-
: null}
|
|
185
|
+
{isOpened ? (
|
|
186
|
+
<div
|
|
187
|
+
style={{ width: positionStyle.width }}
|
|
188
|
+
data-fs-bp-autocomplete-dropdown-menu
|
|
189
|
+
ref={autocompleteMenuRef}
|
|
190
|
+
>
|
|
191
|
+
<ul>
|
|
192
|
+
{options?.map((option, index) => renderOption?.(option, index))}
|
|
193
|
+
</ul>
|
|
194
|
+
</div>
|
|
195
|
+
) : null}
|
|
170
196
|
</div>
|
|
171
197
|
</AutocompleteDropdownContext.Provider>
|
|
172
198
|
);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SlideOver } from "@faststore/ui";
|
|
2
|
-
import { DrawerProps } from "../../hooks/useDrawerProps";
|
|
2
|
+
import type { DrawerProps } from "../../hooks/useDrawerProps";
|
|
3
3
|
import { BasicDrawerHeading } from "./BasicDrawerHeading";
|
|
4
4
|
import { BasicDrawerBody } from "./BasicDrawerBody";
|
|
5
5
|
import { BasicDrawerFooter } from "./BasicDrawerFooter";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { ComponentProps } from "react";
|
|
1
|
+
import type { ComponentProps } from "react";
|
|
2
2
|
import { Icon } from "../Icon";
|
|
3
3
|
|
|
4
4
|
export type BasicDrawerHeadingProps = {
|
|
5
5
|
title: React.ReactNode;
|
|
6
6
|
onClose?: () => void;
|
|
7
|
-
} & ComponentProps<"header">;
|
|
7
|
+
} & Omit<ComponentProps<"header">, "title">;
|
|
8
8
|
|
|
9
9
|
export const BasicDrawerHeading = ({
|
|
10
10
|
title,
|
|
@@ -14,7 +14,11 @@ export const BasicDrawerHeading = ({
|
|
|
14
14
|
return (
|
|
15
15
|
<header data-fs-bp-basic-drawer-heading {...props}>
|
|
16
16
|
<h2 data-fs-bp-basic-drawer-heading-title>{title}</h2>
|
|
17
|
-
<button
|
|
17
|
+
<button
|
|
18
|
+
type="button"
|
|
19
|
+
data-fs-bp-basic-drawer-heading-close-button
|
|
20
|
+
onClick={onClose}
|
|
21
|
+
>
|
|
18
22
|
<Icon
|
|
19
23
|
data-fs-bp-basic-drawer-heading-close-icon
|
|
20
24
|
name="Close"
|
|
@@ -45,6 +45,16 @@
|
|
|
45
45
|
flex: 1;
|
|
46
46
|
min-height: auto;
|
|
47
47
|
|
|
48
|
+
p {
|
|
49
|
+
font-weight: 400;
|
|
50
|
+
font-size: var(--fs-text-size-1);
|
|
51
|
+
line-height: calc(var(--fs-spacing-3) + var(--fs-spacing-0));
|
|
52
|
+
}
|
|
53
|
+
a {
|
|
54
|
+
color: #0366dd;
|
|
55
|
+
text-decoration: none;
|
|
56
|
+
}
|
|
57
|
+
|
|
48
58
|
[data-fs-bp-basic-drawer-body-wrapper] {
|
|
49
59
|
padding: var(--fs-spacing-8)
|
|
50
60
|
calc(var(--fs-spacing-8) + var(--fs-spacing-0)) 0
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
width: auto;
|
|
4
4
|
background-color: #fff;
|
|
5
5
|
padding: var(--fs-spacing-1) 0;
|
|
6
|
+
min-width: 15rem;
|
|
6
7
|
|
|
7
8
|
[data-fs-dropdown-item] {
|
|
8
9
|
display: flex;
|
|
@@ -22,6 +23,15 @@
|
|
|
22
23
|
[data-fs-toggle] {
|
|
23
24
|
margin-left: auto;
|
|
24
25
|
}
|
|
26
|
+
|
|
27
|
+
&:hover {
|
|
28
|
+
background-color: #f5f5f5;
|
|
29
|
+
color: #000;
|
|
30
|
+
|
|
31
|
+
svg {
|
|
32
|
+
color: #000;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
25
35
|
}
|
|
26
36
|
|
|
27
37
|
[data-fs-bp-basic-dropdown-menu-separator] {
|
|
@@ -4,7 +4,7 @@ import type { OrgUnitBasicData } from "../../../org-units/types";
|
|
|
4
4
|
|
|
5
5
|
export type BuyerPortalContextType = {
|
|
6
6
|
clientContext: ClientContext;
|
|
7
|
-
currentOrgUnit?: OrgUnitBasicData
|
|
7
|
+
currentOrgUnit?: OrgUnitBasicData;
|
|
8
8
|
};
|
|
9
9
|
|
|
10
10
|
export const BuyerPortalContext = createContext<
|
|
@@ -13,7 +13,7 @@ export const BuyerPortalContext = createContext<
|
|
|
13
13
|
|
|
14
14
|
export type BuyerPortalProviderProps = {
|
|
15
15
|
clientContext: ClientContext;
|
|
16
|
-
currentOrgUnit?: OrgUnitBasicData
|
|
16
|
+
currentOrgUnit?: OrgUnitBasicData;
|
|
17
17
|
children: ReactNode;
|
|
18
18
|
};
|
|
19
19
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export { CustomerSwitchDrawer } from "./CustomerSwitchDrawer";
|
|
2
2
|
export {
|
|
3
3
|
CustomerSwitchOption,
|
|
4
|
-
CustomerSwitchOptionProps,
|
|
4
|
+
type CustomerSwitchOptionProps,
|
|
5
5
|
} from "./CustomerSwitchOption";
|
|
6
6
|
export {
|
|
7
7
|
CustomerSwitchOptionsList,
|
|
8
|
-
CustomerSwitchOptionsListProps,
|
|
8
|
+
type CustomerSwitchOptionsListProps,
|
|
9
9
|
} from "./CustomerSwitchOptionsList";
|
|
10
10
|
export {
|
|
11
11
|
CustomerSwitchSearch,
|
|
@@ -7,6 +7,8 @@ import {
|
|
|
7
7
|
useImperativeHandle,
|
|
8
8
|
useRef,
|
|
9
9
|
useState,
|
|
10
|
+
type KeyboardEvent,
|
|
11
|
+
type MouseEvent,
|
|
10
12
|
} from "react";
|
|
11
13
|
|
|
12
14
|
export type InputTextProps = ComponentProps<"input"> & {
|
|
@@ -44,7 +46,12 @@ export const InputText = forwardRef<HTMLInputElement, InputTextProps>(
|
|
|
44
46
|
|
|
45
47
|
useImperativeHandle(ref, () => inputRef?.current!);
|
|
46
48
|
|
|
47
|
-
const handleWrapperClick = (
|
|
49
|
+
const handleWrapperClick = (
|
|
50
|
+
event?:
|
|
51
|
+
| MouseEvent<HTMLLabelElement, globalThis.MouseEvent>
|
|
52
|
+
| KeyboardEvent<HTMLLabelElement>
|
|
53
|
+
) => {
|
|
54
|
+
event?.preventDefault();
|
|
48
55
|
!disabled && setIsFocused(true);
|
|
49
56
|
};
|
|
50
57
|
|
|
@@ -61,9 +68,14 @@ export const InputText = forwardRef<HTMLInputElement, InputTextProps>(
|
|
|
61
68
|
data-fs-bp-input-text-is-disabled={disabled}
|
|
62
69
|
data-fs-bp-input-text-has-error={hasError}
|
|
63
70
|
{...wrapperProps}
|
|
64
|
-
onClick={handleWrapperClick}
|
|
71
|
+
onClick={() => handleWrapperClick()}
|
|
65
72
|
>
|
|
66
|
-
<label
|
|
73
|
+
<label
|
|
74
|
+
data-fs-bp-input-text-label
|
|
75
|
+
htmlFor={id}
|
|
76
|
+
onClick={(event) => handleWrapperClick(event)}
|
|
77
|
+
onKeyDown={handleWrapperClick}
|
|
78
|
+
>
|
|
67
79
|
{label}
|
|
68
80
|
</label>
|
|
69
81
|
{icon && <span data-fs-bp-input-text-icon>{icon}</span>}
|
|
@@ -75,6 +87,7 @@ export const InputText = forwardRef<HTMLInputElement, InputTextProps>(
|
|
|
75
87
|
ref={inputRef}
|
|
76
88
|
onBlur={handleBlur}
|
|
77
89
|
disabled={disabled}
|
|
90
|
+
onFocus={() => setIsFocused(true)}
|
|
78
91
|
/>
|
|
79
92
|
</div>
|
|
80
93
|
);
|